Skip to content

Make the default resolver use args and context #468

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

Merged
merged 1 commit into from
Aug 22, 2016

Conversation

lacker
Copy link

@lacker lacker commented Aug 22, 2016

Right now the default resolver is really handy in some cases. If you have a field that uses args and/or context, though, you can't use a default resolver because the default resolver just throws them away, even if there's a function hanging off the source object. There's no real benefit to that behavior, so this PR passes args and context along to the function hanging off the source object if there is one. This makes it easier to use es6 classes in conjunction with graphql.js.

This is backward compatible unless you happened to use a default resolver method which relied on not receiving any arguments despite the schema allowing arguments, which seems perverse enough that we can ignore that case.

@ghost ghost added the CLA Signed label Aug 22, 2016
@leebyron
Copy link
Contributor

Yeah, agreed this is more flexible behavior. This default behavior started conservatively, but I like this behavior better.

This is backward compatible unless you happened to use a default resolver method which relied on not receiving any arguments despite the schema allowing arguments, which seems perverse enough that we can ignore that case.

I bet this is more common than we anticipate. It shouldn't matter though - the next cut of graphql-js will be a major version.

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

Successfully merging this pull request may close these issues.

2 participants