Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mergeSchemas cannot resolve scalar type in Query, Mutation if type is present by extend #847

Closed
1 of 5 tasks
NattapongSiri opened this issue Jun 16, 2018 · 4 comments
Closed
1 of 5 tasks
Labels
has-reproduction ❤ Has a reproduction in a codesandbox or single minimal repository

Comments

@NattapongSiri
Copy link

  • has-reproduction
  • feature
  • docs
  • blocking
  • good first issue

define type by

type Item {
  name: String
}

then makeExectuableSchema out of it.
define another type

extend type Item {
  cost: Float
}
type Query: {
  findItemCostMoreThan(giveCost: Float): [Item]
}

them mergeSchemas of both. Now it complain that it doesn't know Float.
workaround is to split second definition into extend and query then call mergeSchemas twice.
First with extend type definition. Second with Query.
Based on some of my investigation, mergeSchemas seem to detect type out of compile schema but not on string based schema. So split mergeSchemas into two phrase can workaround this.

This is possibly the same issue with #825 and #815

@ghost ghost added the has-reproduction ❤ Has a reproduction in a codesandbox or single minimal repository label Jun 16, 2018
@NattapongSiri
Copy link
Author

NattapongSiri commented Jun 18, 2018

After spend some more time investigate mergeSchemas function...
I found that root cause is due to this part inside mergeSchemas.

https://github.com/apollographql/graphql-tools/blob/248527d497aa1fe5ff5648e94bf38366121d9d92/src/stitching/mergeSchemas.ts#L243-L254

Query, Mutation, and Subscription are being used prior to extensions being apply.
Some interesting thing is..
Will this enhancement fixs this issue ?

@grantwwu
Copy link

grantwwu commented Nov 20, 2018

@NattapongSiri graphql-js isn't a dependency of this project, so I don't think that would fix it.

EDIT: Oops, didn't realize that the package name was graphql.

This issue is blocking my org's forward progress, so I'm going to be working on this until it gets fixed...

@grantwwu
Copy link

https://github.com/grantwwu/graphql-tools-847-repro/ I have uploaded a minimal reproducing repository.

@yaacovCR
Copy link
Collaborator

yaacovCR commented Apr 1, 2020

mergeSchemas does not merge typedefs (!), it stitches them together by proxying. Merging can be done within makeExecutableSchema by just using an array of strings for typeDefs.

See #443 (comment)

@yaacovCR yaacovCR closed this as completed Apr 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
has-reproduction ❤ Has a reproduction in a codesandbox or single minimal repository
Projects
None yet
Development

No branches or pull requests

3 participants