Skip to content
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

Single root resolver to recursively resolve the full query #475

Open
agnivade opened this issue Nov 23, 2021 · 6 comments
Open

Single root resolver to recursively resolve the full query #475

agnivade opened this issue Nov 23, 2021 · 6 comments
Assignees
Milestone

Comments

@agnivade
Copy link
Contributor

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?

@agnivade
Copy link
Contributor Author

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?

@pavelnikolov
Copy link
Member

@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.

@pavelnikolov
Copy link
Member

I agree that making the AST public would open some interesting opportunities.

@pavelnikolov
Copy link
Member

@agnivade you could now use schema.ASTSchema()

@pavelnikolov
Copy link
Member

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.

@pavelnikolov pavelnikolov modified the milestones: v1.6.0, v1.7.0 Feb 17, 2023
@pavelnikolov pavelnikolov self-assigned this Feb 17, 2023
@agnivade
Copy link
Contributor Author

Thanks @pavelnikolov !

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

No branches or pull requests

2 participants