-
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
Rename field error to execution error; define response position #1152
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for graphql-spec-draft ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
may lose data, raising an execution error is more appropriate. For example, a | ||
floating-point number `1.2` should raise an execution error instead of being |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
may lose data, raising an execution error is more appropriate. For example, a | |
floating-point number `1.2` should raise an execution error instead of being | |
may lose data, raising an _execution error_ is more appropriate. For example, a | |
floating-point number `1.2` should raise an _execution error_ instead of being |
If a field error is raised while resolving a field, it is handled as though the | ||
field returned {null}, and the error must be added to the {"errors"} list in the | ||
response. | ||
If an execution error is raised while resolving a field (either directly or |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we do underscores around execution error
everywhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The general pattern is to do it at least once per headed section, but not to worry about it after that. I generally do it when I feel it adds clarity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this, especially defining response position
which improves clarity and will be helpful for Incremental Delivery
This has bugged me for years, but it turns out to be a blocker around disabling error propagation... so I'm proposing we finally fix it.
The GraphQL spec is wrong when it refers to field errors. Case in point:
This is not true for the schema
type Query { foo: [Foo]! } type Foo { throws: Int! }
with the query{ foo { throws } }
. All fields from the root of the request to the source of the field error return Non-Null types, but the list position inside thefoo
return type is nullable, and thus the error should (and does!) stop at that error boundary, returning{ data: {foo: [null]}, errors: [...]}
and not{ data: null, errors: [...] }
as the spec (incorrectly) states.This seems to be an oversight of the list type throughout the spec; there are a lot of incidences where we refer to errors happening at a "field" when actually we mean they're happening at an errorable position - that is to say, a position that can be identified by the
path
in the response. Factoring in that thispath
will also want to be used by incremental delivery, rather than calling it an "error position" I've called it a "response position". I did moot calling it simply "position", which I really like, but we do have instances of referring to argument positions, which are distinct from response positions, so I opted for the longer but less ambiguous name.To make this clearer I've renamed "field error" to "execution error". Technically all execution errors originate in fields, but not necessarily at the field itself - it could be nested within a list. There are three main sources:
I've introduced
<a name="...">
tags in the spec text to maintain these key hyperlinks even after changing titles of sections.I've also fixed a number of bugs, ambiguities, and omissions in the spec relating to error handling.
These all reflect the behavior of GraphQL.js (and, I believe, all other GraphQL implementations) and thus I've marked this as editorial.
@graphql/implementers Do any of your implementations handle errors in the way that the spec currently states, as opposed to the way that the reference implementation works? If so, speak now and we can turn this into an RFC process rather than editorial!
cc @JoviDeCroock @yaacovCR Please confirm that my spec edits correctly represent the way in which GraphQL.js operates.
Footnotes
in spec terms, though in GraphQL.js it's possible to return e.g.
[1, new Error("two"), 3]
and have the second item be treated as an error thrown in that response position. ↩