I've found that given a query with all parameters optional, at least one parameter is still required to call the query with the same queryName(...) syntax:
type Query {
search(text: String, start: Int, end: Int): String
}
search(text: '') and search work, but search() fails with
Syntax Error: Expected Name, found )
This forces client code to specifically look for all parameters being omitted and remove the (). It would be nice to not have to do this.
Syntax Error: Expected Name, found )
@dandv It's expected since GraphQL specification requires argument list to be non-empty:
https://graphql.github.io/graphql-spec/June2018/#sec-Language.Arguments
This forces client code to specifically look for all parameters being omitted and remove the (). It would be nice to not have to do this.
Client code shouldn't do that instead it should use query variables:
query ($text: String, $start: Int, $end: Int) {
search(text: $text, start: $start, end: $end)
}
Most helpful comment
@dandv It's expected since GraphQL specification requires argument list to be non-empty:
https://graphql.github.io/graphql-spec/June2018/#sec-Language.Arguments
Client code shouldn't do that instead it should use query variables: