-
Notifications
You must be signed in to change notification settings - Fork 565
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: replace GraphQLYogaError with GraphQLError (#1473)
* Drop 'GraphQLYogaError' * Fix tests * .. * Fix tests * fixes * feat: rename error utility file Co-authored-by: Laurin Quast <laurinquast@googlemail.com>
- Loading branch information
Showing
14 changed files
with
166 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'graphql-yoga': major | ||
--- | ||
|
||
**BREAKING**: Remove `GraphQLYogaError` in favor of `GraphQLError` | ||
[Check the documentation to see how to use `GraphQLError`](https://www.graphql-yoga.com/docs/guides/error-masking) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { FormatErrorHandler } from '@envelop/core' | ||
import { createGraphQLError } from '@graphql-tools/utils' | ||
import { GraphQLError } from 'graphql' | ||
|
||
export const formatError: FormatErrorHandler = (err, message, isDev) => { | ||
if (err instanceof GraphQLError) { | ||
if (err.originalError) { | ||
if (err.originalError.name === 'GraphQLError') { | ||
return err | ||
} | ||
// Original error should be removed | ||
const extensions = { | ||
...err.extensions, | ||
} | ||
if (isDev) { | ||
extensions.originalError = { | ||
message: err.originalError.message, | ||
stack: err.originalError.stack, | ||
} | ||
} | ||
return createGraphQLError(message, { | ||
nodes: err.nodes, | ||
source: err.source, | ||
positions: err.positions, | ||
path: err.path, | ||
extensions, | ||
}) | ||
} | ||
return err | ||
} | ||
return new GraphQLError(message) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.