Non-nullable field errors in defer/stream payloads #23
Replies: 7 comments 9 replies
-
Just as straw man, only sensical alternative I can think of is to disallow stream a nonnullable list or to defer any subfields of a non nullable field, which I don’t think is necessary. Was this discussed in wg? As far as I can tell, this is last outstanding issue! |
Beta Was this translation helpful? Give feedback.
-
What's implemented now seems...fine? Ie, defer/stream conceptually act as nullable boundaries. |
Beta Was this translation helpful? Give feedback.
-
I'm currently leaning towards
|
Beta Was this translation helpful? Give feedback.
-
For posterity from meeting: My recommendation was to make sure Also, adding This address the non-null error in a stream payload here, but warrants a top level discussion since this would be a significant change. {
"data": {
"asyncIterableNonNullError": [
{
"name": "Luke"
}
]
},
"hasNext": true
},
{
"data": null,
"path": ["asyncIterableNonNullError"],
"atIndex": 1
"errors": [
{
"message": "Cannot return null for non-nullable field Query.asyncIterableNonNullError.",
"locations": [
{
"line": 3,
"column": 9
}
],
"path": ["asyncIterableNonNullError", 1]
}
],
"hasNext": false
} |
Beta Was this translation helpful? Give feedback.
-
Discussed at the Feb 2022 WG meeting
|
Beta Was this translation helpful? Give feedback.
-
My 5 cents for @defer & @stream directives after watching GraphQL Working Group - February 3, 2022 Let's keep them KISS. I consider and assume that:
1. If
|
Beta Was this translation helpful? Give feedback.
-
The defer-stream branch on |
Beta Was this translation helpful? Give feedback.
-
Context
If a resolver returns null for a field on an output type that is declared NonNull, there should be an error. Additionally, the GraphQL spec states
This may not be possible when defer and stream are used because the next nullable field may have already been returned to the client.
What's implemented in graphql-js now: The data field on the payload will be returned as null, with the correct non-nullable error. This should be called out in the spec.
Example -
@defer
Response
Example -
@stream
Response
Decision
Discussed at the April 2020 WG meeting in the context of: #32
With the decision to wrap stream data in an array, it is no longer ambiguous to determine if an error would have bubbled above the defer/stream payload boundary.
Beta Was this translation helpful? Give feedback.
All reactions