-
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
Editorial: Error Terminology #966
Conversation
✅ Deploy Preview for graphql-spec-draft ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
8323576
to
f6dbee8
Compare
Uses the definition syntax to set definitions for "field error" and "request error", and uses italic references in every formal normative location as well as the first reference in each prose. This also clarifies when we previously used a plural "field errors" that we actually mean "a list of field error" Include links to other sections as set up in #957 Co-authored-by: Roman Ivantsov <[email protected]>
f6dbee8
to
eee64e9
Compare
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.
Generally great improvement, section 7 needs perhaps a little extra attention. Also, see related: #967
spec/Section 7 -- Response.md
Outdated
should contain those errors. | ||
{null}), the `errors` entry in the response may contain a list of all _field | ||
error_ that were raised during execution. If any _field error_ was raised during | ||
execution, it should contain the `errors` entry. |
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.
Because we've gone from plural to singular, the "it" has become ambiguous (it could be referring to the "field error"); so let's clarify:
execution, it should contain the `errors` entry. | |
execution, the request should contain the `errors` entry. |
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 believe the second sentence (If any field error was raised... it SHOULD (?) contain ...) is a repetition of the first sentence (the errors entry in the response MAY(?) contain a list...) - basically saying 'errors' contains errors raised.
At the same time, there is slight contradiction - MAY vs SHOULD
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 suggest to remove the second sentence and change MAY -> SHOULD in the first.
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 may
is because the errors
field is not required to be present (e.g. it will not be present in the case of no errors). The should
is to indicate that the field should be present if there are errors. But I agree, the existing wording could be improved; something like:
the response may include an
errors
property containing a list of all field error that were raised during execution.
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.
Lots of confusing interchanging of must/should - let me try to reword this section further to clarify
spec/Section 7 -- Response.md
Outdated
:: A _request error_ is an error raised during a _request_ but before execution | ||
begins. This may occur due to a parse grammar or validation error in the | ||
_Document_, an inability to determine which operation to execute, or invalid | ||
input values for variables. |
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.
Note CreateSourceEventStream()
can also raise a request error:
- If groupedFieldSet does not have exactly one entry, raise a request error.
-- https://spec.graphql.org/draft/#CreateSourceEventStream()
There's also various places where there are Assert:
that could raise an error (though if you've done validation they should not occur, except when we don't handle that well).
The phrase "before execution begins" is quite a fuzzy definition it turns out; here's a comment where I try and pick it apart a bit: graphql/graphql-js#3640 (comment)
My current opinion is that "execution begins"
- for queries: when you enter ExecuteQuery()
- for mutations: when you enter ExecuteMutation()
- for subscriptions: when you enter MapSourceToResponseEvent()
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.
Time boundary isn't the best way to describe this. Maybe prose about this being "typical" could be helpful, but really the difference is that field errors go alongside partial results where request errors do not
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.
That's kind of circular reasoning though; for example if an error is raised from the subscribe()
resolver of a field (i.e. in step 10 of CreateSourceEventStream() via the ResolveFieldEventStream() algorithm) then it's not clear from the spec whether that should be a request error (since it prevents setting up the subscription, so the request cannot continue) or a field error (since it originated from a field). And thus, it's not clear if it should resolve to {data: null, errors: [...]}
or just {errors: [...]}
- and thus not clear if it's a partial result or not.
In my opinion, the boundary is effectively that it's a request error if it happens before the first ExecuteSelectionSet()
; the boundaries I defined above give this rule of thumb explicit positions in the algorithm that are passed once only for each request.
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.
In my opinion, the boundary is effectively that it's a request error if it happens before the first ExecuteSelectionSet()
That does seem to be currently true. Feels too in the weeds to be the written definition.
I applied an update, curious if you find it clearer
Thanks for the detailed read! I'll incorporate |
b6b74c2
to
054e024
Compare
054e024
to
9e70c72
Compare
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.
Really good improvements! I have a couple minor suggestions:
Co-authored-by: Benjie Gillam <[email protected]>
Merged your suggestions @benjie |
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.
Really good improvements, thanks @leebyron 🙌
@@ -154,7 +155,8 @@ ExecuteMutation(mutation, schema, variableValues, initialValue): | |||
- Let {selectionSet} be the top level Selection Set in {mutation}. | |||
- Let {data} be the result of running {ExecuteSelectionSet(selectionSet, | |||
mutationType, initialValue, variableValues)} _serially_. | |||
- Let {errors} be any _field errors_ produced while executing the selection set. | |||
- Let {errors} be the list of all _field error_ raised while executing the |
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.
field errors plural?
@@ -302,7 +304,8 @@ ExecuteSubscriptionEvent(subscription, schema, variableValues, initialValue): | |||
- Let {data} be the result of running {ExecuteSelectionSet(selectionSet, | |||
subscriptionType, initialValue, variableValues)} _normally_ (allowing | |||
parallelization). | |||
- Let {errors} be any _field errors_ produced while executing the selection set. | |||
- Let {errors} be the list of all _field error_ raised while executing the |
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.
Plural?
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.
For this to be a glossary referenced term it need to remain in the singular, hence "list of field error" vs "field errors". It's a little grammatically awkward, but hopefully palatable
Uses the definition syntax to set definitions for "field error" and "request error", and uses italic references in every formal normative location as well as the first reference in each prose.
This also clarifies when we previously used a plural "field errors" that we actually mean "a list of field error"
Include links to other sections as set up in #957