-
-
Notifications
You must be signed in to change notification settings - Fork 831
Description
Is your feature request related to a problem? Please describe.
Right now this package exposes errors through Error
. This is fine but results in build logs like so:
throw new Error(`Couldn't find type ${dependencyName} in any of the schemas.`);
Error: Couldn't find type Post in any of the schemas.
at syntaxError (node_modules/graphql/error/syntaxError.js:15:10)
Contrast this with graphql errors which provide much more actionable details:
Couldn't find type Post in any of the schemas.
/path/to/schema.graphql:2:9
1 | type Dummy {
2 | test: Post
| ^
3 | }
Describe the solution you'd like
By switching to the class GraphQLError
(exported by graphql which this project already depends on) we get better errors by default. The only requirement is that we take two actions:
- Turn on parsing with locations (currently is off)
- Plumb GraphQL AST Nodes to the error constructor (required to get source locations when formatting the error)
Of these, (2) is trivial and simply requires some internal data plumbing. (1) is more interesting as it could have the side effect of increasing memory requirements (albeit marginally) and including graphql source code at runtime. Granted most graphql implementations have reflection so this isn't a huge risk but it requires some consideration.