Skip to content

Commit b60f628

Browse files
committed
Add operationName in graphQL payload
1 parent 49161ed commit b60f628

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ out
22
node_modules
33
dist
44
*.vsix
5+
.DS_Store
56

67
# Logs
78
npm-debug.log*

‎src/utils/httpRequestParser.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,12 @@ export class HttpRequestParser implements RequestParser {
135135
body = await convertStreamToString(body);
136136
}
137137

138+
const matched = body?.match(/^\s*query\s+([^\{\(]+)/i);
139+
const operationName = matched?.[1];
140+
138141
const graphQlPayload = {
139142
query: body,
143+
operationName,
140144
variables: variables ? JSON.parse(variables) : {}
141145
};
142146
return JSON.stringify(graphQlPayload);

0 commit comments

Comments
 (0)