-
Notifications
You must be signed in to change notification settings - Fork 2k
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
execute: Correctly report missing root type error #3308
Conversation
ce5fb23
to
0f33b29
Compare
executeSync({ schema, document, operationName: 'Q' }), | ||
).to.throw('Schema is not configured to execute query operation.'); | ||
).to.deep.equal({ | ||
data: null, |
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.
@yaacovCR Probably it should be just errors
without data
, what do you think?
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 spec is unclear, sometimes it says that if execution fails because of missing information, you should just errors, sometimes it says that if execution starts, you should get some data, and it is internally contradictory on whether request execution is considered execution for these purposes, definitionally it calls it execution, but the parts of execution seem validation like, and so in the subsections it says to return only errors and that “execution” is considered to start only with operation execution @benjie has a bit in the glossary about this maybe he has thoughts
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 of that ambiguity in requests, where it is called execution even though later not considered execution, I am inclined to say the same is possibly true in the execution operations section, so we can return just errors
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.
But the spec should be clarified, I think, so kind of doesnt matter what we choose, except if we can anticipate how we would like this to go, in terms of usefulness for clients, I don’t even know what the right answer is, in general, documents should be validated, so this case shouldn’t even come up, so I would say should be similar to any missing field where document not validated where I assume null is returned so data should be null here
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.
Although currently the subscribe code I think just returns errors, that’s the better option there because data for subscribe belongs only in payloads. So maybe consistency with subscribe for execute means data should be skipped for all the operations
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.
From Response/Response Format/Data:
If an error was raised during the execution that prevented a valid response, the
data
entry in the response should be null.
From Executing Requests:
- If operation is a query operation:
- Return ExecuteQuery(operation, schema, coercedVariableValues, initialValue).
From ExecuteQuery():
- Assert: queryType is an Object type.
Assuming that this error is triggered by the assert above, then it's part of the execution process and thus the data
should be null. Interesting that this is a should
not a must, actually. Anyway; since we're the reference implementation we should follow the 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.
Just so I understand that is because the assertion is made in the operation execution algorithm section, and not the request execution section? Or is either section considered execution? Variable coercion section says:
If a request error is encountered during input coercion of variable values, then the operation fails without execution.
That is ambiguous itself seems to mean operation execution, as opposed to request execution.
Anyways, we should align subscription behavior to whatever we do for queries
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 think you’re right; there is ambiguity there. I’ll have a go at adding some 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.
It turns out that this is addressed a couple paragraphs lower down:
https://spec.graphql.org/draft/#sec-Errors.Request-errors
Namely: ExecuteRequest()
can raise "request errors" which are deemed to occur "before execution begins". So "execution" refers to neither "operation execution" nor "request execution" but to the phase of request/operation execution that occurs after the last possible point at which a request error could be raised. Note this could be during the CreateSourceEventStream()
algorithm.
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.
Here's my attempt to clarify this with a non-normative note: graphql/graphql-spec#894
cc: @yaacovCR