That’s fair. While the schema generation is working as intended, there are clearly reasons you (and I am sure others) would prefer a null value to create an error.
I think the default value would be to provide the null value which would cause the GraphQL server to send an error. Filtering would be an additional operation, which might be objectionable to other folks I don’t think we can make the call for everyone to add a filter step. If you want to filter results, you can create a custom resolver to do so.
It’s still worth considering, and we appreciate the feedback! If you feel strongly about it, feel free to start a new Topic here under Feature Requests. It’s always helpful to know a bit more about the use cases you think a FR is best suited for, as well as some examples of how it should work.
Another thing to consider is that the same Page
type is reused for paginated queries that return the same type.
So for this uploaded schema
type Query {
jobsByTitle(title: String): [Thing]!
jobsByLocation(location: String): [Thing]!
jobsBySalary(salary: String): [Thing]!
}
all of those fields transform to return the same Page type
type Query {
jobsByTitle(title: String, _size: Int, _cursor: String): ThingPage!
jobsByLocation(location: String, _size: Int, _cursor: String): ThingPage!
jobsBySalary(salary: String, _size: Int, _cursor: String): ThingPage!
}
To accommodate nullable and nonnullable types, we would probably need different Page types. For example.
[Job]!
=> JobPage
[Job!]!
=> JobPageNonNull
If you think that is a reasonable tradeoff, then highlight that in a feature request.
NOTE: When considering different Page types, I did not address the fact that the list type is always changed to NonNullable. I already explained that the Paginate
function always returns at least an empty array. If were to change anything, IMO, it would be to make it illegal to specify a paginated result type as a Nullable List, e.g. [Job]
. Though I don’t feel strongly that we should do that