@graphql-yoga/plugin-apollo-inline-trace 3.9.0 → 3.10.0-alpha-20241108143443-1715ecd4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/index.js +16 -1
- package/esm/index.js +16 -1
- package/package.json +3 -3
package/cjs/index.js
CHANGED
|
@@ -279,7 +279,7 @@ function handleErrors(reqCtx, ctx, errors, rewriteError) {
|
|
|
279
279
|
// put errors on the root node by default
|
|
280
280
|
let node = ctx.rootNode;
|
|
281
281
|
if (Array.isArray(errToReport.path)) {
|
|
282
|
-
const specificNode = ctx.nodes
|
|
282
|
+
const specificNode = getSpecificOrNearestNode(ctx.nodes, errToReport.path);
|
|
283
283
|
if (specificNode) {
|
|
284
284
|
node = specificNode;
|
|
285
285
|
}
|
|
@@ -294,3 +294,18 @@ function handleErrors(reqCtx, ctx, errors, rewriteError) {
|
|
|
294
294
|
}));
|
|
295
295
|
}
|
|
296
296
|
}
|
|
297
|
+
/**
|
|
298
|
+
* If something fails at "non-nullable" GraphQL field in case of federated query, the error path might not be in trace nodes
|
|
299
|
+
* but the error should be assigned to the nearest possible trace node.
|
|
300
|
+
*/
|
|
301
|
+
function getSpecificOrNearestNode(nodes, path) {
|
|
302
|
+
// iterates through "path" backwards
|
|
303
|
+
for (let i = path.length; i > 0; i--) {
|
|
304
|
+
const pathString = path.slice(0, i).join('.');
|
|
305
|
+
const node = nodes.get(pathString);
|
|
306
|
+
if (node) {
|
|
307
|
+
return node;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
return;
|
|
311
|
+
}
|
package/esm/index.js
CHANGED
|
@@ -275,7 +275,7 @@ function handleErrors(reqCtx, ctx, errors, rewriteError) {
|
|
|
275
275
|
// put errors on the root node by default
|
|
276
276
|
let node = ctx.rootNode;
|
|
277
277
|
if (Array.isArray(errToReport.path)) {
|
|
278
|
-
const specificNode = ctx.nodes
|
|
278
|
+
const specificNode = getSpecificOrNearestNode(ctx.nodes, errToReport.path);
|
|
279
279
|
if (specificNode) {
|
|
280
280
|
node = specificNode;
|
|
281
281
|
}
|
|
@@ -290,3 +290,18 @@ function handleErrors(reqCtx, ctx, errors, rewriteError) {
|
|
|
290
290
|
}));
|
|
291
291
|
}
|
|
292
292
|
}
|
|
293
|
+
/**
|
|
294
|
+
* If something fails at "non-nullable" GraphQL field in case of federated query, the error path might not be in trace nodes
|
|
295
|
+
* but the error should be assigned to the nearest possible trace node.
|
|
296
|
+
*/
|
|
297
|
+
function getSpecificOrNearestNode(nodes, path) {
|
|
298
|
+
// iterates through "path" backwards
|
|
299
|
+
for (let i = path.length; i > 0; i--) {
|
|
300
|
+
const pathString = path.slice(0, i).join('.');
|
|
301
|
+
const node = nodes.get(pathString);
|
|
302
|
+
if (node) {
|
|
303
|
+
return node;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
return;
|
|
307
|
+
}
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-yoga/plugin-apollo-inline-trace",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.10.0-alpha-20241108143443-1715ecd4",
|
|
4
4
|
"description": "Apollo's federated tracing plugin for GraphQL Yoga.",
|
|
5
5
|
"peerDependencies": {
|
|
6
6
|
"@graphql-tools/utils": "^10.0.0",
|
|
7
7
|
"@whatwg-node/fetch": "^0.9.22",
|
|
8
8
|
"graphql": "^15.2.0 || ^16.0.0",
|
|
9
|
-
"graphql-yoga": "^5.
|
|
9
|
+
"graphql-yoga": "^5.10.0-alpha-20241108143443-1715ecd4"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@apollo/usage-reporting-protobuf": "^4.1.1",
|
|
13
|
-
"@envelop/on-resolve": "^4.
|
|
13
|
+
"@envelop/on-resolve": "^4.1.1",
|
|
14
14
|
"tslib": "^2.5.2"
|
|
15
15
|
},
|
|
16
16
|
"repository": {
|