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

✨ Expose better errors #321

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

GauBen
Copy link
Contributor

@GauBen GauBen commented Jul 12, 2022

GraphQL v16.5.0 has introduced new types that we can leverage to expose better errors.

Features introduced by this PR:

  • Introduced a new class named ZeusError, replacing the confusing GraphQLError
  • Expose errors as an array of GraphQLErrors
  • ZeusError is fully serializable and parse-able (new ZeusError(JSON.parse(JSON.serialize(zeusError))) works great if you don't care about stack-traces)

Breaking changes: none

I also refreshed the examples.

@aexol
Copy link
Collaborator

aexol commented Jul 13, 2022

Thank you so much! Will review later today

@@ -65,21 +65,35 @@ export type OperationOptions = {

export type ScalarCoder = Record<string, (s: unknown) => string>;

import { GraphQLError, type GraphQLErrorOptions } from 'graphql'; // keep
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we copy those from 'graphql` ? Right now it will need 'graphql' as a dep

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pros:

  • No external dependencies
  • Backports the feature to users of graphql@<=15

Cons:

Alternative: create a lite version of GraphQLError, but it will be incompatible with its graphql-js#GraphQLError counterpart, and we will need to export it as GraphQLError which is a breaking change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants