@orion-js/graphql 2.8.3 → 2.8.4
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/lib/getOperationName.js +12 -8
- package/package.json +1 -1
package/lib/getOperationName.js
CHANGED
|
@@ -11,14 +11,18 @@ async function getOperationName(params) {
|
|
|
11
11
|
getBodyJSON
|
|
12
12
|
} = params;
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
try {
|
|
15
|
+
if (request.method !== 'GET') {
|
|
16
|
+
const data = await getBodyJSON();
|
|
17
|
+
return data.operationName;
|
|
18
|
+
}
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
if (request.method === 'GET') {
|
|
21
|
+
// handle persisted queries
|
|
22
|
+
const queryParams = new URLSearchParams(request.url.split('?')[1]);
|
|
23
|
+
return queryParams.get('operationName');
|
|
24
|
+
}
|
|
25
|
+
} catch (error) {
|
|
26
|
+
return null;
|
|
23
27
|
}
|
|
24
28
|
}
|