@orion-js/graphql 2.8.3-alpha-1 → 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.
@@ -11,14 +11,18 @@ async function getOperationName(params) {
11
11
  getBodyJSON
12
12
  } = params;
13
13
 
14
- if (request.method !== 'GET') {
15
- const data = await getBodyJSON();
16
- return data.operationName;
17
- }
14
+ try {
15
+ if (request.method !== 'GET') {
16
+ const data = await getBodyJSON();
17
+ return data.operationName;
18
+ }
18
19
 
19
- if (request.method === 'GET') {
20
- // handle persisted queries
21
- const queryParams = new URLSearchParams(request.url.split('?')[1]);
22
- return queryParams.get('operationName');
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
  }
@@ -25,6 +25,8 @@ var _apolloServerCaching = require("apollo-server-caching");
25
25
 
26
26
  var _getOperationName = _interopRequireDefault(require("./getOperationName"));
27
27
 
28
+ var _storePersistedQuery = _interopRequireDefault(require("./storePersistedQuery"));
29
+
28
30
  global.globalMicro = _micro.default;
29
31
 
30
32
  async function _default(options) {
@@ -68,7 +70,7 @@ async function _default(options) {
68
70
  const result = await options.executeGraphQLCache(params, fallback);
69
71
 
70
72
  if (result) {
71
- await storePersistedQuery(apolloOptions, params);
73
+ await (0, _storePersistedQuery.default)(apolloOptions, params);
72
74
 
73
75
  if (result.cacheControl && cacheKey) {
74
76
  cacheControlCache.set(cacheKey, result.cacheControl);
@@ -4,6 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = storePersistedQuery;
7
+ exports.APQ_CACHE_PREFIX = void 0;
8
+ const APQ_CACHE_PREFIX = 'apq:';
9
+ exports.APQ_CACHE_PREFIX = APQ_CACHE_PREFIX;
7
10
 
8
11
  function createSHA(algorithm) {
9
12
  return require('crypto').createHash(algorithm);
@@ -30,7 +33,7 @@ async function storePersistedQuery(apolloConfig, params) {
30
33
  return;
31
34
  }
32
35
 
33
- const hash = computeQueryHash(data.query);
36
+ const hash = APQ_CACHE_PREFIX + computeQueryHash(data.query);
34
37
  const ttl = apolloConfig.persistedQueries?.ttl !== undefined ? apolloConfig.persistedQueries.ttl : 60 * 15;
35
38
  await queryCache.set(hash, data.query, {
36
39
  ttl
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orion-js/graphql",
3
- "version": "2.8.3-alpha-1",
3
+ "version": "2.8.4",
4
4
  "main": "lib/index.js",
5
5
  "author": "nicolaslopezj",
6
6
  "license": "MIT",