-
Notifications
You must be signed in to change notification settings - Fork 2k
Improve documention of resolve function (info param) #799
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
Comments
wait.. what? anyway, resolver signature should be: obj -> the object resolved, (rootQuery argument for root types (such as Query)) |
(Sorry, I had typos in the first post which I just fixed.) What you described is not what I'm seeing. In my root resolvers, the first arg in the list is an object of input arguments for that field, and the second arg is clearly the context object. |
@odigity just have a look at the source code and you find the signature. that is the way I find it in v0.5 update, that's when I met the error too. |
If you look at the source, you can see the resolve function is passed The best non-source documentation for this is probably the "Execution" page on graphql.org, although it doesn't mention the |
As I explained in careful detail in my initial post, the signature you're describing does not the match the results I'm getting. For example, I'm seeing args in the first position. |
Do you have some sample code that we could look at? The snippets in your post aren't something that I could run and try to repro what you're seeing. |
It'll take some time, but I'll try to get to it soon. |
The graphql-js/src/type/definition.js Lines 584 to 595 in bacd412
|
Closing this issue since it is starting to age. The flow types and documentation should help, and you can also check out some of the examples and tests in this repository to see how resolvers are called with values. What you might be running into is the default resolver, which attempts to look for a method on the |
For those who are still stumbling upon this issue, I've written an article that documents the internals of the |
@odigity I know what you were talking about. I was confused just like you were. I am using the I didn't dive into the source code. The following is just my guess. Part of them are not listed clearly in the document but just a sentence:
I think the reason that all the first argument |
I have figured it out. If you do not explicity provide your own resolver, then then default resolver is used. This the behaviour when you use buildschema. What then happens is the default resolver will call your resolvers with (args, context, info). In order to access the root value, you would need to use the |
@Alappin you are right. I listed I'm using When we use Instead we have to provide Since no real resolvers are provided to the graphql-js/src/execution/execute.js Line 585 in dda7c4a
When we think the graphql-js/src/execution/execute.js Line 650 in dda7c4a
instead the function is actually a graphql-js/src/execution/execute.js Line 1160 in dda7c4a
|
I've read all the docs at graphql.org and the READMEs for graphql-js and express-graphql, and I cannot find a reference for the resolver function signature.
The GraphQL docs suggest:
But my brief testing with my new express-graphql server I just made (first one) suggests the signature GraphQL.js uses is:
From my console debugging:
(I just learned GraphQL/GraphQL.js last week, so I might be missing something obvious.)
The text was updated successfully, but these errors were encountered: