@graphql-yoga/plugin-apollo-usage-report 0.9.0-alpha-20250520092918-4e78157511f024b73e7df2eb0797de0242e81e34 → 0.9.0-alpha-20250527093154-d0be5f4626600bfbe255c0ab57590d3963013823
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 +14 -11
- package/esm/index.js +14 -11
- package/package.json +3 -3
package/cjs/index.js
CHANGED
|
@@ -65,18 +65,21 @@ function useApolloUsageReport(options = {}) {
|
|
|
65
65
|
logger.debug('operation tracing context not found, this operation will not be traced.');
|
|
66
66
|
return;
|
|
67
67
|
}
|
|
68
|
-
const operationName = context.params.operationName ??
|
|
69
|
-
(isDocumentNode(result) ? (0, graphql_1.getOperationAST)(result)?.name?.value : undefined);
|
|
70
|
-
const signature = operationName
|
|
71
|
-
? (0, utils_usagereporting_1.usageReportingSignature)(result, operationName)
|
|
72
|
-
: (context.params.query ?? '');
|
|
73
|
-
ctx.referencedFieldsByType = (0, utils_usagereporting_1.calculateReferencedFieldsByType)({
|
|
74
|
-
document: result,
|
|
75
|
-
schema: currentSchema.schema,
|
|
76
|
-
resolvedOperationName: operationName ?? null,
|
|
77
|
-
});
|
|
78
|
-
ctx.operationKey = `# ${operationName || '-'}\n${signature}`;
|
|
79
68
|
ctx.schemaId = currentSchema.id;
|
|
69
|
+
// It is possible that the result is not a document when the parsing fails
|
|
70
|
+
const document = isDocumentNode(result) ? result : null;
|
|
71
|
+
if (document) {
|
|
72
|
+
const opName = (0, graphql_1.getOperationAST)(document, context.params.operationName)?.name?.value;
|
|
73
|
+
ctx.referencedFieldsByType = (0, utils_usagereporting_1.calculateReferencedFieldsByType)({
|
|
74
|
+
document,
|
|
75
|
+
schema: currentSchema.schema,
|
|
76
|
+
resolvedOperationName: opName ?? null,
|
|
77
|
+
});
|
|
78
|
+
ctx.operationKey = `# ${opName || '-'}\n${opName && (0, utils_usagereporting_1.usageReportingSignature)(document, opName)}`;
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
ctx.operationKey = `# ${context.params.operationName || '-'} \n${context.params.query ?? ''}`;
|
|
82
|
+
}
|
|
80
83
|
};
|
|
81
84
|
},
|
|
82
85
|
onResultProcess({ request, result, serverContext }) {
|
package/esm/index.js
CHANGED
|
@@ -61,18 +61,21 @@ export function useApolloUsageReport(options = {}) {
|
|
|
61
61
|
logger.debug('operation tracing context not found, this operation will not be traced.');
|
|
62
62
|
return;
|
|
63
63
|
}
|
|
64
|
-
const operationName = context.params.operationName ??
|
|
65
|
-
(isDocumentNode(result) ? getOperationAST(result)?.name?.value : undefined);
|
|
66
|
-
const signature = operationName
|
|
67
|
-
? usageReportingSignature(result, operationName)
|
|
68
|
-
: (context.params.query ?? '');
|
|
69
|
-
ctx.referencedFieldsByType = calculateReferencedFieldsByType({
|
|
70
|
-
document: result,
|
|
71
|
-
schema: currentSchema.schema,
|
|
72
|
-
resolvedOperationName: operationName ?? null,
|
|
73
|
-
});
|
|
74
|
-
ctx.operationKey = `# ${operationName || '-'}\n${signature}`;
|
|
75
64
|
ctx.schemaId = currentSchema.id;
|
|
65
|
+
// It is possible that the result is not a document when the parsing fails
|
|
66
|
+
const document = isDocumentNode(result) ? result : null;
|
|
67
|
+
if (document) {
|
|
68
|
+
const opName = getOperationAST(document, context.params.operationName)?.name?.value;
|
|
69
|
+
ctx.referencedFieldsByType = calculateReferencedFieldsByType({
|
|
70
|
+
document,
|
|
71
|
+
schema: currentSchema.schema,
|
|
72
|
+
resolvedOperationName: opName ?? null,
|
|
73
|
+
});
|
|
74
|
+
ctx.operationKey = `# ${opName || '-'}\n${opName && usageReportingSignature(document, opName)}`;
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
ctx.operationKey = `# ${context.params.operationName || '-'} \n${context.params.query ?? ''}`;
|
|
78
|
+
}
|
|
76
79
|
};
|
|
77
80
|
},
|
|
78
81
|
onResultProcess({ request, result, serverContext }) {
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-yoga/plugin-apollo-usage-report",
|
|
3
|
-
"version": "0.9.0-alpha-
|
|
3
|
+
"version": "0.9.0-alpha-20250527093154-d0be5f4626600bfbe255c0ab57590d3963013823",
|
|
4
4
|
"description": "Apollo's GraphOS usage report plugin for GraphQL Yoga.",
|
|
5
5
|
"peerDependencies": {
|
|
6
6
|
"graphql": "^15.2.0 || ^16.0.0",
|
|
7
|
-
"graphql-yoga": "^5.13.
|
|
7
|
+
"graphql-yoga": "^5.13.5"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"@apollo/server-gateway-interface": "^1.1.1",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"@graphql-tools/utils": "^10.8.6",
|
|
14
14
|
"@whatwg-node/promise-helpers": "^1.2.4",
|
|
15
15
|
"tslib": "^2.8.1",
|
|
16
|
-
"@graphql-yoga/plugin-apollo-inline-trace": "^3.13.
|
|
16
|
+
"@graphql-yoga/plugin-apollo-inline-trace": "^3.13.5"
|
|
17
17
|
},
|
|
18
18
|
"repository": {
|
|
19
19
|
"type": "git",
|