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

FR: include GraphQL schema validation (via graphql-core) #177

Open
mjpieters opened this issue Jan 7, 2025 · 3 comments
Open

FR: include GraphQL schema validation (via graphql-core) #177

mjpieters opened this issue Jan 7, 2025 · 3 comments
Labels
wontfix This will not be worked on

Comments

@mjpieters
Copy link
Contributor

mjpieters commented Jan 7, 2025

The graphql-core library can validate GraphQL query strings against a known schema.

If githubkit included the most recent GQL schema, it could pre-validate queries and make sure that the right variables (including their types) are passed in when querying.

The library should also make it possible to apply optimisations to the passed in query (such as AST-based minification, resulting in less network bandwidth and more efficient queries. The AST also tells you if the input query supports pagination (and where in the response to find the cursor information, and what the cursor argument name is).

@yanyongyu
Copy link
Owner

yanyongyu commented Jan 8, 2025

Validating the query may prevent making wrong requests, but, I think this should be done in your development stage. Query validation (including variable validation) should not always happen in the production env (runtime). Queries are literal strings in most cases. Including schema validation will also increase the complexity of the code. GitHub's public schemas are not always correct 🫠.

For AST-based query operations, parsing it and walking through AST (every request) also takes a lot of times (do this in python is really slow).

@mjpieters
Copy link
Contributor Author

Fair enough. I was thinking about this as dev-time support, but you may as well then use a dedicated project (e.g. along ariadne-codegen, but with some more tooling to make it output code that uses githubkit as the client).

@yanyongyu
Copy link
Owner

yanyongyu commented Jan 9, 2025

It seems ariadne-codegen is a powerful graphql code generator. But i'm not quite familiar with it.

As the example in the readme, we can replace the client into githubkit and find a way to turn the query object into string that can be passed to the githubkit graphql method. This can be an additional tool that wraps githubkit's functionality.

@yanyongyu yanyongyu added the wontfix This will not be worked on label Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants