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

Depth limit validator key error if fragment undefined #1538

Open
ahmedaljawahiry opened this issue Mar 5, 2024 · 0 comments
Open

Depth limit validator key error if fragment undefined #1538

ahmedaljawahiry opened this issue Mar 5, 2024 · 0 comments
Labels

Comments

@ahmedaljawahiry
Copy link

Current behaviour:
When using the depth_limit_validator (docs), an invalid query can lead to a KeyError being thrown (from here), which usually results in the API returning a 500 server error.

To reproduce:

  • Add the depth_limit_validator to the validation_rules in your GraphQLView.
  • Execute a query with an undefined fragment, i.e. something like:
query {
  validQuery {
    validField
    ...undefinedFragment
  }
}

Expected behaviour:
A standard validation error response, like:

{
  "errors": [
    {
      "message": "Unknown fragment 'undefinedFragment'.",
      "locations": [
        {
          "line": x,
          "column": y
        }
      ]
    }
  ]
}

Since this is something that's caught by the standard validators, depth_limit_validator should probably just skip such errors. Or, do whatever the other validators do when they hit an "unrelated" error.

Environment:

  • Version: 3.3
  • Platform: n/a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant