rmosolgo / rmosolgo/graphql-ruby
Incorrect `path` attribute on query validation error
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 5.4k
- Forks
- 1.4k
- Avg merge
- 23h 19m
- Merged PRs (30d)
- 28
Description
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.)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the supplied query against graphql-ruby 2.1 and compare the returned path with the GraphQL error-result specification and Apollo Router expectations. Trace where the validation error's path is assembled, then add a regression check showing that validation errors do not contain the invalid query-operation path.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, rails, ruby
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100