question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Handling of variable type errors does not conform to spec and appears inconsistent with graphql-js

See original GitHub issue

Currently, if a given variable does not conform to its declared type, a RuntimeException will be thrown when executing a query.

This does not conform to the spec, nor to any other graphql implementations I’ve been able to test against, including graphql-js.

Going through the relevant sections of the spec:

Section 6.1.2 specifies what happens when variable types mismatch: http://facebook.github.io/graphql/October2016/#sec-Coercing-Variable-Values

If a query error is encountered during input coercion of variable values, then the operation fails without execution. … … f. Otherwise, if value cannot be coerced according to the input coercion rules of variableType, throw a query error.

Section 7 describes how the response should look: http://facebook.github.io/graphql/October2016/#sec-Response

When a GraphQL server receives a request, it must return a well‐formed response. The server’s response describes the result of executing the requested operation if successful, and describes any errors encountered during the request.

There is no exception here for operations that fail without execution, and in fact section 7.2.1 explicitly describes how the response should look in this case: http://facebook.github.io/graphql/October2016/#sec-Response-Format

If the operation included execution, the response map must contain a first entry with key data. The value of this entry is described in the “Data” section. If the operation failed before execution, due to a syntax error, missing information, or validation error, this entry must not be present.

I guess this might be the biggest point of contention, as query error is not explicitly listed as one of the types of errors occurring before execution. However, as the spec does not give unambiguous descriptions of the different types of errors and their meanings, I think the most reasonable reading is that this specific type of query error is a validation error.

In any case, I think it would be helpful if the spec was made clearer on the error types.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
bbakermancommented, Oct 19, 2017

We will reconsider this in light of this

0reactions
bbakermancommented, Oct 22, 2017

Now present on master.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error handling - Apollo GraphQL Docs
A client sent the hash of a query string to execute via automatic persisted queries, but the query was not in the APQ...
Read more >
GraphQL: Mapping Error Messages to Generic Error Codes
The logic throwing errors in graphql-js sometimes indicates which section from the spec does the error message belong to, sometimes not.
Read more >
GraphQL union and conflicting types - Stack Overflow
When I tried to query zone data as described in the query part below, I've got an error from GraphQL. zones { ...zoneFieldsWithoutData...
Read more >
GraphQL specification
5.8.1Variable Uniqueness; 5.8.2Variables Are Input Types ... If an input value does not match a coercion rule, a query error must be raised....
Read more >
The Problems of "Schema-First" GraphQL Server Development
Tooling for GraphQL server development has exploded in the last two years. We believe that the need for most tools comes from the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found