Child resolver args is empty
See original GitHub issueversion: apollo-server 2.0.4
Problem Given the following resolver:
module.exports = {
Query: {
myQuery = (parent, args, context) => {
// args.queryParam is defined
returns arrayOfItems
}
},
Item: {
myResolver: async (parent, args, context) => {
const { queryParam } = args;
// queryParam is undefined here
if (queryParam) {
return { ... omitted }
}
return null;
},
},
};
query {
myQuery(queryParam: "mystuff") {
...
}
}
I have checked when myResolver
is called and the second params args
is always empty. Even when passing the the param when running the query.
I have checked the args
of myQuery
and it successfully passes the arg there, but it does not show up on myResolver
. I was under the intention that myResolver
should have this arg as well. I even remember it working before, but it has stopped working for me.
As a workaround I am using myQuery
to set the arg in the context
and then I can get it from myResolver.context
.
Expected
myResolver
to have the arg queryParam
when calling the query with it.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:6
- Comments:10 (2 by maintainers)
Top Results From Across the Web
Graphql-Access arguments in child resolvers - Stack Overflow
My question is that how can I access args which is available in root resolver( getTotalVehicals ) in any of the child resolvers?...
Read more >Resolvers - Apollo GraphQL Docs
A resolver can optionally accept four positional arguments: (parent, args, contextValue, info) . Learn more about these arguments. The args argument is an ......
Read more >Use the GraphQL Parent Object in a Child Resolver | egghead.io
Data resolved out of a parent resolver can be accessed by a child resolver. ... If we do that, we'll just get null...
Read more >How to get the args of the parent resolver in the Apollo Server?
There might be different resolvers that return the parent and not all of them might have the given parameter. Using information from these ......
Read more >Resolvers | Strawberry GraphQL
In Strawberry there are two ways of defining resolvers; the first is to pass a ... between null (maps to None in Python)...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m also seeing this on apollo-server-express 2.4.8. The args param is always empty on child resolvers, from what I have seen it is because
Item
in your case is a type and therefore doesn’t have args. I’m not sure if that is the reason or not but it seems like it would be nice if args were passed down.By intention the query is never passed from the parent resolver to the child resolver, because child resolvers could have their own query. In this case we have a Product resolver with its query (“articleNumber”). It has a child resolver called currentPricing with its own query. In the resolver code for the currentPricing resolver you will only get the “currency” query.