Repository navigation
Conversation
This proposal extracts the multiple-error reporting idea from Duckki Oe's original implementation in [graphql#4859](graphql#4859). This is an optional follow-up to [graphql#4868](graphql#4868) and [graphql#4869](graphql#4869). Those changes already prevent lost or delayed successful results and completions for unannounced fragments, in line with graphql#4859. This PR extracts an additional element from graphql#4859, i.e. how many errored tasks to report for a delivery group with multiple shared tasks that have errored prior to the start of a deferred group. Currently, when several shared tasks have failed before a deferred group starts, the group completes with the first replayed error. This proposal includes every failure already cached by its retained, started tasks in that one completion. It exposes more information we already have, without waiting for other work. For example: ```graphql { hero { ... @defer(label: "R1") { first: nonNullName } ... @defer(label: "R2") { second: nonNullName } ... @defer(label: "P") { name ... @defer(label: "C") { first: nonNullName second: nonNullName } } } } ``` `first` and `second` both return `null`, failing R1 and R2 while P's `name` is still pending. R1 and R2 each report their own error. When `name` resolves to `"Luke"`, both versions announce C and complete P successfully. The final response on `17.x.x` is: ```json { "hasNext": false, "pending": [ { "id": "3", "path": [ "hero" ], "label": "C" } ], "incremental": [ { "id": "2", "data": { "name": "Luke" } } ], "completed": [ { "id": "2" }, { "id": "3", "errors": [ { "message": "Cannot return null for non-nullable field Hero.nonNullName.", "locations": [ { "line": 4, "column": 7 }, { "line": 12, "column": 9 } ], "path": [ "hero", "first" ] } ] } ] } ``` With this proposal, the final response is: ```json { "hasNext": false, "pending": [ { "id": "3", "path": [ "hero" ], "label": "C" } ], "incremental": [ { "id": "2", "data": { "name": "Luke" } } ], "completed": [ { "id": "2" }, { "id": "3", "errors": [ { "message": "Cannot return null for non-nullable field Hero.nonNullName.", "locations": [ { "line": 4, "column": 7 }, { "line": 12, "column": 9 } ], "path": [ "hero", "first" ] }, { "message": "Cannot return null for non-nullable field Hero.nonNullName.", "locations": [ { "line": 7, "column": 7 }, { "line": 13, "column": 9 } ], "path": [ "hero", "second" ] } ] } ] } ``` The implementation moves cached-failure inspection from `startTask` to `startGroup`. It adds an additional pass over a group's tasks before starting new work to check for cached failures. This also ensures that a group already known to have failed does not start unnecessary tasks. Unlike the original implementation's retained group errors, this version reads the existing computation results. It adds no persistent group-error storage or WeakSet. Co-authored-by: Duckki Oe <[email protected]>
|
@yaacovCR is attempting to deploy a commit to the The GraphQL Foundation Team on Vercel. A member of the Team first needs to authorize it. |
|
Thanks for separating this from the lifecycle fixes. I support this approach: when several retained, started shared tasks have already rejected, reporting their cached failures together gives the client more information without waiting for unfinished work or introducing persistent group-error storage. I also understand this is preferable over #4861: these are multiple failures explaining why the group cannot deliver; some previously collected errors may be omitted (such as nullable-field errors from discarded data). The corresponding spec question is whether |
|
I've implemented a formal model of this PR in Lean. |
@duckki @robrichard @benjie
This proposal extracts the multiple-error reporting idea from Duckki Oe's original implementation in #4859.
This is an optional follow-up to #4868 and #4869. Those changes already prevent lost or delayed successful results and completions for unannounced fragments, in line with #4859.
This PR extracts an additional element from #4859, i.e. how many errored tasks to report for a delivery group with multiple shared tasks that have errored prior to the start of a deferred group.
Currently, when several shared tasks have failed before a deferred group starts, the group completes with the first replayed error. This proposal includes every failure already cached by its retained, started tasks in that one completion. It exposes more information we already have, without waiting for other work.
For example:
{ hero { ... @defer(label: "R1") { first: nonNullName } ... @defer(label: "R2") { second: nonNullName } ... @defer(label: "P") { name ... @defer(label: "C") { first: nonNullName second: nonNullName } } } }firstandsecondboth returnnull, failing R1 and R2 while P'snameis still pending. R1 and R2 each report their own error. Whennameresolves to"Luke", both versions announce C and complete P successfully.The final response on
17.x.xis:{ "hasNext": false, "pending": [ { "id": "3", "path": [ "hero" ], "label": "C" } ], "incremental": [ { "id": "2", "data": { "name": "Luke" } } ], "completed": [ { "id": "2" }, { "id": "3", "errors": [ { "message": "Cannot return null for non-nullable field Hero.nonNullName.", "locations": [ { "line": 4, "column": 7 }, { "line": 12, "column": 9 } ], "path": [ "hero", "first" ] } ] } ] }With this proposal, the final response is:
{ "hasNext": false, "pending": [ { "id": "3", "path": [ "hero" ], "label": "C" } ], "incremental": [ { "id": "2", "data": { "name": "Luke" } } ], "completed": [ { "id": "2" }, { "id": "3", "errors": [ { "message": "Cannot return null for non-nullable field Hero.nonNullName.", "locations": [ { "line": 4, "column": 7 }, { "line": 12, "column": 9 } ], "path": [ "hero", "first" ] }, { "message": "Cannot return null for non-nullable field Hero.nonNullName.", "locations": [ { "line": 7, "column": 7 }, { "line": 13, "column": 9 } ], "path": [ "hero", "second" ] } ] } ] }The implementation moves cached-failure inspection from
startTasktostartGroup. It adds an additional pass over a group's tasks before starting new work to check for cached failures. This also ensures that a group already known to have failed does not start unnecessary tasks.Unlike the original implementation's retained group errors, this version reads the existing computation results. It adds no persistent group-error storage or WeakSet.