-
Notifications
You must be signed in to change notification settings - Fork 128
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
Disallowing empty parens (introduced in v.2.5.12) is a breaking change #309
Comments
You are entirely correct that this is a behavior change, and I regret the extra work this may have caused you and others. This library has not easily exposed configuration settings to allow people to opt-in to behavioral changes. As a result, I am not able to guarantee preserving the backward compatibility of
The GraphQL documentation gives these examples showing omitting parenthesis for queries when there are no arguments:
And the spec states that if you try to add empty parenthesis like: query GetSomething() { # <-- empty arguments list here
user() { # <-- empty argument list here
name
}
} There should be a validation error in Line 1 and Line 2 each because in GraphQL, Arguments must contain at least one Argument. In GraphQL spec, the notation [list] means one or more -- see spec definition Note that the entire "Arguments" portion is optional in both contexts, therefore query GetSomething { ... } is allowed and so is user { ... }, but if the braces () are present they must contain something. The graphql-js reference implementation reports errors on both cases correctly. This parser used to allow empty parenthesis, but we are trying to maintain spec compliance. The change was made here: I again regret the additional work this forced upon you and others, but I hope you can understand my reasoning and motivation. |
What happened?
In v2.5.12, a change (#293) was made to return a parse error if the user supplied a GraphQL request where the query or root was followed by an empty argument list
()
. Empty argument lists were previously allowed up to v2.5.11.Although the change was made to comply with the GraphQL spec and match implementation of other libraries, it breaks all existing clients who have been supplying empty argument lists. This makes upgrading very difficult for servers with diverse client traffic.
What did you expect?
Queries performed on v2.5.11 will continue to work after upgrading to v2.5.12.
Minimal graphql.schema and models to reproduce
Queries that look like this work with v2.5.11
With v2.5.12, queries with an empty argument list return
versions
github.com/vektah/gqlparser/v2 v2.5.12
go version go1.22.2 darwin/arm64
The text was updated successfully, but these errors were encountered: