graphql-go
graphql-go copied to clipboard
Single root resolver to recursively resolve the full query
Hi,
I am investigating this library to be used in our project. From what I am seeing, we need to pass a resolver struct whose fields/methods map to the graphQL query, and the engine recursively calls each of its nested fields.
What I am looking to achieve is to have a single root resolver, and I want to access the query AST myself to construct the full response. The reason for this is to be able to dynamically generate efficient SQL queries joining multiple tables, rather than querying multiple times. Similar to what https://hasura.io/ does.
Is there a way to achieve that using this library?
It seems that I just need access to the query
package to get its AST and then execute the query by my own. But the query package is under internal
right now, and more interestingly the AST it returns (types.ExecutableDefinition
) is public. And the query package just has one function Parse
.
I am wondering if we could make this public?
@agnivade I am working on exposing the selected fields in each resolver as well as their child fields. This has been the most requested feature to the library ever. There has been several PRs so far and a few ideas how to implement this. I'll continue the work on this next week when I'm back home. I'd be happy to explain in more details in Slack.
I agree that making the AST public would open some interesting opportunities.
@agnivade you could now use schema.ASTSchema()
After more careful reading, I realized that you are talking about the query and not the schema. This will most probably be added in v1.7.0
.
Thanks @pavelnikolov !