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

mergeSchema - fragments don't query fields added during merge #605

Closed
goldensunliu opened this issue Jan 30, 2018 · 4 comments
Closed

mergeSchema - fragments don't query fields added during merge #605

goldensunliu opened this issue Jan 30, 2018 · 4 comments

Comments

@goldensunliu
Copy link

During resolve, if the fragment includes fields added/extended during the merge are not queried for.
here is a simple example forked from the Doc's Example

LaunchPad Example

the basic idea is now type User also has a new field chripCount which infers its value for the extended field chirps by doing:

      chripCount: {
        fragment: 'fragment UserInferringFragment on User { id chirps }',
        resolve(parent) {
          return parent.chrips && parent.chrips.length
        }
      }

this field will always resolve to be 'null'. Looks like the chrips field never got resolved

@marktani
Copy link

marktani commented Feb 2, 2018

Looks like the root issue of this one: prisma-labs/graphql-prisma-typescript#91

@freiksenet
Copy link
Contributor

It can't really work this way atm. It's kinda a chicken and egg problem. fragment param works in a way that they modify a query to subschema. If the field doesn't exist in subschema, naturally it won't be queried. It's not possible to modify the running query inside a running graphql executor. In order for this to work, one should modify the query that is applied to the merged schema. In #527, you could try to apply transforms on the merged schema to do it.

@freiksenet
Copy link
Contributor

You could also just use delegateToSchema when calling mergedSchema, instead of querying it with GraphQL, this way you could pass fragment replacements that should happen on merged schema level.

@goldensunliu
Copy link
Author

@freiksenet thanks! I will keep an eye on the merge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants