Open IvanGoncharov opened 2 years ago
Note, there is a very similar ECMAScript proposal here https://github.com/tc39/proposal-error-cause
Bikeshed, could merge the two related proposals with a key name like "causes"
Moving to Stage1 per Oct2021 WG discussion.
TL;DR:
This RFC proposes adding the
why
field to GraphQL errors that contain a list of reasons why this error happened.Problem Statement
Sometimes, during execution multiple errors happening at the same time (e.g. parallel execution) or to provide full context on what happens you need to chain errors.
Recent changes in JS, added two features
AggregatedError
andError.cause
to solve both problems but we don't have any mechanism to represent this additional error context in graphql.But I don't think this proposal is JS specific and other languages have also mechanisms for aggregated errors and chains of errors.
TBD: Examples in other languages
🧑💻 Proposed Solution
Add ability to attach an array of sub-errors to graphql error under a property named
why
(the name is up to discussion). With following limitations:why
is an optional non-empty array of objectsmessage
property (required) andextensions
(optional)🎬 Behavior
Error chaining:
Aggregated errors: