Skip to content
This repository was archived by the owner on Dec 9, 2024. It is now read-only.

Commit 41eb41e

Browse files
Add operation names and selections to variables
1 parent 6c65f34 commit 41eb41e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

services/graphql-server/src/graphql/operation-logger.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,19 @@ class GraphQLOperationLogger {
105105
const variableHash = hashObject(data.request.variables || {});
106106
const variableKeys = objectDeepKeys(request.variables || {}).sort();
107107

108+
const selectionNames = operation.selectionSet.selections.map((selection) => (selection.name ? selection.name.value : '(none)'));
109+
108110
await Promise.all([
109111
fragments.length ? collection.fragments.bulkWrite(fragments.map((frag) => ({
110112
updateOne: {
111113
filter: { _id: frag.hash },
112114
update: {
113115
$addToSet: {
114116
clients: client,
115-
operations: hash,
116117
environments: data.request.environment,
118+
operations: hash,
119+
operationNames: operationName || '(none)',
120+
selections: { $each: selectionNames },
117121
},
118122
$inc: { n: 1 },
119123
$set: { '_meta.lastSeen': new Date() },
@@ -161,7 +165,9 @@ class GraphQLOperationLogger {
161165
$addToSet: {
162166
clients: client,
163167
operations: hash,
168+
operationNames: operationName || '(none)',
164169
environments: data.request.environment,
170+
selections: { $each: selectionNames },
165171
},
166172
$inc: { n: 1 },
167173
$set: { '_meta.lastSeen': new Date() },

0 commit comments

Comments
 (0)