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

Incorrect path attribute on query validation error #4711

Open
utay opened this issue Nov 22, 2023 · 1 comment
Open

Incorrect path attribute on query validation error #4711

utay opened this issue Nov 22, 2023 · 1 comment

Comments

@utay
Copy link

utay commented Nov 22, 2023

Describe the bug

With this query:

query TestQuery($slug: String! = "utay") {
  user(slug: $slug) {
    id
  }
}

This error is returned:

{
  "errors": [
    {
      "message": "Non-null variable $slug can't have a default value",
      "locations": [
        {
          "line": 1,
          "column": 17
        }
      ],
      "path": [
        "query TestQuery"
      ],
      "extensions": {
        "code": "defaultValueInvalidOnNonNullVariable",
        "variableName": "slug"
      }
    }
  ]
}

The issue here is path; it's equal to "query TestQuery" and I think it is not exactly compliant with the graphql spec which expects path to be an array of fields. It is an issue for us because we use a federation router in front of the graphql server and path is invalid for the router in this case.

Versions

graphql version: 2.1
rails version: 7.0.7

Expected behavior

Maybe path shouldn't be set when there's a validation error in the query arguments as some other graphql implementations seem to do that.

(It's a separate topic but some implementations accept default values for non-null variables and it's not clear to me what is the right behavior per the spec.)

@rmosolgo
Copy link
Owner

Hey, sorry I didn't get back to you on this earlier! I agree that the path on this error should match the spec.

Also, looking back at the spec, I can see that this query doesn't violate it. It's allowed within the given grammar and not expressly prohibited elsewhere.

I'll keep this open until I've checked the paths and removed this error from the project.

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

No branches or pull requests

2 participants