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

Include meta fields (__typename, __type, __schema) against total field complexity #90

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jvanst
Copy link

@jvanst jvanst commented Oct 6, 2023

What

Update QueryComplexity.ts to count meta fields against total complexity. The current implementation only considers fields included in the schema, which omits: __typename, __type and __schema.

Why

Denial of service attacks are possible by creating many aliases of meta fields:

query LargeQuery {
  __typename
  alias1: __typename
  alias2: __typename
  ...
  alias1000: __typename
}

Considerations

If counting each field as 1 cost, common introspection queries will have a cost around 180. Consumers of the library may need to increase the maximum.

@ivome
Copy link
Collaborator

ivome commented Oct 9, 2023

@jvanst Good catch! Thanks for the PR. Would you mind adding some tests for this?

@Squarix
Copy link

Squarix commented May 23, 2024

@ivome @jvanst
very important changes, any news on this pr?

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

Successfully merging this pull request may close these issues.

None yet

3 participants