-
-
Notifications
You must be signed in to change notification settings - Fork 834
feat(executor): add schema coordinate to graphql errors #7588
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
Open
EmrysMyrddin
wants to merge
30
commits into
master
Choose a base branch
from
feat/executor/error-schema-coordinates
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+393
−107
Open
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
0f65692
chore(release): update monorepo packages versions (#6826)
theguild-bot 33e8b5d
Bump webpack from 5.99.1 to 5.99.2 in the actions-deps group (#7101)
dependabot[bot] bf72aff
chore(deps): update dependency svelte to v5.25.9 (#7108)
renovate[bot] dba7f2a
build(deps): bump next from 15.4.2 to 15.4.3 (#7317)
dependabot[bot] c7d8570
feat(executor): add schema coordinates extension to graphql errors
EmrysMyrddin 0f67a7b
make error coordinate schema extension opt-in and non-serializable
EmrysMyrddin 91a9a5e
fix import
EmrysMyrddin cafb417
remove `null` for nodes
EmrysMyrddin 7922d3f
fix
EmrysMyrddin ce2817a
add changeset
EmrysMyrddin 6bc6c4f
try fix CI snapshot message
EmrysMyrddin e38dabd
export getter
EmrysMyrddin fb45070
fix example
EmrysMyrddin 0fe02b7
update tests
EmrysMyrddin bfe3e42
remove version guards in tests
EmrysMyrddin 37d8ddf
fix tests for Bun
EmrysMyrddin 751f280
use `coordinate` instead of extensions
EmrysMyrddin 7c9f1fc
chore(dependencies): updated changesets for modified dependencies
github-actions[bot] 5663c9b
do not care about graphql 15
EmrysMyrddin 748556a
update changeset
EmrysMyrddin 0fbfc4d
do not use class
EmrysMyrddin b9286d7
add executor tests for error coordinates
EmrysMyrddin cd259c9
chore(dependencies): updated changesets for modified dependencies
github-actions[bot] 1d4c7bf
fix JSON stringify
EmrysMyrddin 50334a2
do not override existing coordinate
EmrysMyrddin 9882723
use define property and guard against existing coordinate
EmrysMyrddin eae3c31
also override toJSON in locatedError
EmrysMyrddin 1629d64
chore(dependencies): updated changesets for modified dependencies
github-actions[bot] d10ee4a
update changeset
EmrysMyrddin 2b67fa6
fix test
EmrysMyrddin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,34 @@ | ||
| --- | ||
| '@graphql-tools/executor': minor | ||
| '@graphql-tools/utils': 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. | ||
|
|
||
| **Caution:** This feature, when enabled, will expose information about your schema. If you need to | ||
| keep you schema private and secret, you should strip this attribute at serialization time before | ||
| sending errors to the client. | ||
|
|
||
| ```ts | ||
| import { parse } from 'graphql' | ||
| import { normalizedExecutor } from '@graphql-tools/executor' | ||
| 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 ', error.coordinate, ':', error.message) | ||
| } | ||
| } | ||
| ``` | ||
This file contains hidden or 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Polish changeset wording and example
A few small doc fixes will make this clearer:
Symbol.for('graphql.error.schemaCoordinate')suggests a symbol-based API, while the current example and implementation exposeerror.coordinatedirectly; clarifying how/if the symbol is actually used would avoid confusion.parse(gql\...`)without importinggql; either add the import or switch to a plain string literal inparse` so the example is self-contained.🧰 Tools
🪛 LanguageTool
[grammar] ~12-~12: Ensure spelling is correct
Context: ... about your schema. If you need to keep you schema private and secret, you should s...
(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)