Skip to content

Commit fe14dbe

Browse files
committed
use plugin to enable error coordinate
1 parent 9697fda commit fe14dbe

File tree

4 files changed

+29
-21
lines changed

4 files changed

+29
-21
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,12 @@
6363
"vitest": "3.2.4"
6464
},
6565
"resolutions": {
66-
"graphql-yoga": "5.17.0-alpha-20251114095508-2f60bef8687586cf6bd70c56f5c2b127ea53f61f",
66+
"graphql-yoga": "5.17.0-alpha-20251120144328-f407246d4f94919701bf3bdd78b9ae60c7059269",
6767
"@graphql-mesh/types": "0.104.13",
6868
"@graphql-mesh/utils": "0.104.13",
6969
"@graphql-tools/delegate": "workspace:^",
70-
"@graphql-tools/executor": "1.5.0-alpha-20251114103641-9f5dd54441b8068214cc1ae9afe2803485cf9d9d",
71-
"@graphql-tools/utils": "10.11.0-alpha-20251114103641-9f5dd54441b8068214cc1ae9afe2803485cf9d9d",
70+
"@graphql-tools/executor": "1.5.0-alpha-20251120140925-6fcd4c6ff2d2eb40d5890db29418a15cc4cc3956",
71+
"@graphql-tools/utils": "10.11.0-alpha-20251120140925-6fcd4c6ff2d2eb40d5890db29418a15cc4cc3956",
7272
"@opentelemetry/otlp-exporter-base@npm:0.203.0": "patch:@opentelemetry/otlp-exporter-base@npm%3A0.203.0#~/.yarn/patches/@opentelemetry-otlp-exporter-base-npm-0.203.0-183dcac0e6.patch",
7373
"@rollup/plugin-node-resolve@npm:^15.2.3": "patch:@rollup/plugin-node-resolve@npm%3A16.0.1#~/.yarn/patches/@rollup-plugin-node-resolve-npm-16.0.1-2936474bab.patch",
7474
"@vitest/snapshot": "patch:@vitest/snapshot@npm:3.1.2#~/.yarn/patches/@vitest-snapshot-npm-3.1.1-4d18cf86dc.patch",

packages/plugins/opentelemetry/src/plugin.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
import {
22
GatewayConfigContext,
3+
GatewayContext,
34
getRetryInfo,
45
isRetryExecutionRequest,
56
Logger,
67
type GatewayPlugin,
78
} from '@graphql-hive/gateway-runtime';
89
import { getHeadersObj } from '@graphql-mesh/utils';
9-
import { ExecutionArgs } from '@graphql-tools/executor';
1010
import { ExecutionRequest, fakePromise } from '@graphql-tools/utils';
1111
import { unfakePromise } from '@whatwg-node/promise-helpers';
12+
import { Plugin, useErrorCoordinate } from 'graphql-yoga';
1213
import {
1314
context,
1415
hive,
@@ -706,6 +707,11 @@ export function useOpenTelemetry(
706707
},
707708
},
708709

710+
onPluginInit({ addPlugin }) {
711+
// @ts-expect-error Yoga plugin incompatible types with Gateway plugin.
712+
addPlugin(useErrorCoordinate());
713+
},
714+
709715
onYogaInit({ yoga }) {
710716
//TODO remove this when Yoga will also use the new Logger API
711717
pluginLogger ??= new Logger({
@@ -882,8 +888,6 @@ export function useOpenTelemetry(
882888
return;
883889
}
884890

885-
(args as ExecutionArgs).schemaCoordinateInErrors = true;
886-
887891
const ctx = getContext(state);
888892
setGraphQLExecutionAttributes({
889893
ctx,

packages/plugins/opentelemetry/tests/useOpenTelemetry.spec.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
SEMATTRS_HTTP_URL,
2222
SEMATTRS_NET_HOST_NAME,
2323
} from '@graphql-hive/plugin-opentelemetry/setup';
24+
import { assertSingleExecutionValue } from '@internal/testing';
2425
import {
2526
ROOT_CONTEXT,
2627
SpanStatusCode,
@@ -823,7 +824,11 @@ describe('useOpenTelemetry', () => {
823824
}),
824825
),
825826
});
826-
await gateway.query({ shouldReturnErrors: true });
827+
const result = await gateway.query({ shouldReturnErrors: true });
828+
assertSingleExecutionValue(result);
829+
expect(result.errors?.[0]).toBeDefined();
830+
// By default, coordinate should not leak to client
831+
expect(Object.keys(result.errors![0]!)).not.toContain('coordinate');
827832

828833
const operationSpan = spanExporter.assertRoot('graphql.operation');
829834
expect(operationSpan.span.status).toMatchObject({

yarn.lock

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5268,19 +5268,19 @@ __metadata:
52685268
languageName: unknown
52695269
linkType: soft
52705270

5271-
"@graphql-tools/executor@npm:1.5.0-alpha-20251114103641-9f5dd54441b8068214cc1ae9afe2803485cf9d9d":
5272-
version: 1.5.0-alpha-20251114103641-9f5dd54441b8068214cc1ae9afe2803485cf9d9d
5273-
resolution: "@graphql-tools/executor@npm:1.5.0-alpha-20251114103641-9f5dd54441b8068214cc1ae9afe2803485cf9d9d"
5271+
"@graphql-tools/executor@npm:1.5.0-alpha-20251120140925-6fcd4c6ff2d2eb40d5890db29418a15cc4cc3956":
5272+
version: 1.5.0-alpha-20251120140925-6fcd4c6ff2d2eb40d5890db29418a15cc4cc3956
5273+
resolution: "@graphql-tools/executor@npm:1.5.0-alpha-20251120140925-6fcd4c6ff2d2eb40d5890db29418a15cc4cc3956"
52745274
dependencies:
5275-
"@graphql-tools/utils": "npm:10.11.0-alpha-20251114103641-9f5dd54441b8068214cc1ae9afe2803485cf9d9d"
5275+
"@graphql-tools/utils": "npm:10.11.0-alpha-20251120140925-6fcd4c6ff2d2eb40d5890db29418a15cc4cc3956"
52765276
"@graphql-typed-document-node/core": "npm:^3.2.0"
52775277
"@repeaterjs/repeater": "npm:^3.0.4"
52785278
"@whatwg-node/disposablestack": "npm:^0.0.6"
52795279
"@whatwg-node/promise-helpers": "npm:^1.0.0"
52805280
tslib: "npm:^2.4.0"
52815281
peerDependencies:
52825282
graphql: ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0
5283-
checksum: 10c0/17be94aa647860410ad9a09c334c038841cc01313d5e3606a94d97a7c58821272220a5d40d862590997145fa5cb578323e37ff00554c3d349ff7098025d7ca45
5283+
checksum: 10c0/06bbfa85f44c5d93b40d4df022d50154b1501bd08354444a13fa7dae0975b8672d8f0cc0f762de17db3734a5f32d0bb988822d27248eaa0206413ed9a838f74a
52845284
languageName: node
52855285
linkType: hard
52865286

@@ -5561,18 +5561,17 @@ __metadata:
55615561
languageName: unknown
55625562
linkType: soft
55635563

5564-
"@graphql-tools/utils@npm:10.11.0-alpha-20251114103641-9f5dd54441b8068214cc1ae9afe2803485cf9d9d":
5565-
version: 10.11.0-alpha-20251114103641-9f5dd54441b8068214cc1ae9afe2803485cf9d9d
5566-
resolution: "@graphql-tools/utils@npm:10.11.0-alpha-20251114103641-9f5dd54441b8068214cc1ae9afe2803485cf9d9d"
5564+
"@graphql-tools/utils@npm:10.11.0-alpha-20251120140925-6fcd4c6ff2d2eb40d5890db29418a15cc4cc3956":
5565+
version: 10.11.0-alpha-20251120140925-6fcd4c6ff2d2eb40d5890db29418a15cc4cc3956
5566+
resolution: "@graphql-tools/utils@npm:10.11.0-alpha-20251120140925-6fcd4c6ff2d2eb40d5890db29418a15cc4cc3956"
55675567
dependencies:
55685568
"@graphql-typed-document-node/core": "npm:^3.1.1"
55695569
"@whatwg-node/promise-helpers": "npm:^1.0.0"
55705570
cross-inspect: "npm:1.0.1"
5571-
dset: "npm:^3.1.4"
55725571
tslib: "npm:^2.4.0"
55735572
peerDependencies:
55745573
graphql: ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0
5575-
checksum: 10c0/901a8b1b01855d0d5f66424a1d3a9eb52da91cf49a0809a1edb46df87c209a994db673f4c522f4e61af2e31df0e612f69a1a730b78072163f841ea058266b7ff
5574+
checksum: 10c0/6c4296b4dfff16758b15311301db03cd9c9413e1a7620847f21c065f3b0bcf2907052df0bf052a0d68bbea325b6af74a507ee6df904de218434fd9262fea039d
55765575
languageName: node
55775576
linkType: hard
55785577

@@ -15593,9 +15592,9 @@ __metadata:
1559315592
languageName: node
1559415593
linkType: hard
1559515594

15596-
"graphql-yoga@npm:5.17.0-alpha-20251114095508-2f60bef8687586cf6bd70c56f5c2b127ea53f61f":
15597-
version: 5.17.0-alpha-20251114095508-2f60bef8687586cf6bd70c56f5c2b127ea53f61f
15598-
resolution: "graphql-yoga@npm:5.17.0-alpha-20251114095508-2f60bef8687586cf6bd70c56f5c2b127ea53f61f"
15595+
"graphql-yoga@npm:5.17.0-alpha-20251120144328-f407246d4f94919701bf3bdd78b9ae60c7059269":
15596+
version: 5.17.0-alpha-20251120144328-f407246d4f94919701bf3bdd78b9ae60c7059269
15597+
resolution: "graphql-yoga@npm:5.17.0-alpha-20251120144328-f407246d4f94919701bf3bdd78b9ae60c7059269"
1559915598
dependencies:
1560015599
"@envelop/core": "npm:^5.3.0"
1560115600
"@envelop/instrumentation": "npm:^1.0.0"
@@ -15611,7 +15610,7 @@ __metadata:
1561115610
tslib: "npm:^2.8.1"
1561215611
peerDependencies:
1561315612
graphql: ^15.2.0 || ^16.0.0
15614-
checksum: 10c0/6a697f0d882597b3094a0ed41d723ff05943aa3b052ee0d3916cab3eff46dfd0722b2d8e2e10652ed9364dbf166ac51760703273337c845014adce2d27b2d586
15613+
checksum: 10c0/54e082b759781980c32ec6fddabbaa17e22f21b7dafc87aa30771ae30997b73be1efbe6ef2e779fb410786c10d20a3cb1ea0479cef24952d7735dbe14f04e7b6
1561515614
languageName: node
1561615615
linkType: hard
1561715616

0 commit comments

Comments
 (0)