-
Notifications
You must be signed in to change notification settings - Fork 125
docs(router): Operation Complexity #7544
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
base: main
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @ardatan, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request primarily focuses on enhancing the documentation for the GraphQL router by introducing detailed guides on query complexity limiting features. It covers how to configure Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
📚 Storybook DeploymentThe latest changes are available as preview in: https://pr-7544.hive-storybook.pages.dev |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request adds documentation for the new query complexity limiting features in the router. The changes are well-structured, adding a new configuration page for limits and a security guide on query complexity. I've found a few typos and minor inconsistencies in the documentation content that should be addressed for clarity.
packages/web/docs/src/content/router/security/query_complexity.mdx
Outdated
Show resolved
Hide resolved
packages/web/docs/src/content/router/security/query_complexity.mdx
Outdated
Show resolved
Hide resolved
packages/web/docs/src/content/router/security/query_complexity.mdx
Outdated
Show resolved
Hide resolved
|
🐋 This PR was built and pushed to the following Docker images: Targets: Platforms: Image Tag: |
|
🐋 This PR was built and pushed to the following Docker images: Targets: Platforms: Image Tag: |
💻 Website PreviewThe latest changes are available as preview in: https://pr-7544.hive-landing-page.pages.dev |
| @@ -0,0 +1,210 @@ | |||
| --- | |||
| title: 'Query Complexity' | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Query Complexity title sounds a bit vague, and also too specific 😄
Should this just be Router Limits or Security Hardening?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was the name of the task actually 🤷♂️. Limits sound too broad. The idea of this section is to prevent malicious requests. Security Hardening is also too broad because the category of this section is also called Security so it sounds a bit weird to duplicate "Security" here, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. In any way, I think Query Complexity is a bit weird here. I'm not sure what's the better name so let's have an internal discussion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure maybe the title should focus on preventing the malicious/unwanted operations. So disabling introspection as in one of your comments can fit in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe Query Cost Analysis? It implies the what (Query) why (cost) how (by analysing it)
Query Cost Analysis Rate Limiting, might be an option. Though it seems there is no real rate limiting solution provided here.
| cors: 'Configuring CORS', | ||
| csrf: 'CSRF Prevention', | ||
| 'jwt-authentication': 'JWT Authentication', | ||
| query_complexity: 'Query Complexity', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as the other comment on the title
| GraphQL by design allows clients to request exactly the data they need. However, this flexibility | ||
| can be exploited to create overly complex queries that can strain server resources, leading to | ||
| performance degradation or denial of service. To mitigate these risks, it's essential to implement | ||
| query complexity limits in your GraphQL router configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
your GraphQL router configuration, especially in production environments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added!
| performance degradation or denial of service. To mitigate these risks, it's essential to implement | ||
| query complexity limits in your GraphQL router configuration. | ||
|
|
||
| This guide explains how to configure the GraphQL router to enforce query complexity limits to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
again here on query complexity, it's too specific and i think we should name it better.
| query complexity limits in your GraphQL router configuration. | ||
|
|
||
| This guide explains how to configure the GraphQL router to enforce query complexity limits to | ||
| prevent abusive queries. For the complete configuration options, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
queries -> GraphQL operations
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
| In that example, any incoming GraphQL query that exceeds 1000 tokens will be rejected with an error. | ||
| ## Prevent deeply nested queries |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
queries -> operations
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
| ## Prevent deeply nested queries | ||
| If you build an API that is available to the 3rd-party users, it is recommended to limit the maximum |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe not 3rd-party here? but mention instead that this is useful in case your GraphQL is open (either for the public, third-party, or in general).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about now?
| } | ||
| ``` | ||
|
|
||
| The above query has a depth of 3 (`user` -> `posts` -> `comments`), so it would be accepted. If a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's duplicated, written above as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed!
|
|
||
| {/* TODO: Rate Limiting here */} | ||
|
|
||
| ## Why both `max_depth` and `max_tokens`? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe "Using max_depth along with max_tokens"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed
| @@ -0,0 +1,210 @@ | |||
| --- | |||
| title: 'Query Complexity' | |||
| --- | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ardatan should we also include a section here and mention disabling introspection? and then link to https://github.com/graphql-hive/console/pull/7483/changes when it lands
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think they have different aspects. This section is mostly about numeric limitations on incoming operations like depth, tokens, rate limits(in the future). So I didn't want to bloat this section with all limitations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it's related to my previous suggestion, where we treat this page as "Security Hardening" and then things like persisted docs, rate-limit and also disabling introspection can fit in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The category of this page is Security already;

So Security Hardening under Security sounds weird. Also my point with this page is not to cover everything about limiting. It is about the story of preventing the malicious requests, starting from depth, tokens, rate limits then persisted operations. Disabling introspection might be fitting but calling all those as Security Hardening doesn't sound like specific enough for these.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah it's a different page with a different context (Secuity in the context of HTTP mostly, right?), while this new page is about hardening and "make it ready for prod" in the context of GraphQL
Documentation of graphql-hive/router#623