Skip to content

[useMaskedErrors] replace EnvelopError with GraphQLError #1343

@n1ru4l

Description

@n1ru4l

Is your feature request related to a problem? Please describe.

Right now we use EnvelopError which extends GraphQLError for identifying whether an error should be masked or not.

https://github.com/dotansimha/envelop/blob/7e90676ce7b90a1880d5b06e18b6694819aed1fa/packages/core/src/plugins/use-masked-errors.ts#L17

We choose to use a custom EnvelopError because the GraphQLError constructor API was cumbersome. We changed this within graphql/graphql-js#3454

Instead of

throw new GraphQLError("Oops.", undefined, undefined, undefined, undefined, { code: "SERVER_GOES_BRRT" })

We can now instantiate a GraphQLError with extensions via the new object constructor overload:

throw new GraphQLError("Oops.", {
  extensions: { code: "SERVER_GOES_BRRT" },
})

Describe the solution you'd like

Replace EnvelopError with GraphQLError. This might be a breaking change though we could potentially work around it by just alias exporting GraphQLError as EnvelopError 🤔 .

import { GraphQLError } from "graphql";

export const EnvelopError = GraphQLError

However, since the constructor changes that would still be a breaking change.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions