Closed jhelberg closed 5 months ago
Thank you for taking the time to report this, but I'm not sure this is a bug, even if it is a change in behavior from the past.
The GraphQL documentation gives these examples showing omitting parenthesis for queries when there are no arguments:
type Query {
books: [Book]
authors: [Author]
}
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.
graphql-js 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: https://github.com/vektah/gqlparser/pull/293
thx for taking the time. Seems that () is not allowed indeed. regards.
What happened?
I have the following in my definition file under Queries:
gqlparse bombs out with:
expected at least one definition, found )
What did you expect?
I think it is allowed to have a query without paratemers. I expect gqlparse to accept this line.
Minimal graphql.schema and models to reproduce
versions