fix(graphql): root level custom query connection fields now nullable #653
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #641.
As explained in our documentation, root level fields in the GraphQL schema should be nullable if it's possible for them to throw an error: https://www.graphile.org/postgraphile/why-nullable/
However, due to an oversight we made custom queries which return connections non-nullable. This is a bug, and it's embarassing it's been present for 3 years and wasn't spotted until a few weeks ago.
Making a field that was previously non-nullable nullable is technically a breaking change in GraphQL. However, these fields were never truly non-nullable, they could throw an error which (due to the non-null of the root field) could invalidate the entire GraphQL result. Hence I'm classifying this as a bugfix and not a breaking change. If you use TypeScript (or similar) you may have to add a few more
?.
operators in your client code to deal with this, other languages may have other ways of dealing with this nullability.Should you wish to opt out of it, you may do so with the
disableIssue641Fix
flag:You could alternatively selectively change the nullability of your fields with
makeChangeNullabilityPlugin
.I'm sorry no-one spotted this sooner!
Fixes #641