Skip to content
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

Merged
merged 1 commit into from Oct 11, 2021

Conversation

IvanGoncharov
Copy link
Member

cc: @yaacovCR

@IvanGoncharov IvanGoncharov added the PR: bug fix 🐞 requires increase of "patch" version number label Oct 11, 2021
executeSync({ schema, document, operationName: 'Q' }),
).to.throw('Schema is not configured to execute query operation.');
).to.deep.equal({
data: null,
Copy link
Member Author

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?

Copy link
Contributor

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

Copy link
Contributor

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

Copy link
Contributor

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

Copy link
Contributor

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

Copy link
Member

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:

  1. If operation is a query operation:
    • Return ExecuteQuery(operation, schema, coercedVariableValues, initialValue).

From ExecuteQuery():

  1. 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.

Copy link
Contributor

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

Copy link
Member

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.

Copy link
Member

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.

Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: bug fix 🐞 requires increase of "patch" version number
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants