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

[useMaskedErrors] replace EnvelopError with GraphQLError #1343

Closed
n1ru4l opened this issue Mar 24, 2022 · 2 comments
Closed

[useMaskedErrors] replace EnvelopError with GraphQLError #1343

n1ru4l opened this issue Mar 24, 2022 · 2 comments
Assignees
Milestone

Comments

@n1ru4l
Copy link
Owner

n1ru4l commented Mar 24, 2022

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.

@n1ru4l n1ru4l added this to the v3 milestone Aug 16, 2022
@saihaj saihaj self-assigned this Sep 1, 2022
@saihaj
Copy link
Collaborator

saihaj commented Sep 1, 2022

in engine agnostic envelop #1487 we dropped useMaskedError plugin from core since that required relying on GraphQLError class. Do we want to create a new plug-in for this?

@RIP21
Copy link

RIP21 commented Dec 12, 2022

BTW docs are still outdated and say EnvelopError :)

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

No branches or pull requests

3 participants