feat(root-level-limitation): add max root fields limitation plugin #3233
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Introduction
This pull request introduces the
root-level-limitation
plugin, designed to enhance the performance and stability of our GraphQL server.Motivation
Unrestricted query complexity can negatively impact GraphQL server performance. By allowing clients to request a vast amount of data in a single query, we risk overwhelming the server and potentially leading to timeouts or errors.
Solution
The
root-level-limitation
plugin addresses this concern by enforcing a limit on the number of root fields permitted within a GraphQL query. This approach offers several benefits:Implementation
This plugin integrates seamlessly with our existing Yoga GraphQL Server setup. We can configure the maximum number of allowed root fields through the maxRootFields option. The provided doc inside website demonstrates how to utilize the plugin within our project.