Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ardatan committed Jul 28, 2022
1 parent 5a7fa8c commit 1b1cb03
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/graphql-yoga/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"dependencies": {
"@graphql-tools/code-file-loader": "^7.3.0",
"@graphql-tools/mock": "^8.7.0",
"@envelop/core": "^2.4.0",
"@envelop/core": "^2.4.1",
"@envelop/parser-cache": "^4.4.0",
"@envelop/validation-cache": "^4.4.0",
"@graphql-typed-document-node/core": "^3.1.1",
Expand Down
23 changes: 23 additions & 0 deletions packages/graphql-yoga/src/utils/formatError.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,31 @@
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)
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2863,10 +2863,10 @@
apollo-server-caching "^3.1.0"
apollo-server-types "^3.2.0"

"@envelop/core@^2.4.0":
version "2.4.0"
resolved "https://registry.yarnpkg.com/@envelop/core/-/core-2.4.0.tgz#4319bd681a83fa0964c8be77f7535f728e2e05bb"
integrity sha512-ZA8d3sg69+IrZH0seB/HxHi+IYaOOu5OLzZBAHw7MrT2mBI0RyboM6QZv0gGvYJjQIUeJ1I2Zz4bqjOKNmgpxA==
"@envelop/core@^2.4.1":
version "2.4.1"
resolved "https://registry.yarnpkg.com/@envelop/core/-/core-2.4.1.tgz#d1f6c62867415a9fb93fd598c6263397a730c340"
integrity sha512-27vOytvJSmKo8ny90coegQ9/Js8zaJtQ570vWGEqYbT7losSqJzgyg8tkNAz1WeJoJh3B4Nw4KiuAG1h2jeH3A==
dependencies:
"@envelop/types" "2.3.0"

Expand Down

0 comments on commit 1b1cb03

Please sign in to comment.