Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .changeset/floppy-women-poke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
'@graphql-tools/executor': minor
---

Add optional schema coordinate in error extensions. This extension allows to precisely identify the
source of the error by automated tools like tracing or monitoring.

This new feature is opt-in, you have to enable it using `schemaCoordinateInErrors` executor option.

To avoid leaking schema information to the client, the extension key is a `Symbol` (which is not serializable).
To forward it to the client, copy it to a custom extension with a serializable key.

```ts
import { getSchemaCoordinate } from '@graphql-tools/utils'
import { normalizedExecutor } from '@graphql-tools/executor'
import { parse } from 'graphql'
import schema from './schema'

// You can also use `Symbol.for('graphql.error.schemaCoordinate')` to get the symbol if you don't
// want to depend on `@graphql-tools/utils`

const result = await normalizedExecutor({
schema,
document: parse(gql`...`),
schemaCoordinateInErrors: true, // enable adding schema coordinate to graphql errors
});

if (result.errors) {
for (const error of result.errors) {
console.log(
'Error in resolver ',
getSchemaCoordinate(error), ':',
error.message
)
}
}
```
1 change: 1 addition & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
permissions:
contents: read
id-token: write
pull-requests: write
uses: the-guild-org/shared-config/.github/workflows/release-snapshot.yml@v1
if: ${{ github.event.pull_request.title != 'Upcoming Release Changes' }}
with:
Expand Down
47 changes: 2 additions & 45 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading