@graphql-box/cache-manager 5.4.11 → 5.4.13

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.
Files changed (36) hide show
  1. package/LICENSE +1 -1
  2. package/dist/cjs/index.cjs +1 -1
  3. package/dist/cjs/index.cjs.map +1 -1
  4. package/dist/esm/index.mjs +1 -1
  5. package/dist/esm/index.mjs.map +1 -1
  6. package/dist/production.analysis.txt +49 -49
  7. package/dist/types/cjs/debug/logCacheEntry.d.cts.map +1 -1
  8. package/dist/types/cjs/debug/logCacheQuery.d.cts.map +1 -1
  9. package/dist/types/cjs/debug/logPartialCompiled.d.cts.map +1 -1
  10. package/dist/types/cjs/helpers/isFirstResponseChunk.d.cts.map +1 -1
  11. package/dist/types/cjs/helpers/isLastResponseChunk.d.cts.map +1 -1
  12. package/dist/types/cjs/helpers/isNotLastResponseChunk.d.cts.map +1 -1
  13. package/dist/types/cjs/helpers/isNotResponseChunk.d.cts.map +1 -1
  14. package/dist/types/cjs/main.d.cts.map +1 -1
  15. package/dist/types/esm/debug/logCacheEntry.d.ts.map +1 -1
  16. package/dist/types/esm/debug/logCacheQuery.d.ts.map +1 -1
  17. package/dist/types/esm/debug/logPartialCompiled.d.ts.map +1 -1
  18. package/dist/types/esm/helpers/isFirstResponseChunk.d.ts.map +1 -1
  19. package/dist/types/esm/helpers/isLastResponseChunk.d.ts.map +1 -1
  20. package/dist/types/esm/helpers/isNotLastResponseChunk.d.ts.map +1 -1
  21. package/dist/types/esm/helpers/isNotResponseChunk.d.ts.map +1 -1
  22. package/dist/types/esm/main.d.ts.map +1 -1
  23. package/dist/types/tsconfig.build.tsbuildinfo +1 -1
  24. package/package.json +5 -5
  25. package/src/__snapshots__/index.test.ts.snap +10 -10
  26. package/src/debug/logCacheEntry.ts +9 -12
  27. package/src/debug/logCacheQuery.ts +8 -11
  28. package/src/debug/logPartialCompiled.ts +2 -5
  29. package/src/helpers/filterQuery.ts +4 -4
  30. package/src/helpers/isFirstResponseChunk.ts +1 -1
  31. package/src/helpers/isLastResponseChunk.ts +1 -1
  32. package/src/helpers/isNotLastResponseChunk.ts +1 -1
  33. package/src/helpers/isNotResponseChunk.ts +1 -1
  34. package/src/helpers/normalizePatchResponseData.ts +1 -1
  35. package/src/index.test.ts +45 -20
  36. package/src/main.ts +25 -22
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@graphql-box/cache-manager",
3
3
  "description": "The GraphQL Box cache manager module.",
4
- "version": "5.4.11",
5
- "author": "Dylan Aubrey",
4
+ "version": "5.4.13",
5
+ "author": "miami-man",
6
6
  "license": "MIT",
7
7
  "homepage": "https://github.com/badbatch/graphql-box",
8
8
  "repository": {
@@ -36,8 +36,8 @@
36
36
  "cacheability": "^4.0.27",
37
37
  "core-js": "^3.39.0",
38
38
  "lodash-es": "^4.17.21",
39
- "@graphql-box/helpers": "5.4.10",
40
- "@graphql-box/core": "5.4.10"
39
+ "@graphql-box/helpers": "5.4.12",
40
+ "@graphql-box/core": "5.4.12"
41
41
  },
42
42
  "peerDependencies": {
43
43
  "@cachemap/core": "<6",
@@ -50,7 +50,7 @@
50
50
  "cts-types": "^0.0.8",
51
51
  "del-cli": "^6.0.0",
52
52
  "graphql": "^16.9.0",
53
- "@graphql-box/test-utils": "5.4.10"
53
+ "@graphql-box/test-utils": "5.4.12"
54
54
  },
