Skip to content

Commit 0796992

Browse files
committed
add changeset
1 parent 8c94a52 commit 0796992

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

.changeset/floppy-women-poke.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
'@graphql-tools/executor': minor
3+
---
4+
5+
Add optional schema coordinate in error extensions. This extension allows to precisely identify the
6+
source of the error by automated tools like tracing or monitoring.
7+
8+
This new feature is opt-in, you have to enable it using `schemaCoordinateInErrors` executor option.
9+
10+
To avoid leaking schema information to the client, the extension key is a `Symbol` (which is not serializable).
11+
To forward it to the client, copy it to a custom extension with a serializable key.
12+
13+
```ts
14+
import { ERROR_EXTENSION_SCHEMA_COORDINATE } from '@graphql-tools/utils'
15+
import { normalizedExecutor } from '@graphql-tools/executor'
16+
import { parse } from 'graphql'
17+
import schema from './schema'
18+
19+
// You can also use `Symbol.for('graphql.error.schemaCoordinate')` to get the symbol if you don't
20+
// want to depend on `@graphql-tools/utils`
21+
22+
const result = await normalizedExecutor({
23+
schema,
24+
document: parse(gql`...`),
25+
schemaCoordinateInErrors: true, // enable adding schema coordinate to graphql errors
26+
});
27+
28+
if (result.errors) {
29+
for (error of result.errors) {
30+
console.log(
31+
'Error in resolver ',
32+
error.extensions[ERROR_EXTENSION_SCHEMA_COORDINATE], ':',
33+
error.message
34+
)
35+
}
36+
}
37+
```

0 commit comments

Comments
 (0)