Skip to content

Custom global fieldResolver called on introspection fields #1015

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

Closed
southpolesteve opened this issue Aug 28, 2017 · 7 comments
Closed

Custom global fieldResolver called on introspection fields #1015

southpolesteve opened this issue Aug 28, 2017 · 7 comments

Comments

@southpolesteve
Copy link

Ran into this when adding a custom schema wide fieldResolver. This resolver will also get called for introspection fields which was surprising to me. Is this the expected behavior?

@fredericnowak
Copy link

I ran into the same issue, when launching the graphiql console.
@southpolesteve did you find a workaround or a way to fallback to the default fieldResolver ?

@southpolesteve
Copy link
Author

@growak I ended up copying the default resolver behavior into my custom resolver and checking the type via the info argument to make sure it is my type and not a built in graphql type

@fredericnowak
Copy link

@southpolesteve thx

@sibelius
Copy link

@southpolesteve can you share your solution?

can we close this?

@IvanGoncharov
Copy link
Member

Ran into this when adding a custom schema wide fieldResolver. This resolver will also get called for introspection fields which was surprising to me. Is this the expected behavior?

@southpolesteve @fredericnowak @sibelius It shouldn't work like that since field specific resolvers always take precedence over schema wide fieldResolver, see here:

const resolveFn = fieldDef.resolve || exeContext.fieldResolver;

and all introspection types have assigned resolvers.

How did you construct your schema?
Did you use new GraphQLSchema(, buildSchema or something else?

Such behavior can occur if you construct your schema using buildClientSchema or similar function that doesn't use built-in introspections types.

@southpolesteve
Copy link
Author

Sorry I no longer have access to the code where I solved this problem :/

@IvanGoncharov
Copy link
Member

I did some testing and you were right. There are a few introspection fields that don't have resolver attached. So I created #1329 PR which should fix this issue.

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

4 participants