55
55
  "keywords": [
56
56
  "client",
@@ -50831,8 +50831,8 @@ exports[`@graphql-box/cache-manager >> cacheResponse >> mutation >> nested inter
50831
50831
  "dataEntities::User::MDQ6VXNlcjE3MzQ2OTc4",
50832
50832
  {
50833
50833
  "id": "MDQ6VXNlcjE3MzQ2OTc4",
50834
- "login": "dylanaubrey",
50835
- "name": "Dylan Aubrey",
50834
+ "login": "miami-man",
50835
+ "name": "miami-man",
50836
50836
  },
50837
50837
  ],
50838
50838
  [
@@ -50925,7 +50925,7 @@ exports[`@graphql-box/cache-manager >> cacheResponse >> mutation >> nested inter
50925
50925
  "key": "dataEntities::User::MDQ6VXNlcjE3MzQ2OTc4",
50926
50926
  "lastAccessed": 297475200000,
50927
50927
  "lastUpdated": 297475200000,
50928
- "size": 146,
50928
+ "size": 136,
50929
50929
  "tags": [],
50930
50930
  "updatedCount": 0,
50931
50931
  },
@@ -51124,8 +51124,8 @@ exports[`@graphql-box/cache-manager >> cacheResponse >> mutation >> nested inter
51124
51124
  {
51125
51125
  "node": {
51126
51126
  "id": "MDQ6VXNlcjE3MzQ2OTc4",
51127
- "login": "dylanaubrey",
51128
- "name": "Dylan Aubrey",
51127
+ "login": "miami-man",
51128
+ "name": "miami-man",
51129
51129
  },
51130
51130
  },
51131
51131
  ],
@@ -51161,8 +51161,8 @@ exports[`@graphql-box/cache-manager >> cacheResponse >> mutation >> nested inter
51161
51161
  "dataEntities::User::MDQ6VXNlcjE3MzQ2OTc4",
51162
51162
  {
51163
51163
  "id": "MDQ6VXNlcjE3MzQ2OTc4",
51164
- "login": "dylanaubrey",
51165
- "name": "Dylan Aubrey",
51164
+ "login": "miami-man",
51165
+ "name": "miami-man",
51166
51166
  },
51167
51167
  ],
51168
51168
  [
@@ -51255,7 +51255,7 @@ exports[`@graphql-box/cache-manager >> cacheResponse >> mutation >> nested inter
51255
51255
  "key": "dataEntities::User::MDQ6VXNlcjE3MzQ2OTc4",
51256
51256
  "lastAccessed": 297475200000,
51257
51257
  "lastUpdated": 297475200000,
51258
- "size": 146,
51258
+ "size": 136,
51259
51259
  "tags": [],
51260
51260
  "updatedCount": 0,
51261
51261
  },
@@ -51454,8 +51454,8 @@ exports[`@graphql-box/cache-manager >> cacheResponse >> mutation >> nested inter
51454
51454
  {
51455
51455
  "node": {
51456
51456
  "id": "MDQ6VXNlcjE3MzQ2OTc4",
51457
- "login": "dylanaubrey",
51458
- "name": "Dylan Aubrey",
51457
+ "login": "miami-man",
51458
+ "name": "miami-man",
51459
51459
  },
51460
51460
  },
51461
51461
  ],
@@ -21,7 +21,7 @@ export const logCacheEntry = () => {
21
21
  descriptor.value = async function descriptorValue(...args: Parameters<Descriptor>): ReturnType<Descriptor> {
22
22
  return new Promise<void>(resolve => {
23
23
  const resolver = async () => {
24
- const { debugManager, requestFieldCacheKey, ...otherContext } = args[5];
24
+ const { data, debugManager, requestFieldCacheKey } = args[5];
25
25
 
26
26
  if (!debugManager) {
27
27
  await method.apply(this, args);
@@ -35,18 +35,15 @@ export const logCacheEntry = () => {
35
35
  const duration = endTime - startTime;
36
36
  resolve();
37
37
 
38
- const payload = {
39
- cacheType: args[0],
40
- cachemapOptions: args[3],
41
- context: otherContext,
42
- options: args[4],
43
- requestHash: args[1],
38
+ debugManager.log(CACHE_ENTRY_ADDED, {
39
+ data: {
40
+ ...data,
41
+ cacheHeaders: args[3].cacheHeaders,
42
+ cacheType: args[0],
43
+ ...(requestFieldCacheKey ? { decryptedCacheKey: requestFieldCacheKey } : undefined),
44
+ },
44
45
  stats: { duration, endTime, startTime },
45
- value: args[2],
46
- ...(requestFieldCacheKey ? { decryptedCacheKey: requestFieldCacheKey } : {}),
47
- };
48
-
49
- debugManager.log(CACHE_ENTRY_ADDED, payload);
46
+ });
50
47
  };
51
48
 
52
49
  void resolver();
@@ -23,7 +23,7 @@ export const logCacheQuery = () => {
23
23
  // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
24
24
  return new Promise<never | undefined>(resolve => {
25
25
  const resolver = async () => {
26
- const { debugManager, requestFieldCacheKey, ...otherContext } = args[3];
26
+ const { data, debugManager, requestFieldCacheKey } = args[3];
27
27
 
28
28
  if (!debugManager) {
29
29
  // Proving more difficult to fix, that worth the effort
@@ -40,17 +40,14 @@ export const logCacheQuery = () => {
40
40
  const duration = endTime - startTime;
41
41
  resolve(result);
42
42
 
43
- const payload = {
44
- cacheType: args[0],
45
- context: otherContext,
46
- options: args[2],
47
- requestHash: args[1],
48
- result,
43
+ debugManager.log(CACHE_ENTRY_QUERIED, {
44
+ data: {
45
+ ...data,
46
+ cacheType: args[0],
47
+ ...(requestFieldCacheKey ? { decryptedCacheKey: requestFieldCacheKey } : undefined),
48
+ },
49
49
  stats: { duration, endTime, startTime },
50
- ...(requestFieldCacheKey ? { decryptedCacheKey: requestFieldCacheKey } : {}),
51
- };
52
-
53
- debugManager.log(CACHE_ENTRY_QUERIED, payload);
50
+ });
54
51
  };
55
52
 
56
53
  void resolver();
@@ -17,7 +17,7 @@ export const logPartialCompiled = () => {
17
17
  }
18
18
 
19
19
  descriptor.value = function descriptorValue(...args: Parameters<Descriptor>): ReturnType<Descriptor> {
20
- const { debugManager, ...otherContext } = args[3];
20
+ const { data, debugManager } = args[3];
21
21
 
22
22
  if (!debugManager) {
23
23
  method.apply(this, args);
@@ -30,10 +30,7 @@ export const logPartialCompiled = () => {
30
30
  const duration = endTime - startTime;
31
31
 
32
32
  debugManager.log(PARTIAL_QUERY_COMPILED, {
33
- context: otherContext,
34
- options: args[2],
35
- requestHash: args[0],
36
- result: args[1],
33
+ data,
37
34
  stats: { duration, endTime, startTime },
38
35
  });
39
36
  };
@@ -16,13 +16,13 @@ export const filterQuery = (
16
16
  context: CacheManagerContext,
17
17
  ) => {
18
18
  const { ast } = requestData;
19
- const queryNode = getOperationDefinitions(ast, context.operation)[0];
19
+ const queryNode = getOperationDefinitions(ast, context.data.operation)[0];
20
20
 
21
21
  if (!queryNode) {
22
22
  return ast;
23
23
  }
24
24
 
25
- const { fragmentDefinitions, operation } = context;
25
+ const { data, fragmentDefinitions } = context;
26
26
  const fieldsAndTypeNames = getChildFields(queryNode, { fragmentDefinitions });
27
27
 
28
28
  if (!fieldsAndTypeNames) {
@@ -39,7 +39,7 @@ export const filterQuery = (
39
39
  const { requestFieldPath } = buildFieldKeysAndPaths(
40
40
  fieldNode,
41
41
  {
42
- requestFieldPath: operation,
42
+ requestFieldPath: data.operation,
43
43
  },
44
44
  context,
45
45
  );
@@ -49,6 +49,6 @@ export const filterQuery = (
49
49
  }
50
50
  }
51
51
 
52
- context.queryFiltered = true;
52
+ context.data.queryFiltered = true;
53
53
  return filterFragmentDefinitions(ast, fieldPathChecklist, fragmentSpreadChecklist, context);
54
54
  };
@@ -4,4 +4,4 @@ import { type CacheManagerContext } from '../types.ts';
4
4
  export const isFirstResponseChunk = (
5
5
  rawResponseData: RawResponseDataWithMaybeCacheMetadata,
6
6
  context: CacheManagerContext,
7
- ) => context.hasDeferOrStream && rawResponseData.hasNext && !rawResponseData.paths;
7
+ ) => context.deprecated.hasDeferOrStream && rawResponseData.hasNext && !rawResponseData.paths;
@@ -4,4 +4,4 @@ import { type CacheManagerContext } from '../types.ts';
4
4
  export const isLastResponseChunk = (
5
5
  rawResponseData: RawResponseDataWithMaybeCacheMetadata,
6
6
  context: CacheManagerContext,
7
- ) => context.hasDeferOrStream && !rawResponseData.hasNext && rawResponseData.paths;
7
+ ) => context.deprecated.hasDeferOrStream && !rawResponseData.hasNext && rawResponseData.paths;
@@ -4,4 +4,4 @@ import { type CacheManagerContext } from '../types.ts';
4
4
  export const isNotLastResponseChunk = (
5
5
  rawResponseData: RawResponseDataWithMaybeCacheMetadata,
6
6
  context: CacheManagerContext,
7
- ) => context.hasDeferOrStream && rawResponseData.hasNext;
7
+ ) => context.deprecated.hasDeferOrStream && rawResponseData.hasNext;
@@ -4,4 +4,4 @@ import { type CacheManagerContext } from '../types.ts';
4
4
  export const isNotResponseChunk = (
5
5
  rawResponseData: RawResponseDataWithMaybeCacheMetadata,
6
6
  context: CacheManagerContext,
7
- ) => !context.hasDeferOrStream && !rawResponseData.hasNext && !rawResponseData.paths;
7
+ ) => !context.deprecated.hasDeferOrStream && !rawResponseData.hasNext && !rawResponseData.paths;
@@ -6,7 +6,7 @@ export const normalizePatchResponseData = (
6
6
  rawResponseData: RawResponseDataWithMaybeCacheMetadata,
7
7
  context: CacheManagerContext,
8
8
  ) => {
9
- if (!context.normalizePatchResponseData) {
9
+ if (!context.deprecated.normalizePatchResponseData) {
10
10
  return rawResponseData;
11
11
  }
12
12
 
package/src/index.test.ts CHANGED
@@ -61,8 +61,10 @@ describe('@graphql-box/cache-manager >>', () => {
61
61
  responses.nestedInterfaceMutation,
62
62
  { awaitDataCaching: true },
63
63
  getRequestContext({
64
+ data: {
65
+ operation: OperationTypeNode.MUTATION,
66
+ },
64
67
  fieldTypeMap: requestFieldTypeMaps.nestedInterfaceMutation,
65
- operation: OperationTypeNode.MUTATION,
66
68
  }),
67
69
  );
68
70
  });
@@ -108,8 +110,10 @@ describe('@graphql-box/cache-manager >>', () => {
108
110
  responses.nestedInterfaceMutation,
109
111
  { awaitDataCaching: true },
110
112
  getRequestContext({
113
+ data: {
114
+ operation: OperationTypeNode.MUTATION,
115
+ },
111
116
  fieldTypeMap: requestFieldTypeMaps.nestedInterfaceMutation,
112
- operation: OperationTypeNode.MUTATION,
113
117
  }),
114
118
  );
115
119
  });
@@ -151,8 +155,10 @@ describe('@graphql-box/cache-manager >>', () => {
151
155
  responses.nestedTypeSubscription,
152
156
  { awaitDataCaching: true },
153
157
  getRequestContext({
158
+ data: {
159
+ operation: OperationTypeNode.SUBSCRIPTION,
160
+ },
154
161
  fieldTypeMap: requestFieldTypeMaps.nestedTypeSubscription,
155
- operation: OperationTypeNode.SUBSCRIPTION,
156
162
  }),
157
163
  );
158
164
  });
@@ -195,8 +201,10 @@ describe('@graphql-box/cache-manager >>', () => {
195
201
  responses.nestedTypeSubscription,
196
202
  { awaitDataCaching: true },
197
203
  getRequestContext({
204
+ data: {
205
+ operation: OperationTypeNode.SUBSCRIPTION,
206
+ },
198
207
  fieldTypeMap: requestFieldTypeMaps.nestedTypeSubscription,
199
- operation: OperationTypeNode.SUBSCRIPTION,
200
208
  }),
201
209
  );
202
210
  });
@@ -516,7 +524,7 @@ describe('@graphql-box/cache-manager >>', () => {
516
524
  getRequestData(parsedRequests.singleTypeQuerySet.updated),
517
525
  responses.singleTypeQuerySet.updated as RawResponseDataWithMaybeCacheMetadata,
518
526
  { awaitDataCaching: true },
519
- getRequestContext({ fieldTypeMap: requestFieldTypeMaps.singleTypeQuery, queryFiltered: true }),
527
+ getRequestContext({ data: { queryFiltered: true }, fieldTypeMap: requestFieldTypeMaps.singleTypeQuery }),
520
528
  );
521
529
  });
522
530
 
@@ -577,7 +585,7 @@ describe('@graphql-box/cache-manager >>', () => {
577
585
  getRequestData(parsedRequests.singleTypeQuerySet.updated),
578
586
  responses.singleTypeQuerySet.updated as RawResponseDataWithMaybeCacheMetadata,
579
587
  { awaitDataCaching: true },
580
- getRequestContext({ fieldTypeMap: requestFieldTypeMaps.singleTypeQuery, queryFiltered: true }),
588
+ getRequestContext({ data: { queryFiltered: true }, fieldTypeMap: requestFieldTypeMaps.singleTypeQuery }),
581
589
  );
582
590
  });
583
591
 
@@ -638,7 +646,7 @@ describe('@graphql-box/cache-manager >>', () => {
638
646
  getRequestData(parsedRequests.nestedTypeQuerySet.updated),
639
647
  responses.nestedTypeQuerySet.updated as RawResponseDataWithMaybeCacheMetadata,
640
648
  { awaitDataCaching: true },
641
- getRequestContext({ fieldTypeMap: requestFieldTypeMaps.nestedTypeQuery, queryFiltered: true }),
649
+ getRequestContext({ data: { queryFiltered: true }, fieldTypeMap: requestFieldTypeMaps.nestedTypeQuery }),
642
650
  );
643
651
  });
644
652
 
@@ -702,7 +710,7 @@ describe('@graphql-box/cache-manager >>', () => {
702
710
  getRequestData(parsedRequests.nestedTypeQuerySet.updated),
703
711
  responses.nestedTypeQuerySet.updated as RawResponseDataWithMaybeCacheMetadata,
704
712
  { awaitDataCaching: true },
705
- getRequestContext({ fieldTypeMap: requestFieldTypeMaps.nestedTypeQuery, queryFiltered: true }),
713
+ getRequestContext({ data: { queryFiltered: true }, fieldTypeMap: requestFieldTypeMaps.nestedTypeQuery }),
706
714
  );
707
715
  });
708
716
 
@@ -763,7 +771,7 @@ describe('@graphql-box/cache-manager >>', () => {
763
771
  getRequestData(parsedRequests.nestedUnionQuerySet.updated),
764
772
  responses.nestedUnionQuerySet.updated as RawResponseDataWithMaybeCacheMetadata,
765
773
  { awaitDataCaching: true },
766
- getRequestContext({ fieldTypeMap: requestFieldTypeMaps.nestedUnionQuery, queryFiltered: true }),
774
+ getRequestContext({ data: { queryFiltered: true }, fieldTypeMap: requestFieldTypeMaps.nestedUnionQuery }),
767
775
  );
768
776
  });
769
777
 
@@ -825,7 +833,7 @@ describe('@graphql-box/cache-manager >>', () => {
825
833
  getRequestData(parsedRequests.nestedUnionQuerySet.updated),
826
834
  responses.nestedUnionQuerySet.updated as RawResponseDataWithMaybeCacheMetadata,
827
835
  { awaitDataCaching: true },
828
- getRequestContext({ fieldTypeMap: requestFieldTypeMaps.nestedUnionQuery, queryFiltered: true }),
836
+ getRequestContext({ data: { queryFiltered: true }, fieldTypeMap: requestFieldTypeMaps.nestedUnionQuery }),
829
837
  );
830
838
  });
831
839
 
@@ -869,7 +877,10 @@ describe('@graphql-box/cache-manager >>', () => {
869
877
  requestData,
870
878
  responses.deferQuerySet.initial,
871
879
  { awaitDataCaching: true },
872
- getRequestContext({ fieldTypeMap: requestFieldTypeMaps.deferQuery, hasDeferOrStream: true }),
880
+ getRequestContext({
881
+ deprecated: { hasDeferOrStream: true },
882
+ fieldTypeMap: requestFieldTypeMaps.deferQuery,
883
+ }),
873
884
  );
874
885
 
875
886
  const { cacheMetadata, data } = responses.deferQuerySet.partial;
@@ -893,9 +904,9 @@ describe('@graphql-box/cache-manager >>', () => {
893
904
  updateResponses.shift()!,
894
905
  { awaitDataCaching: true },
895
906
  getRequestContext({
907
+ data: { queryFiltered: true },
908
+ deprecated: { hasDeferOrStream: true },
896
909
  fieldTypeMap: requestFieldTypeMaps.deferQuery,
897
- hasDeferOrStream: true,
898
- queryFiltered: true,
899
910
  }),
900
911
  );
901
912
 
@@ -1055,7 +1066,10 @@ describe('@graphql-box/cache-manager >>', () => {
1055
1066
  analyzeQueryResult = await cacheManager.analyzeQuery(
1056
1067
  getRequestData(parsedRequests.deferQuery),
1057
1068
  { awaitDataCaching: true },
1058
- getRequestContext({ fieldTypeMap: requestFieldTypeMaps.deferQuery, hasDeferOrStream: true }),
1069
+ getRequestContext({
1070
+ deprecated: { hasDeferOrStream: true },
1071
+ fieldTypeMap: requestFieldTypeMaps.deferQuery,
1072
+ }),
1059
1073
  );
1060
1074
  });
1061
1075
 
@@ -1269,8 +1283,10 @@ describe('@graphql-box/cache-manager >>', () => {
1269
1283
  updateResponses.shift()!,
1270
1284
  { awaitDataCaching: true },
1271
1285
  getRequestContext({
1286
+ deprecated: {
1287
+ hasDeferOrStream: true,
1288
+ },
1272
1289
  fieldTypeMap: requestFieldTypeMaps.deferQuery,
1273
- hasDeferOrStream: true,
1274
1290
  }),
1275
1291
  );
1276
1292
 
@@ -1285,7 +1301,10 @@ describe('@graphql-box/cache-manager >>', () => {
1285
1301
  analyzeQueryResult = await cacheManager.analyzeQuery(
1286
1302
  requestData,
1287
1303
  { awaitDataCaching: true },
1288
- getRequestContext({ fieldTypeMap: requestFieldTypeMaps.deferQuery, hasDeferOrStream: true }),
1304
+ getRequestContext({
1305
+ deprecated: { hasDeferOrStream: true },
1306
+ fieldTypeMap: requestFieldTypeMaps.deferQuery,
1307
+ }),
1289
1308
  );
1290
1309
  });
1291
1310
 
@@ -1576,13 +1595,19 @@ describe('@graphql-box/cache-manager >>', () => {
1576
1595
  requestData,
1577
1596
  responses.getSearchResultsQuery,
1578
1597
  { awaitDataCaching: true },
1579
- getRequestContext({ fieldTypeMap: requestFieldTypeMaps.getSearchResultsQuery, hasDeferOrStream: true }),
1598
+ getRequestContext({
1599
+ data: { hasDeferOrStream: true },
1600
+ fieldTypeMap: requestFieldTypeMaps.getSearchResultsQuery,
1601
+ }),
1580
1602
  );
1581
1603
 
1582
1604
  analyzeQueryResult = await cacheManager.analyzeQuery(
1583
1605
  getRequestData(parsedRequests.getMoviePreviewQuery),
1584
1606
  { awaitDataCaching: true },
1585
- getRequestContext({ fieldTypeMap: requestFieldTypeMaps.getMoviePreviewQuery, hasDeferOrStream: true }),
1607
+ getRequestContext({
1608
+ data: { hasDeferOrStream: true },
1609
+ fieldTypeMap: requestFieldTypeMaps.getMoviePreviewQuery,
1610
+ }),
1586
1611
  );
1587
1612
  });
1588
1613
 
@@ -1634,13 +1659,13 @@ describe('@graphql-box/cache-manager >>', () => {
1634
1659
  requestData,
1635
1660
  responses.deferQuerySet.initial,
1636
1661
  { awaitDataCaching: true },
1637
- getRequestContext({ fieldTypeMap: requestFieldTypeMaps.deferQuery, hasDeferOrStream: true }),
1662
+ getRequestContext({ data: { hasDeferOrStream: true }, fieldTypeMap: requestFieldTypeMaps.deferQuery }),
1638
1663
  );
1639
1664
 
1640
1665
  analyzeQueryResult = await cacheManager.analyzeQuery(
1641
1666
  getRequestData(parsedRequests.deferQuery),
1642
1667
  { awaitDataCaching: true },
1643
- getRequestContext({ fieldTypeMap: requestFieldTypeMaps.deferQuery, hasDeferOrStream: true }),
1668
+ getRequestContext({ data: { hasDeferOrStream: true }, fieldTypeMap: requestFieldTypeMaps.deferQuery }),
1644
1669
  );
1645
1670
  });
1646
1671
 
package/src/main.ts CHANGED
@@ -174,9 +174,9 @@ export class CacheManager implements CacheManagerDef {
174
174
  { propNameOrIndex, requestFieldPath }: KeysAndPaths,
175
175
  typeNamesAndKind: TypenamesAndKind,
176
176
  _options: RequestOptions,
177
- { operation }: CacheManagerContext,
177
+ { data: ctxData }: CacheManagerContext,
178
178
  ) {
179
- CacheManager._setCacheMetadata(cacheMetadata, cachedFieldData.cacheability, requestFieldPath, operation);
179
+ CacheManager._setCacheMetadata(cacheMetadata, cachedFieldData.cacheability, requestFieldPath, ctxData.operation);
180
180
  CacheManager._setFieldPathChecklist(fieldPathChecklist, cachedFieldData, requestFieldPath, typeNamesAndKind);
181
181
  CacheManager._setCachedData(data, cachedFieldData, propNameOrIndex);
182
182
  }
@@ -594,7 +594,7 @@ export class CacheManager implements CacheManagerDef {
594
594
  context: CacheManagerContext,
595
595
  ): CacheMetadata {
596
596
  const cacheMetadata = this._createCacheMetadata({ data, ...otherProps }, context);
597
- const queryNode = getOperationDefinitions(ast, context.operation)[0];
597
+ const queryNode = getOperationDefinitions(ast, context.data.operation)[0];
598
598
 
599
599
  if (!queryNode) {
600
600
  return cacheMetadata;
@@ -609,7 +609,7 @@ export class CacheManager implements CacheManagerDef {
609
609
  for (const { fieldNode } of fieldsAndTypeNames)
610
610
  this._setFieldCacheability(
611
611
  fieldNode,
612
- { requestFieldPath: context.operation },
612
+ { requestFieldPath: context.data.operation },
613
613
  { cacheMetadata, data },
614
614
  options,
615
615
  context,
@@ -661,10 +661,13 @@ export class CacheManager implements CacheManagerDef {
661
661
  let queryCacheMetadata: CacheMetadata | undefined;
662
662
  let queryData: PlainData | undefined;
663
663
 
664
- if (context.operation === OperationTypeNode.QUERY && queryResponseCacheTierEnabled(this._cacheTiersEnabled)) {
664
+ if (
665
+ context.data.operation === OperationTypeNode.QUERY &&
666
+ queryResponseCacheTierEnabled(this._cacheTiersEnabled)
667
+ ) {
665
668
  let partialQueryResponse: PartialQueryResponse | undefined;
666
669
 
667
- if (context.queryFiltered && updatedRequestData) {
670
+ if (context.data.queryFiltered && updatedRequestData) {
668
671
  dataCaching.push(
669
672
  this._setQueryResponseCacheEntry(updatedRequestData.hash, { cacheMetadata, data }, options, context),
670
673
  );
@@ -734,7 +737,7 @@ export class CacheManager implements CacheManagerDef {
734
737
 
735
738
  private _createCacheMetadata(
736
739
  { _cacheMetadata, headers }: RawResponseDataWithMaybeCacheMetadata,
737
- { operation }: CacheManagerContext,
740
+ { data }: CacheManagerContext,
738
741
  ): CacheMetadata {
739
742
  const cacheMetadata = new Map<string, Cacheability>();
740
743
 
@@ -744,7 +747,7 @@ export class CacheManager implements CacheManagerDef {
744
747
  headers,
745
748
  });
746
749
 
747
- cacheMetadata.set(operation, cacheability);
750
+ cacheMetadata.set(data.operation, cacheability);
748
751
 
749
752
  if (_cacheMetadata) {
750
753
  rehydrateCacheMetadata(_cacheMetadata, cacheMetadata);
@@ -841,7 +844,7 @@ export class CacheManager implements CacheManagerDef {
841
844
  const hasArgsOrDirectives = fieldTypeInfo.hasArguments || fieldTypeInfo.hasDirectives;
842
845
 
843
846
  if (
844
- context.operation === OperationTypeNode.QUERY &&
847
+ context.data.operation === OperationTypeNode.QUERY &&
845
848
  (isEntity || hasArgsOrDirectives) &&
846
849
  requestPathCacheTierEnabled(this._cacheTiersEnabled)
847
850
  ) {
@@ -1013,7 +1016,7 @@ export class CacheManager implements CacheManagerDef {
1013
1016
  fieldPathChecklist: new Map(),
1014
1017
  };
1015
1018
 
1016
- const queryNode = getOperationDefinitions(ast, context.operation)[0];
1019
+ const queryNode = getOperationDefinitions(ast, context.data.operation)[0];
1017
1020
 
1018
1021
  if (!queryNode) {
1019
1022
  return cachedResponseData;
@@ -1029,7 +1032,7 @@ export class CacheManager implements CacheManagerDef {
1029
1032
  fieldsAndTypeNames.map(({ fieldNode }) =>
1030
1033
  this._analyzeFieldNode(
1031
1034
  fieldNode,
1032
- { requestFieldPath: context.operation },
1035
+ { requestFieldPath: context.data.operation },
1033
1036
  cachedResponseData,
1034
1037
  options,
1035
1038
  context,
@@ -1045,8 +1048,8 @@ export class CacheManager implements CacheManagerDef {
1045
1048
  normalizedResponseData: RawResponseDataWithMaybeCacheMetadata,
1046
1049
  context: CacheManagerContext,
1047
1050
  ) {
1048
- const responseChunks = this._responseChunksAwaitingCaching.get(context.requestID);
1049
- this._responseChunksAwaitingCaching.delete(context.requestID);
1051
+ const responseChunks = this._responseChunksAwaitingCaching.get(context.data.requestID);
1052
+ this._responseChunksAwaitingCaching.delete(context.data.requestID);
1050
1053
  return mergeResponseDataSets([...(responseChunks ?? []), normalizedResponseData]);
1051
1054
  }
1052
1055
 
@@ -1072,7 +1075,7 @@ export class CacheManager implements CacheManagerDef {
1072
1075
  options: RequestOptions,
1073
1076
  context: CacheManagerContext,
1074
1077
  ): Promise<void> {
1075
- const operationNode = getOperationDefinitions(requestData.ast, context.operation)[0];
1078
+ const operationNode = getOperationDefinitions(requestData.ast, context.data.operation)[0];
1076
1079
 
1077
1080
  if (!operationNode) {
1078
1081
  return;
@@ -1088,7 +1091,7 @@ export class CacheManager implements CacheManagerDef {
1088
1091
  fieldsAndTypeNames.map(({ fieldNode }) => {
1089
1092
  return this._parseEntityAndRequestFieldPathCacheEntryData(
1090
1093
  fieldNode,
1091
- { requestFieldPath: context.operation },
1094
+ { requestFieldPath: context.data.operation },
1092
1095
  responseData,
1093
1096
  options,
1094
1097
  context,
@@ -1173,7 +1176,7 @@ export class CacheManager implements CacheManagerDef {
1173
1176
  private _setFieldTypeCacheDirective(
1174
1177
  cacheMetadata: CacheMetadata,
1175
1178
  { ancestorRequestFieldPath, requestFieldPath }: { ancestorRequestFieldPath?: string; requestFieldPath: string },
1176
- { fieldTypeMap, operation }: CacheManagerContext,
1179
+ { data, fieldTypeMap }: CacheManagerContext,
1177
1180
  ): void {
1178
1181
  if (cacheMetadata.has(requestFieldPath)) {
1179
1182
  return;
@@ -1183,13 +1186,13 @@ export class CacheManager implements CacheManagerDef {
1183
1186
 
1184
1187
  if (fieldTypeInfo && this._typeCacheDirectives[fieldTypeInfo.typeName]) {
1185
1188
  const cacheability = new Cacheability({ cacheControl: this._typeCacheDirectives[fieldTypeInfo.typeName] });
1186
- CacheManager._setCacheMetadata(cacheMetadata, cacheability, requestFieldPath, operation);
1189
+ CacheManager._setCacheMetadata(cacheMetadata, cacheability, requestFieldPath, data.operation);
1187
1190
  } else if (this._cascadeCacheControl && ancestorRequestFieldPath) {
1188
1191
  CacheManager._setCacheMetadata(
1189
1192
  cacheMetadata,
1190
1193
  cacheMetadata.get(ancestorRequestFieldPath),
1191
1194
  requestFieldPath,
1192
- operation,
1195
+ data.operation,
1193
1196
  );
1194
1197
  }
1195
1198
  }
@@ -1211,7 +1214,7 @@ export class CacheManager implements CacheManagerDef {
1211
1214
  context: CacheManagerContext,
1212
1215
  ): Promise<void> {
1213
1216
  const dehydratedCacheMetadata = dehydrateCacheMetadata(cacheMetadata);
1214
- const cacheControl = CacheManager._getOperationCacheControl(cacheMetadata, context.operation);
1217
+ const cacheControl = CacheManager._getOperationCacheControl(cacheMetadata, context.data.operation);
1215
1218
 
1216
1219
  await this._setCacheEntry(
1217
1220
  QUERY_RESPONSES,
@@ -1254,12 +1257,12 @@ export class CacheManager implements CacheManagerDef {
1254
1257
  normalizedResponseData: RawResponseDataWithMaybeCacheMetadata,
1255
1258
  context: CacheManagerContext,
1256
1259
  ) {
1257
- const responseChunks = this._responseChunksAwaitingCaching.get(context.requestID);
1260
+ const responseChunks = this._responseChunksAwaitingCaching.get(context.data.requestID);
1258
1261
 
1259
1262
  if (responseChunks) {
1260
- this._responseChunksAwaitingCaching.set(context.requestID, [...responseChunks, normalizedResponseData]);
1263
+ this._responseChunksAwaitingCaching.set(context.data.requestID, [...responseChunks, normalizedResponseData]);
1261
1264
  } else {
1262
- this._responseChunksAwaitingCaching.set(context.requestID, [normalizedResponseData]);
1265
+ this._responseChunksAwaitingCaching.set(context.data.requestID, [normalizedResponseData]);
1263
1266
  }
1264
1267
  }
1265
1268
  }