-
Notifications
You must be signed in to change notification settings - Fork 8
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
Query Cost Analysis #27
Comments
It seems like the capability needed to be implemented first is validation rules. I will see what I can do. |
The validation rules is already in the GraphQLSwift/GraphQL package which should allow something like https://github.com/pa-bru/graphql-cost-analysis. However, the capability to provide custom validation rules are not public outside the GraphQLSwift/GraphQL package. I am not sure if that was an intentional decision by the maintainer for GraphQLSwift/GraphQL. I have asked about this and once that feature is made public, I will immediately update this package as well. |
In the mean time, you can technically use the context builder to intercept request by throwing an error before it is executed by the resolver which was updated in v0.6.0. |
I'll be sure to take a look at that and see if it works for my use case. Thanks 😊 |
Sorry, this feature took a while, but validation rules are now in Pioneer since v0.9.0. You should be able to provide custom rules that intercept operation before any resolver is executed. You should also be capable of computing the validation rules for a specific The only thing missing now is an implementation of Query Cost Analysis or Query Complexity. |
For applications which seek the ability to charge for access to their GraphQL API, a cost analysis must be done to charge request based on their impact. As in, requesting a single model will cost less than multiple models with relationships and such.
It would be good if we could provide a way of intercepting requests before they're executed. This would allow us to throw an error (also helpful for auth), record usage, or even add support for a "dryRun" mode which simply returns the query cost without actually executing it.
Examples:
https://github.com/pa-bru/graphql-cost-analysis
https://github.com/slicknode/graphql-query-complexity
The text was updated successfully, but these errors were encountered: