-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[WIP] Non-nullable error boundary - interrobang #1046
Conversation
❌ Deploy Preview for graphql-spec-draft failed.
|
First of all, thanks for kicking off the discussion. I think this proposal gets us what we will need for True Nullabilty, and severs as a great starting place for iteration. Things I like about this proposal:
Things I wish could be better:Mainly the syntax has some drawbacks ( perhaps we should defer syntax bike shedding for another time, but I’ll list a few concerns for now)
An observation: we’ll also need to consider how this new type variant would affect interface validation and potentially selection validation. |
I agree on all your points @captbaritone. From a separate in-person conversation, I think @mjmahone thinks that this new "non-nullable error boundary" type should be the default, but I'm not convinced I agree - I think nullable+null boundary (i.e. the current default) should remain the default. Also, I'm considering changing it into a different "wrapper type" instead. So these spec edits are far from complete. |
Agree that the syntax is a bit weird. Is type User {
friends: [User!?]!?
} But overall, what bugs my brain the most here is that it introduces some kind of dissymmetry between nullable and non-nullable types. Why would error boundaries be limited to non-nullable types? I get the technical reason why (null bubbling is only an issue for non-nullable fields). But from a user point of view, I'd expect errors and nullability to be orthogonal concepts. If we're saying |
Yeah, so what I’m considering is that you’d have e.g. |
To clarify, with this schema: type Query {
book: Book!?
}
type Book {
author: User!?
} querying a/ { "errors": {...}, "data": { "book": { "author": null } } } or b/ { "errors": {...}, "data": { "book": null } } ? |
(A) (there is no bubbling past an interrobang ) |
Closing this in favour of the much more complete asterisk proposal: #1048 |
Inspired by @captbaritone's True Nullability Schema discussion (graphql/graphql-wg#1394) and following @fotoetienne's excellent talk at GraphQLConf, and trying to "use the things we already have in new ways" I am proposing that we introduce a new non-nullable variant, the "Non-Null error boundary" type, represented via interrobang mark
!?
. This will be aNon-Null
type in the current sense, but with an extra property of__Type.isErrorBoundary: true
Critically, this type would "evaporate" for legacy clients, appearing the same as a nullable field. (This is enabled via the
includeErrorBoundaries
argument to the__Field.type
field, which defaults tofalse
.)The main difference in this type is that it will never be
null
unless there is an error in theerrors
array. So it's like a hybrid between the nullability default, and Non-Null. A middle ground.I have not made all the spec edits for this, I'm just feeling out the problem space right now. "Collecting" the field error (rather than throwing it) is going to need some careful wording... but that's a problem for when we come to formalize it.