I need to get the child parameter value from Graphql.
Here is my Graphql query:
{
foods(type: "fries") {
drinks {
calorie(joule :1500) {
name
}
}
}
}
I can get the type
field easily but also I need to get the joule
value.
When I investigate this problem I find a file called generated.go
, so I found the following code part for sending parameters to the target function;
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return storage.FoodFinder(rctx, args["type"].(string)) //only args sended to function.
})
I can get whole raw data from rctx
variable but I don't wanna parse that, seems grueling.
So How can I get joule
, one of that child fields from rctx
context variable?