Description
Abstract
I am researching and planning to build a generic test suite to check the compliance of the various GraphQL libraries The project idea is given by the GraphQL Foundation for the Google Summer of Code 2020
. There are various implementations of GraphQL and all of them are throwing error in various ways.
As all errors are thrown in plain text(string). There is no way to test these implementations for such errors.
Say we have given an incorrect query (with circular fragment) to a GraphQL server and we are expecting an error. If the error comes with a specific error code then it would be great to test the libraries and provides and assuring the actual cause of the error, therefore, improving the DX as well.
For example imagine a well known error place that can hold a "spec rule number" that is indicative of what validation rule you have caused an error message to fail on
errors : [ { message : "any old message", extensions : [ __graphqlspec : { reason : "March2018-5.1.2.4" }}}}
Follow this discussion -> graphql-java/graphql-java#1826 (comment)
Motivation
I am really impressed by the standardisation of the error codes in the following projects.
- React error codes -> https://github.com/facebook/react/blob/master/scripts/error-codes/codes.json
- Rust lang -> https://doc.rust-lang.org/error-index.html
- TypeScript -> https://github.com/microsoft/TypeScript/blob/master/src/compiler/diagnosticMessages.json
What can be done
It would be great if we can come up with such standard error codes in the GraphQL spec.