@graphql-box/cache-manager 4.1.4 → 5.0.0
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/README.md +1 -5
- package/dist/cjs/index.cjs +1477 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/{lib/module/main/index.js → dist/esm/index.mjs} +734 -331
- package/dist/esm/index.mjs.map +1 -0
- package/dist/types/cjs/constants.d.cts +6 -0
- package/dist/types/cjs/constants.d.cts.map +1 -0
- package/dist/types/cjs/debug/index.d.cts +4 -0
- package/dist/types/cjs/debug/index.d.cts.map +1 -0
- package/dist/types/cjs/debug/logCacheEntry.d.cts +8 -0
- package/dist/types/cjs/debug/logCacheEntry.d.cts.map +1 -0
- package/dist/types/cjs/debug/logCacheQuery.d.cts +8 -0
- package/dist/types/cjs/debug/logCacheQuery.d.cts.map +1 -0
- package/dist/types/cjs/debug/logPartialCompiled.d.cts +6 -0
- package/dist/types/cjs/debug/logPartialCompiled.d.cts.map +1 -0
- package/dist/types/cjs/helpers/areOnlyPopulatedFieldsTypeIdKeys.d.cts +3 -0
- package/dist/types/cjs/helpers/areOnlyPopulatedFieldsTypeIdKeys.d.cts.map +1 -0
- package/dist/types/cjs/helpers/checkFieldPathChecklist.d.cts +3 -0
- package/dist/types/cjs/helpers/checkFieldPathChecklist.d.cts.map +1 -0
- package/dist/types/cjs/helpers/combineData.d.cts +2 -0
- package/dist/types/cjs/helpers/combineData.d.cts.map +1 -0
- package/dist/types/cjs/helpers/createFragmentSpreadChecklist.d.cts +9 -0
- package/dist/types/cjs/helpers/createFragmentSpreadChecklist.d.cts.map +1 -0
- package/dist/types/cjs/helpers/deriveOpCacheability.d.cts +9 -0
- package/dist/types/cjs/helpers/deriveOpCacheability.d.cts.map +1 -0
- package/dist/types/cjs/helpers/filterField.d.cts +5 -0
- package/dist/types/cjs/helpers/filterField.d.cts.map +1 -0
- package/dist/types/cjs/helpers/filterFragmentDefinitions.d.cts +5 -0
- package/dist/types/cjs/helpers/filterFragmentDefinitions.d.cts.map +1 -0
- package/dist/types/cjs/helpers/filterFragmentSpreads.d.cts +5 -0
- package/dist/types/cjs/helpers/filterFragmentSpreads.d.cts.map +1 -0
- package/dist/types/cjs/helpers/filterIDsAndTypeNames.d.cts +4 -0
- package/dist/types/cjs/helpers/filterIDsAndTypeNames.d.cts.map +1 -0
- package/dist/types/cjs/helpers/filterInlineFragments.d.cts +4 -0
- package/dist/types/cjs/helpers/filterInlineFragments.d.cts.map +1 -0
- package/dist/types/cjs/helpers/filterOperationAndFragmentDefinitions.d.cts +3 -0
- package/dist/types/cjs/helpers/filterOperationAndFragmentDefinitions.d.cts.map +1 -0
- package/dist/types/cjs/helpers/filterOutPropsWithArgsOrDirectives.d.cts +6 -0
- package/dist/types/cjs/helpers/filterOutPropsWithArgsOrDirectives.d.cts.map +1 -0
- package/dist/types/cjs/helpers/filterQuery.d.cts +4 -0
- package/dist/types/cjs/helpers/filterQuery.d.cts.map +1 -0
- package/dist/types/cjs/helpers/getDataValue.d.cts +2 -0
- package/dist/types/cjs/helpers/getDataValue.d.cts.map +1 -0
- package/dist/types/cjs/helpers/hasTypename.d.cts +3 -0
- package/dist/types/cjs/helpers/hasTypename.d.cts.map +1 -0
- package/dist/types/cjs/helpers/isFirstResponseChunk.d.cts +4 -0
- package/dist/types/cjs/helpers/isFirstResponseChunk.d.cts.map +1 -0
- package/dist/types/cjs/helpers/isLastResponseChunk.d.cts +4 -0
- package/dist/types/cjs/helpers/isLastResponseChunk.d.cts.map +1 -0
- package/dist/types/cjs/helpers/isNotLastResponseChunk.d.cts +4 -0
- package/dist/types/cjs/helpers/isNotLastResponseChunk.d.cts.map +1 -0
- package/dist/types/cjs/helpers/isNotResponseChunk.d.cts +4 -0
- package/dist/types/cjs/helpers/isNotResponseChunk.d.cts.map +1 -0
- package/dist/types/cjs/helpers/mergeObjects.d.cts +2 -0
- package/dist/types/cjs/helpers/mergeObjects.d.cts.map +1 -0
- package/dist/types/cjs/helpers/mergeResponseDataSets.d.cts +3 -0
- package/dist/types/cjs/helpers/mergeResponseDataSets.d.cts.map +1 -0
- package/dist/types/cjs/helpers/normalizePatchResponseData.d.cts +11 -0
- package/dist/types/cjs/helpers/normalizePatchResponseData.d.cts.map +1 -0
- package/dist/types/cjs/helpers/validTypeIdValue.d.cts +3 -0
- package/dist/types/cjs/helpers/validTypeIdValue.d.cts.map +1 -0
- package/dist/types/cjs/index.d.cts +3 -0
- package/dist/types/cjs/index.d.cts.map +1 -0
- package/dist/types/cjs/main.d.cts +63 -0
- package/dist/types/cjs/main.d.cts.map +1 -0
- package/dist/types/cjs/types.d.cts +131 -0
- package/dist/types/cjs/types.d.cts.map +1 -0
- package/dist/types/esm/constants.d.ts +6 -0
- package/dist/types/esm/constants.d.ts.map +1 -0
- package/dist/types/esm/debug/index.d.ts +4 -0
- package/dist/types/esm/debug/index.d.ts.map +1 -0
- package/dist/types/esm/debug/logCacheEntry.d.ts +8 -0
- package/dist/types/esm/debug/logCacheEntry.d.ts.map +1 -0
- package/dist/types/esm/debug/logCacheQuery.d.ts +8 -0
- package/dist/types/esm/debug/logCacheQuery.d.ts.map +1 -0
- package/dist/types/esm/debug/logPartialCompiled.d.ts +6 -0
- package/dist/types/esm/debug/logPartialCompiled.d.ts.map +1 -0
- package/dist/types/esm/helpers/areOnlyPopulatedFieldsTypeIdKeys.d.ts +3 -0
- package/dist/types/esm/helpers/areOnlyPopulatedFieldsTypeIdKeys.d.ts.map +1 -0
- package/dist/types/esm/helpers/checkFieldPathChecklist.d.ts +3 -0
- package/dist/types/esm/helpers/checkFieldPathChecklist.d.ts.map +1 -0
- package/dist/types/esm/helpers/combineData.d.ts +2 -0
- package/dist/types/esm/helpers/combineData.d.ts.map +1 -0
- package/dist/types/esm/helpers/createFragmentSpreadChecklist.d.ts +9 -0
- package/dist/types/esm/helpers/createFragmentSpreadChecklist.d.ts.map +1 -0
- package/dist/types/esm/helpers/deriveOpCacheability.d.ts +9 -0
- package/dist/types/esm/helpers/deriveOpCacheability.d.ts.map +1 -0
- package/dist/types/esm/helpers/filterField.d.ts +5 -0
- package/dist/types/esm/helpers/filterField.d.ts.map +1 -0
- package/dist/types/esm/helpers/filterFragmentDefinitions.d.ts +5 -0
- package/dist/types/esm/helpers/filterFragmentDefinitions.d.ts.map +1 -0
- package/dist/types/esm/helpers/filterFragmentSpreads.d.ts +5 -0
- package/dist/types/esm/helpers/filterFragmentSpreads.d.ts.map +1 -0
- package/dist/types/esm/helpers/filterIDsAndTypeNames.d.ts +4 -0
- package/dist/types/esm/helpers/filterIDsAndTypeNames.d.ts.map +1 -0
- package/dist/types/esm/helpers/filterInlineFragments.d.ts +4 -0
- package/dist/types/esm/helpers/filterInlineFragments.d.ts.map +1 -0
- package/dist/types/esm/helpers/filterOperationAndFragmentDefinitions.d.ts +3 -0
- package/dist/types/esm/helpers/filterOperationAndFragmentDefinitions.d.ts.map +1 -0
- package/dist/types/esm/helpers/filterOutPropsWithArgsOrDirectives.d.ts +6 -0
- package/dist/types/esm/helpers/filterOutPropsWithArgsOrDirectives.d.ts.map +1 -0
- package/dist/types/esm/helpers/filterQuery.d.ts +4 -0
- package/dist/types/esm/helpers/filterQuery.d.ts.map +1 -0
- package/dist/types/esm/helpers/getDataValue.d.ts +2 -0
- package/dist/types/esm/helpers/getDataValue.d.ts.map +1 -0
- package/dist/types/esm/helpers/hasTypename.d.ts +3 -0
- package/dist/types/esm/helpers/hasTypename.d.ts.map +1 -0
- package/dist/types/esm/helpers/isFirstResponseChunk.d.ts +4 -0
- package/dist/types/esm/helpers/isFirstResponseChunk.d.ts.map +1 -0
- package/dist/types/esm/helpers/isLastResponseChunk.d.ts +4 -0
- package/dist/types/esm/helpers/isLastResponseChunk.d.ts.map +1 -0
- package/dist/types/esm/helpers/isNotLastResponseChunk.d.ts +4 -0
- package/dist/types/esm/helpers/isNotLastResponseChunk.d.ts.map +1 -0
- package/dist/types/esm/helpers/isNotResponseChunk.d.ts +4 -0
- package/dist/types/esm/helpers/isNotResponseChunk.d.ts.map +1 -0
- package/dist/types/esm/helpers/mergeObjects.d.ts +2 -0
- package/dist/types/esm/helpers/mergeObjects.d.ts.map +1 -0
- package/dist/types/esm/helpers/mergeResponseDataSets.d.ts +3 -0
- package/dist/types/esm/helpers/mergeResponseDataSets.d.ts.map +1 -0
- package/dist/types/esm/helpers/normalizePatchResponseData.d.ts +11 -0
- package/dist/types/esm/helpers/normalizePatchResponseData.d.ts.map +1 -0
- package/dist/types/esm/helpers/validTypeIdValue.d.ts +3 -0
- package/dist/types/esm/helpers/validTypeIdValue.d.ts.map +1 -0
- package/dist/types/esm/index.d.ts +3 -0
- package/dist/types/esm/index.d.ts.map +1 -0
- package/{lib/types/main/index.d.ts → dist/types/esm/main.d.ts} +6 -7
- package/dist/types/esm/main.d.ts.map +1 -0
- package/{lib/types/defs/index.d.ts → dist/types/esm/types.d.ts} +26 -26
- package/dist/types/esm/types.d.ts.map +1 -0
- package/dist/types/tsconfig.build.tsbuildinfo +1 -0
- package/package.json +54 -39
- package/src/__snapshots__/index.test.ts.snap +16531 -16531
- package/src/constants.ts +6 -0
- package/src/debug/index.ts +3 -3
- package/src/debug/logCacheEntry.ts +54 -0
- package/src/debug/{log-cache-query/index.ts → logCacheQuery.ts} +23 -20
- package/src/debug/logPartialCompiled.ts +41 -0
- package/src/helpers/areOnlyPopulatedFieldsTypeIdKeys.ts +19 -12
- package/src/helpers/checkFieldPathChecklist.ts +9 -7
- package/src/helpers/combineData.ts +14 -0
- package/src/helpers/createFragmentSpreadChecklist.ts +11 -10
- package/src/helpers/deriveOpCacheability.ts +10 -6
- package/src/helpers/filterField.ts +28 -21
- package/src/helpers/filterFragmentDefinitions.ts +35 -21
- package/src/helpers/filterFragmentSpreads.ts +17 -12
- package/src/helpers/filterIDsAndTypeNames.ts +15 -11
- package/src/helpers/filterInlineFragments.ts +13 -11
- package/src/helpers/filterOperationAndFragmentDefinitions.ts +5 -5
- package/src/helpers/filterOutPropsWithArgsOrDirectives.ts +10 -10
- package/src/helpers/filterQuery.ts +21 -12
- package/src/helpers/getDataValue.ts +14 -0
- package/src/helpers/hasTypename.ts +11 -0
- package/src/helpers/isFirstResponseChunk.ts +6 -4
- package/src/helpers/isLastResponseChunk.ts +6 -4
- package/src/helpers/isNotLastResponseChunk.ts +6 -4
- package/src/helpers/isNotResponseChunk.ts +6 -4
- package/src/helpers/mergeObjects.ts +7 -0
- package/src/helpers/mergeResponseDataSets.ts +8 -8
- package/src/helpers/normalizePatchResponseData.ts +12 -5
- package/src/helpers/validTypeIdValue.ts +18 -0
- package/src/index.test.ts +479 -450
- package/src/index.ts +2 -2
- package/src/{main/index.ts → main.ts} +287 -260
- package/src/{defs/index.ts → types.ts} +38 -43
- package/tsconfig.build.json +10 -0
- package/tsconfig.json +17 -0
- package/lib/browser/index.js +0 -2
- package/lib/browser/index.js.map +0 -1
- package/lib/browser/production.analysis.txt +0 -234
- package/lib/main/consts/index.js +0 -17
- package/lib/main/consts/index.js.map +0 -1
- package/lib/main/debug/index.js +0 -32
- package/lib/main/debug/index.js.map +0 -1
- package/lib/main/debug/log-cache-entry/index.js +0 -57
- package/lib/main/debug/log-cache-entry/index.js.map +0 -1
- package/lib/main/debug/log-cache-query/index.js +0 -59
- package/lib/main/debug/log-cache-query/index.js.map +0 -1
- package/lib/main/debug/log-partial-compiled/index.js +0 -50
- package/lib/main/debug/log-partial-compiled/index.js.map +0 -1
- package/lib/main/defs/index.js +0 -2
- package/lib/main/defs/index.js.map +0 -1
- package/lib/main/helpers/areOnlyPopulatedFieldsTypeIdKeys.js +0 -53
- package/lib/main/helpers/areOnlyPopulatedFieldsTypeIdKeys.js.map +0 -1
- package/lib/main/helpers/checkFieldPathChecklist.js +0 -40
- package/lib/main/helpers/checkFieldPathChecklist.js.map +0 -1
- package/lib/main/helpers/createFragmentSpreadChecklist.js +0 -26
- package/lib/main/helpers/createFragmentSpreadChecklist.js.map +0 -1
- package/lib/main/helpers/deriveOpCacheability.js +0 -46
- package/lib/main/helpers/deriveOpCacheability.js.map +0 -1
- package/lib/main/helpers/filterField.js +0 -95
- package/lib/main/helpers/filterField.js.map +0 -1
- package/lib/main/helpers/filterFragmentDefinitions.js +0 -55
- package/lib/main/helpers/filterFragmentDefinitions.js.map +0 -1
- package/lib/main/helpers/filterFragmentSpreads.js +0 -36
- package/lib/main/helpers/filterFragmentSpreads.js.map +0 -1
- package/lib/main/helpers/filterIDsAndTypeNames.js +0 -47
- package/lib/main/helpers/filterIDsAndTypeNames.js.map +0 -1
- package/lib/main/helpers/filterInlineFragments.js +0 -42
- package/lib/main/helpers/filterInlineFragments.js.map +0 -1
- package/lib/main/helpers/filterOperationAndFragmentDefinitions.js +0 -15
- package/lib/main/helpers/filterOperationAndFragmentDefinitions.js.map +0 -1
- package/lib/main/helpers/filterOutPropsWithArgsOrDirectives.js +0 -37
- package/lib/main/helpers/filterOutPropsWithArgsOrDirectives.js.map +0 -1
- package/lib/main/helpers/filterQuery.js +0 -58
- package/lib/main/helpers/filterQuery.js.map +0 -1
- package/lib/main/helpers/isFirstResponseChunk.js +0 -11
- package/lib/main/helpers/isFirstResponseChunk.js.map +0 -1
- package/lib/main/helpers/isLastResponseChunk.js +0 -11
- package/lib/main/helpers/isLastResponseChunk.js.map +0 -1
- package/lib/main/helpers/isNotLastResponseChunk.js +0 -11
- package/lib/main/helpers/isNotLastResponseChunk.js.map +0 -1
- package/lib/main/helpers/isNotResponseChunk.js +0 -11
- package/lib/main/helpers/isNotResponseChunk.js.map +0 -1
- package/lib/main/helpers/mergeResponseDataSets.js +0 -53
- package/lib/main/helpers/mergeResponseDataSets.js.map +0 -1
- package/lib/main/helpers/normalizePatchResponseData.js +0 -29
- package/lib/main/helpers/normalizePatchResponseData.js.map +0 -1
- package/lib/main/helpers/validTypeIDValue.js +0 -20
- package/lib/main/helpers/validTypeIDValue.js.map +0 -1
- package/lib/main/index.js +0 -31
- package/lib/main/index.js.map +0 -1
- package/lib/main/main/index.js +0 -1090
- package/lib/main/main/index.js.map +0 -1
- package/lib/module/consts/index.js +0 -6
- package/lib/module/consts/index.js.map +0 -1
- package/lib/module/debug/index.js +0 -4
- package/lib/module/debug/index.js.map +0 -1
- package/lib/module/debug/log-cache-entry/index.js +0 -48
- package/lib/module/debug/log-cache-entry/index.js.map +0 -1
- package/lib/module/debug/log-cache-query/index.js +0 -50
- package/lib/module/debug/log-cache-query/index.js.map +0 -1
- package/lib/module/debug/log-partial-compiled/index.js +0 -41
- package/lib/module/debug/log-partial-compiled/index.js.map +0 -1
- package/lib/module/defs/index.js +0 -2
- package/lib/module/defs/index.js.map +0 -1
- package/lib/module/helpers/areOnlyPopulatedFieldsTypeIdKeys.js +0 -41
- package/lib/module/helpers/areOnlyPopulatedFieldsTypeIdKeys.js.map +0 -1
- package/lib/module/helpers/checkFieldPathChecklist.js +0 -31
- package/lib/module/helpers/checkFieldPathChecklist.js.map +0 -1
- package/lib/module/helpers/createFragmentSpreadChecklist.js +0 -14
- package/lib/module/helpers/createFragmentSpreadChecklist.js.map +0 -1
- package/lib/module/helpers/deriveOpCacheability.js +0 -32
- package/lib/module/helpers/deriveOpCacheability.js.map +0 -1
- package/lib/module/helpers/filterField.js +0 -80
- package/lib/module/helpers/filterField.js.map +0 -1
- package/lib/module/helpers/filterFragmentDefinitions.js +0 -43
- package/lib/module/helpers/filterFragmentDefinitions.js.map +0 -1
- package/lib/module/helpers/filterFragmentSpreads.js +0 -22
- package/lib/module/helpers/filterFragmentSpreads.js.map +0 -1
- package/lib/module/helpers/filterIDsAndTypeNames.js +0 -36
- package/lib/module/helpers/filterIDsAndTypeNames.js.map +0 -1
- package/lib/module/helpers/filterInlineFragments.js +0 -32
- package/lib/module/helpers/filterInlineFragments.js.map +0 -1
- package/lib/module/helpers/filterOperationAndFragmentDefinitions.js +0 -5
- package/lib/module/helpers/filterOperationAndFragmentDefinitions.js.map +0 -1
- package/lib/module/helpers/filterOutPropsWithArgsOrDirectives.js +0 -24
- package/lib/module/helpers/filterOutPropsWithArgsOrDirectives.js.map +0 -1
- package/lib/module/helpers/filterQuery.js +0 -43
- package/lib/module/helpers/filterQuery.js.map +0 -1
- package/lib/module/helpers/isFirstResponseChunk.js +0 -2
- package/lib/module/helpers/isFirstResponseChunk.js.map +0 -1
- package/lib/module/helpers/isLastResponseChunk.js +0 -2
- package/lib/module/helpers/isLastResponseChunk.js.map +0 -1
- package/lib/module/helpers/isNotLastResponseChunk.js +0 -2
- package/lib/module/helpers/isNotLastResponseChunk.js.map +0 -1
- package/lib/module/helpers/isNotResponseChunk.js +0 -2
- package/lib/module/helpers/isNotResponseChunk.js.map +0 -1
- package/lib/module/helpers/mergeResponseDataSets.js +0 -41
- package/lib/module/helpers/mergeResponseDataSets.js.map +0 -1
- package/lib/module/helpers/normalizePatchResponseData.js +0 -17
- package/lib/module/helpers/normalizePatchResponseData.js.map +0 -1
- package/lib/module/helpers/validTypeIDValue.js +0 -8
- package/lib/module/helpers/validTypeIDValue.js.map +0 -1
- package/lib/module/index.js +0 -3
- package/lib/module/index.js.map +0 -1
- package/lib/module/main/index.js.map +0 -1
- package/lib/types/consts/index.d.ts +0 -6
- package/lib/types/consts/index.d.ts.map +0 -1
- package/lib/types/debug/index.d.ts +0 -4
- package/lib/types/debug/index.d.ts.map +0 -1
- package/lib/types/debug/log-cache-entry/index.d.ts +0 -2
- package/lib/types/debug/log-cache-entry/index.d.ts.map +0 -1
- package/lib/types/debug/log-cache-query/index.d.ts +0 -2
- package/lib/types/debug/log-cache-query/index.d.ts.map +0 -1
- package/lib/types/debug/log-partial-compiled/index.d.ts +0 -2
- package/lib/types/debug/log-partial-compiled/index.d.ts.map +0 -1
- package/lib/types/defs/index.d.ts.map +0 -1
- package/lib/types/helpers/areOnlyPopulatedFieldsTypeIdKeys.d.ts +0 -4
- package/lib/types/helpers/areOnlyPopulatedFieldsTypeIdKeys.d.ts.map +0 -1
- package/lib/types/helpers/checkFieldPathChecklist.d.ts +0 -4
- package/lib/types/helpers/checkFieldPathChecklist.d.ts.map +0 -1
- package/lib/types/helpers/createFragmentSpreadChecklist.d.ts +0 -12
- package/lib/types/helpers/createFragmentSpreadChecklist.d.ts.map +0 -1
- package/lib/types/helpers/deriveOpCacheability.d.ts +0 -10
- package/lib/types/helpers/deriveOpCacheability.d.ts.map +0 -1
- package/lib/types/helpers/filterField.d.ts +0 -6
- package/lib/types/helpers/filterField.d.ts.map +0 -1
- package/lib/types/helpers/filterFragmentDefinitions.d.ts +0 -6
- package/lib/types/helpers/filterFragmentDefinitions.d.ts.map +0 -1
- package/lib/types/helpers/filterFragmentSpreads.d.ts +0 -6
- package/lib/types/helpers/filterFragmentSpreads.d.ts.map +0 -1
- package/lib/types/helpers/filterIDsAndTypeNames.d.ts +0 -5
- package/lib/types/helpers/filterIDsAndTypeNames.d.ts.map +0 -1
- package/lib/types/helpers/filterInlineFragments.d.ts +0 -5
- package/lib/types/helpers/filterInlineFragments.d.ts.map +0 -1
- package/lib/types/helpers/filterOperationAndFragmentDefinitions.d.ts +0 -4
- package/lib/types/helpers/filterOperationAndFragmentDefinitions.d.ts.map +0 -1
- package/lib/types/helpers/filterOutPropsWithArgsOrDirectives.d.ts +0 -7
- package/lib/types/helpers/filterOutPropsWithArgsOrDirectives.d.ts.map +0 -1
- package/lib/types/helpers/filterQuery.d.ts +0 -5
- package/lib/types/helpers/filterQuery.d.ts.map +0 -1
- package/lib/types/helpers/isFirstResponseChunk.d.ts +0 -5
- package/lib/types/helpers/isFirstResponseChunk.d.ts.map +0 -1
- package/lib/types/helpers/isLastResponseChunk.d.ts +0 -5
- package/lib/types/helpers/isLastResponseChunk.d.ts.map +0 -1
- package/lib/types/helpers/isNotLastResponseChunk.d.ts +0 -5
- package/lib/types/helpers/isNotLastResponseChunk.d.ts.map +0 -1
- package/lib/types/helpers/isNotResponseChunk.d.ts +0 -5
- package/lib/types/helpers/isNotResponseChunk.d.ts.map +0 -1
- package/lib/types/helpers/mergeResponseDataSets.d.ts +0 -4
- package/lib/types/helpers/mergeResponseDataSets.d.ts.map +0 -1
- package/lib/types/helpers/normalizePatchResponseData.d.ts +0 -5
- package/lib/types/helpers/normalizePatchResponseData.d.ts.map +0 -1
- package/lib/types/helpers/validTypeIDValue.d.ts +0 -3
- package/lib/types/helpers/validTypeIDValue.d.ts.map +0 -1
- package/lib/types/index.d.ts +0 -3
- package/lib/types/index.d.ts.map +0 -1
- package/lib/types/index.test.d.ts +0 -2
- package/lib/types/index.test.d.ts.map +0 -1
- package/lib/types/main/index.d.ts.map +0 -1
- package/src/consts/index.ts +0 -6
- package/src/debug/log-cache-entry/index.ts +0 -45
- package/src/debug/log-partial-compiled/index.ts +0 -38
- package/src/helpers/validTypeIDValue.ts +0 -11
package/lib/main/main/index.js
DELETED
|
@@ -1,1090 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.default = void 0;
|
|
9
|
-
|
|
10
|
-
require("core-js/modules/es.promise.js");
|
|
11
|
-
|
|
12
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
|
-
|
|
14
|
-
var _applyDecoratedDescriptor2 = _interopRequireDefault(require("@babel/runtime/helpers/applyDecoratedDescriptor"));
|
|
15
|
-
|
|
16
|
-
var _unset2 = _interopRequireDefault(require("lodash/unset"));
|
|
17
|
-
|
|
18
|
-
var _set2 = _interopRequireDefault(require("lodash/set"));
|
|
19
|
-
|
|
20
|
-
var _isUndefined2 = _interopRequireDefault(require("lodash/isUndefined"));
|
|
21
|
-
|
|
22
|
-
var _isPlainObject2 = _interopRequireDefault(require("lodash/isPlainObject"));
|
|
23
|
-
|
|
24
|
-
var _isObjectLike2 = _interopRequireDefault(require("lodash/isObjectLike"));
|
|
25
|
-
|
|
26
|
-
var _isArray2 = _interopRequireDefault(require("lodash/isArray"));
|
|
27
|
-
|
|
28
|
-
var _get2 = _interopRequireDefault(require("lodash/get"));
|
|
29
|
-
|
|
30
|
-
var _cloneDeep2 = _interopRequireDefault(require("lodash/cloneDeep"));
|
|
31
|
-
|
|
32
|
-
var _assign2 = _interopRequireDefault(require("lodash/assign"));
|
|
33
|
-
|
|
34
|
-
var _core = require("@graphql-box/core");
|
|
35
|
-
|
|
36
|
-
var _helpers = require("@graphql-box/helpers");
|
|
37
|
-
|
|
38
|
-
var _cacheability2 = _interopRequireDefault(require("cacheability"));
|
|
39
|
-
|
|
40
|
-
var _graphql = require("graphql");
|
|
41
|
-
|
|
42
|
-
var _consts = require("../consts");
|
|
43
|
-
|
|
44
|
-
var _debug = require("../debug");
|
|
45
|
-
|
|
46
|
-
var _areOnlyPopulatedFieldsTypeIdKeys = _interopRequireDefault(require("../helpers/areOnlyPopulatedFieldsTypeIdKeys"));
|
|
47
|
-
|
|
48
|
-
var _deriveOpCacheability = _interopRequireDefault(require("../helpers/deriveOpCacheability"));
|
|
49
|
-
|
|
50
|
-
var _filterOutPropsWithArgsOrDirectives = _interopRequireDefault(require("../helpers/filterOutPropsWithArgsOrDirectives"));
|
|
51
|
-
|
|
52
|
-
var _filterQuery = _interopRequireDefault(require("../helpers/filterQuery"));
|
|
53
|
-
|
|
54
|
-
var _isLastResponseChunk = _interopRequireDefault(require("../helpers/isLastResponseChunk"));
|
|
55
|
-
|
|
56
|
-
var _isNotLastResponseChunk = _interopRequireDefault(require("../helpers/isNotLastResponseChunk"));
|
|
57
|
-
|
|
58
|
-
var _isNotResponseChunk = _interopRequireDefault(require("../helpers/isNotResponseChunk"));
|
|
59
|
-
|
|
60
|
-
var _mergeResponseDataSets = _interopRequireDefault(require("../helpers/mergeResponseDataSets"));
|
|
61
|
-
|
|
62
|
-
var _normalizePatchResponseData = _interopRequireDefault(require("../helpers/normalizePatchResponseData"));
|
|
63
|
-
|
|
64
|
-
var _validTypeIDValue = require("../helpers/validTypeIDValue");
|
|
65
|
-
|
|
66
|
-
var _dec, _dec2, _dec3, _class;
|
|
67
|
-
|
|
68
|
-
let CacheManager = (_dec = (0, _debug.logCacheQuery)(), _dec2 = (0, _debug.logCacheEntry)(), _dec3 = (0, _debug.logPartialCompiled)(), (_class = class CacheManager {
|
|
69
|
-
static _countFieldPathChecklist(fieldPathChecklist) {
|
|
70
|
-
const fieldCount = {
|
|
71
|
-
missing: 0,
|
|
72
|
-
total: 0
|
|
73
|
-
};
|
|
74
|
-
fieldPathChecklist.forEach(checklistValues => {
|
|
75
|
-
fieldCount.total += checklistValues.length;
|
|
76
|
-
const missing = checklistValues.filter(({
|
|
77
|
-
hasData
|
|
78
|
-
}) => !hasData);
|
|
79
|
-
fieldCount.missing += missing.length;
|
|
80
|
-
});
|
|
81
|
-
return fieldCount;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
static _getFieldDataFromAncestor(ancestorFieldData, propNameOrIndex) {
|
|
85
|
-
return (0, _isObjectLike2.default)(ancestorFieldData) ? (0, _cloneDeep2.default)(ancestorFieldData[propNameOrIndex]) : undefined;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
static _getOperationCacheControl(cacheMetadata, operation) {
|
|
89
|
-
const defaultCacheControl = _consts.HEADER_NO_CACHE;
|
|
90
|
-
|
|
91
|
-
if (!cacheMetadata) {
|
|
92
|
-
return defaultCacheControl;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
const cacheability = cacheMetadata.get(operation);
|
|
96
|
-
return cacheability ? cacheability.printCacheControl() : defaultCacheControl;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
static _isNodeEntity(fieldTypeInfo) {
|
|
100
|
-
if (!fieldTypeInfo) {
|
|
101
|
-
return false;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
const {
|
|
105
|
-
isEntity,
|
|
106
|
-
possibleTypes
|
|
107
|
-
} = fieldTypeInfo;
|
|
108
|
-
return isEntity || possibleTypes.some(type => !!type.isEntity);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
static _isNodeRequestFieldPath(fieldTypeInfo) {
|
|
112
|
-
return !!fieldTypeInfo && (this._isNodeEntity(fieldTypeInfo) || fieldTypeInfo.hasArguments || fieldTypeInfo.hasDirectives);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
static _isValid(cacheability) {
|
|
116
|
-
const noCache = (0, _get2.default)(cacheability, [_consts.METADATA, _consts.CACHE_CONTROL, _consts.NO_CACHE], false);
|
|
117
|
-
return !noCache && cacheability.checkTTL();
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
static _mergeResponseCacheMetadata(cacheMetadata, partialQueryResponse) {
|
|
121
|
-
if (!partialQueryResponse) {
|
|
122
|
-
return cacheMetadata;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
return new Map([...partialQueryResponse.cacheMetadata, ...cacheMetadata]);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
static _setCachedData(requestData, {
|
|
129
|
-
data
|
|
130
|
-
}, propNameOrIndex) {
|
|
131
|
-
if (!(0, _isObjectLike2.default)(data) && !(0, _isUndefined2.default)(data)) {
|
|
132
|
-
requestData[propNameOrIndex] = data;
|
|
133
|
-
} else if ((0, _isObjectLike2.default)(data)) {
|
|
134
|
-
const objectLikeData = data;
|
|
135
|
-
requestData[propNameOrIndex] = (0, _isArray2.default)(objectLikeData) ? [] : {};
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
static _setCachedResponseData(cachedFieldData, {
|
|
140
|
-
cacheMetadata,
|
|
141
|
-
data,
|
|
142
|
-
fieldPathChecklist
|
|
143
|
-
}, {
|
|
144
|
-
propNameOrIndex,
|
|
145
|
-
requestFieldPath
|
|
146
|
-
}, typeNamesAndKind, _options, {
|
|
147
|
-
operation
|
|
148
|
-
}) {
|
|
149
|
-
CacheManager._setCacheMetadata(cacheMetadata, cachedFieldData.cacheability, requestFieldPath, operation);
|
|
150
|
-
|
|
151
|
-
CacheManager._setFieldPathChecklist(fieldPathChecklist, cachedFieldData, requestFieldPath, typeNamesAndKind);
|
|
152
|
-
|
|
153
|
-
CacheManager._setCachedData(data, cachedFieldData, propNameOrIndex);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
static _setCacheMetadata(cacheMetadata, cacheability, requestFieldPath, operation) {
|
|
157
|
-
if (!cacheability) {
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
cacheMetadata.set(requestFieldPath, cacheability);
|
|
162
|
-
const operationCacheability = cacheMetadata.get(operation);
|
|
163
|
-
|
|
164
|
-
if (!operationCacheability || operationCacheability.metadata.ttl > cacheability.metadata.ttl) {
|
|
165
|
-
cacheMetadata.set(operation, cacheability);
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
static _setFieldPathChecklist(fieldPathChecklist, {
|
|
170
|
-
data
|
|
171
|
-
}, requestFieldPath, {
|
|
172
|
-
dataTypeName,
|
|
173
|
-
fieldTypeName,
|
|
174
|
-
fragmentKind,
|
|
175
|
-
fragmentName
|
|
176
|
-
}) {
|
|
177
|
-
if ((0, _isUndefined2.default)(fieldTypeName) || fragmentKind === _helpers.FRAGMENT_SPREAD) {
|
|
178
|
-
if (fieldPathChecklist.has(requestFieldPath)) {
|
|
179
|
-
return;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
fieldPathChecklist.set(requestFieldPath, [{
|
|
183
|
-
fragmentKind,
|
|
184
|
-
fragmentName,
|
|
185
|
-
hasData: !(0, _isUndefined2.default)(data)
|
|
186
|
-
}]);
|
|
187
|
-
return;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
if (dataTypeName !== fieldTypeName) {
|
|
191
|
-
return;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
const entry = fieldPathChecklist.get(requestFieldPath);
|
|
195
|
-
const checklistValues = entry ? entry : [];
|
|
196
|
-
|
|
197
|
-
if (checklistValues.some(({
|
|
198
|
-
typeName
|
|
199
|
-
}) => typeName === dataTypeName)) {
|
|
200
|
-
return;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
fieldPathChecklist.set(requestFieldPath, [...checklistValues, {
|
|
204
|
-
fragmentKind,
|
|
205
|
-
fragmentName,
|
|
206
|
-
hasData: !(0, _isUndefined2.default)(data),
|
|
207
|
-
typeName: dataTypeName
|
|
208
|
-
}]);
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
constructor(options) {
|
|
212
|
-
var _options$typeIDKey;
|
|
213
|
-
|
|
214
|
-
(0, _defineProperty2.default)(this, "_cache", void 0);
|
|
215
|
-
(0, _defineProperty2.default)(this, "_cascadeCacheControl", void 0);
|
|
216
|
-
(0, _defineProperty2.default)(this, "_fallbackOperationCacheability", void 0);
|
|
217
|
-
(0, _defineProperty2.default)(this, "_partialQueryResponses", new Map());
|
|
218
|
-
(0, _defineProperty2.default)(this, "_responseChunksAwaitingCaching", new Map());
|
|
219
|
-
(0, _defineProperty2.default)(this, "_typeCacheDirectives", void 0);
|
|
220
|
-
(0, _defineProperty2.default)(this, "_typeIDKey", void 0);
|
|
221
|
-
const errors = [];
|
|
222
|
-
|
|
223
|
-
if (!options.cache) {
|
|
224
|
-
errors.push(new TypeError("@graphql-box/cache-manager expected options.cache."));
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
if (!!options.typeCacheDirectives && !(0, _isPlainObject2.default)(options.typeCacheDirectives)) {
|
|
228
|
-
const message = "@graphql-box/cache-manager expected options.typeCacheDirectives to be a plain object.";
|
|
229
|
-
errors.push(new TypeError(message));
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
if (errors.length) {
|
|
233
|
-
throw errors;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
this._cache = options.cache;
|
|
237
|
-
this._cascadeCacheControl = options.cascadeCacheControl || false;
|
|
238
|
-
this._fallbackOperationCacheability = options.fallbackOperationCacheability || _consts.NO_CACHE;
|
|
239
|
-
this._typeCacheDirectives = options.typeCacheDirectives || {};
|
|
240
|
-
this._typeIDKey = (_options$typeIDKey = options.typeIDKey) !== null && _options$typeIDKey !== void 0 ? _options$typeIDKey : _core.DEFAULT_TYPE_ID_KEY;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
get cache() {
|
|
244
|
-
return this._cache;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
async analyzeQuery(requestData, options, context) {
|
|
248
|
-
const {
|
|
249
|
-
ast,
|
|
250
|
-
hash
|
|
251
|
-
} = requestData;
|
|
252
|
-
|
|
253
|
-
if (!ast) {
|
|
254
|
-
return Promise.reject(new TypeError("@graphql-box/cache-manager expected an AST."));
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
const cacheManagerContext = { ...context,
|
|
258
|
-
fragmentDefinitions: (0, _helpers.getFragmentDefinitions)(ast),
|
|
259
|
-
typeIDKey: this._typeIDKey
|
|
260
|
-
};
|
|
261
|
-
const cachedResponseData = await this._retrieveCachedResponseData(requestData, options, cacheManagerContext);
|
|
262
|
-
const {
|
|
263
|
-
cacheMetadata,
|
|
264
|
-
data,
|
|
265
|
-
fieldCount
|
|
266
|
-
} = cachedResponseData;
|
|
267
|
-
|
|
268
|
-
if (fieldCount.missing === fieldCount.total || (0, _areOnlyPopulatedFieldsTypeIdKeys.default)(data, this._typeIDKey)) {
|
|
269
|
-
return {
|
|
270
|
-
updated: requestData
|
|
271
|
-
};
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
if (!fieldCount.missing) {
|
|
275
|
-
const dataCaching = this._setQueryResponseCacheEntry(hash, {
|
|
276
|
-
cacheMetadata,
|
|
277
|
-
data
|
|
278
|
-
}, options, cacheManagerContext);
|
|
279
|
-
|
|
280
|
-
if (options.awaitDataCaching) {
|
|
281
|
-
await dataCaching;
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
return {
|
|
285
|
-
response: {
|
|
286
|
-
cacheMetadata,
|
|
287
|
-
data
|
|
288
|
-
}
|
|
289
|
-
};
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
const filteredAST = (0, _filterQuery.default)(requestData, cachedResponseData, cacheManagerContext);
|
|
293
|
-
const filteredRequest = (0, _graphql.print)(filteredAST);
|
|
294
|
-
const {
|
|
295
|
-
fragmentDefinitions,
|
|
296
|
-
typeIDKey,
|
|
297
|
-
...rest
|
|
298
|
-
} = cacheManagerContext;
|
|
299
|
-
(0, _assign2.default)(context, { ...rest,
|
|
300
|
-
filteredRequest
|
|
301
|
-
});
|
|
302
|
-
|
|
303
|
-
this._setPartialQueryResponse(hash, {
|
|
304
|
-
cacheMetadata,
|
|
305
|
-
data
|
|
306
|
-
}, options, context);
|
|
307
|
-
|
|
308
|
-
return {
|
|
309
|
-
updated: {
|
|
310
|
-
ast: filteredAST,
|
|
311
|
-
hash: (0, _helpers.hashRequest)(filteredRequest),
|
|
312
|
-
request: filteredRequest
|
|
313
|
-
}
|
|
314
|
-
};
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
async cacheQuery(requestData, updatedRequestData, rawResponseData, options, context) {
|
|
318
|
-
const cacheManagerContext = { ...context,
|
|
319
|
-
fragmentDefinitions: (0, _helpers.getFragmentDefinitions)((updatedRequestData !== null && updatedRequestData !== void 0 ? updatedRequestData : requestData).ast),
|
|
320
|
-
typeIDKey: this._typeIDKey
|
|
321
|
-
};
|
|
322
|
-
return this._cacheResponse(requestData, updatedRequestData, rawResponseData, options, cacheManagerContext);
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
async cacheResponse(requestData, rawResponseData, options, context) {
|
|
326
|
-
const cacheManagerContext = { ...context,
|
|
327
|
-
fragmentDefinitions: (0, _helpers.getFragmentDefinitions)(requestData.ast),
|
|
328
|
-
typeIDKey: this._typeIDKey
|
|
329
|
-
};
|
|
330
|
-
return this._cacheResponse(requestData, undefined, rawResponseData, options, cacheManagerContext);
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
async checkCacheEntry(cacheType, hash, options, context) {
|
|
334
|
-
return this._checkCacheEntry(cacheType, hash, options, context);
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
async checkQueryResponseCacheEntry(hash, options, context) {
|
|
338
|
-
const result = await this._checkCacheEntry(_core.QUERY_RESPONSES, hash, options, context);
|
|
339
|
-
|
|
340
|
-
if (!result) {
|
|
341
|
-
return false;
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
const {
|
|
345
|
-
cacheMetadata,
|
|
346
|
-
data
|
|
347
|
-
} = result.entry;
|
|
348
|
-
return {
|
|
349
|
-
cacheMetadata: (0, _helpers.rehydrateCacheMetadata)(cacheMetadata),
|
|
350
|
-
data
|
|
351
|
-
};
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
deletePartialQueryResponse(hash) {
|
|
355
|
-
this._partialQueryResponses.delete(hash);
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
async setQueryResponseCacheEntry(requestData, responseData, options, context) {
|
|
359
|
-
return this._setQueryResponseCacheEntry(requestData.hash, responseData, options, context);
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
async _analyzeFieldNode(fieldNode, cachedAncestorFieldData, cachedResponseData, options, context) {
|
|
363
|
-
if ((0, _helpers.hasChildFields)(fieldNode, {
|
|
364
|
-
fragmentDefinitions: context.fragmentDefinitions
|
|
365
|
-
})) {
|
|
366
|
-
await this._analyzeParentFieldNode(fieldNode, cachedAncestorFieldData, cachedResponseData, options, context);
|
|
367
|
-
} else {
|
|
368
|
-
await this._analyzeLeafFieldNode(fieldNode, cachedAncestorFieldData, cachedResponseData, options, context);
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
async _analyzeLeafFieldNode(fieldNode, cachedAncestorFieldData, cachedResponseData, options, context) {
|
|
373
|
-
const keysAndPaths = (0, _helpers.buildFieldKeysAndPaths)(fieldNode, cachedAncestorFieldData, context);
|
|
374
|
-
const {
|
|
375
|
-
hashedRequestFieldCacheKey,
|
|
376
|
-
propNameOrIndex,
|
|
377
|
-
requestFieldCacheKey,
|
|
378
|
-
requestFieldPath
|
|
379
|
-
} = keysAndPaths;
|
|
380
|
-
const fieldTypeInfo = context.fieldTypeMap.get(requestFieldPath);
|
|
381
|
-
const {
|
|
382
|
-
entityData,
|
|
383
|
-
fragmentKind,
|
|
384
|
-
fragmentName,
|
|
385
|
-
requestFieldPathData,
|
|
386
|
-
typeName
|
|
387
|
-
} = cachedAncestorFieldData;
|
|
388
|
-
const typeNamesAndKind = {
|
|
389
|
-
dataTypeName: (entityData === null || entityData === void 0 ? void 0 : entityData.__typename) || (requestFieldPathData === null || requestFieldPathData === void 0 ? void 0 : requestFieldPathData.__typename),
|
|
390
|
-
fieldTypeName: typeName,
|
|
391
|
-
fragmentKind,
|
|
392
|
-
fragmentName
|
|
393
|
-
};
|
|
394
|
-
|
|
395
|
-
if (CacheManager._isNodeRequestFieldPath(fieldTypeInfo)) {
|
|
396
|
-
const {
|
|
397
|
-
cacheability,
|
|
398
|
-
entry
|
|
399
|
-
} = await this._retrieveCachedRequestFieldPathData(hashedRequestFieldCacheKey, requestFieldCacheKey, options, context);
|
|
400
|
-
|
|
401
|
-
CacheManager._setCachedResponseData({
|
|
402
|
-
cacheability,
|
|
403
|
-
data: entry
|
|
404
|
-
}, cachedResponseData, keysAndPaths, typeNamesAndKind, options, context);
|
|
405
|
-
} else {
|
|
406
|
-
const cachedFieldData = CacheManager._getFieldDataFromAncestor(entityData, propNameOrIndex) || CacheManager._getFieldDataFromAncestor(requestFieldPathData, propNameOrIndex);
|
|
407
|
-
|
|
408
|
-
CacheManager._setFieldPathChecklist(cachedResponseData.fieldPathChecklist, {
|
|
409
|
-
data: cachedFieldData
|
|
410
|
-
}, requestFieldPath, typeNamesAndKind);
|
|
411
|
-
|
|
412
|
-
CacheManager._setCachedData(cachedResponseData.data, {
|
|
413
|
-
data: cachedFieldData
|
|
414
|
-
}, propNameOrIndex);
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
async _analyzeParentFieldNode(fieldNode, cachedAncestorFieldData, cachedResponseData, options, context) {
|
|
419
|
-
const keysAndPaths = (0, _helpers.buildFieldKeysAndPaths)(fieldNode, cachedAncestorFieldData, context);
|
|
420
|
-
const {
|
|
421
|
-
propNameOrIndex,
|
|
422
|
-
requestFieldCacheKey,
|
|
423
|
-
requestFieldPath
|
|
424
|
-
} = keysAndPaths;
|
|
425
|
-
const fieldTypeInfo = context.fieldTypeMap.get(requestFieldPath);
|
|
426
|
-
const {
|
|
427
|
-
cacheability,
|
|
428
|
-
data,
|
|
429
|
-
entityData,
|
|
430
|
-
requestFieldPathData
|
|
431
|
-
} = await this._retrieveCachedParentNodeData(cachedAncestorFieldData, keysAndPaths, fieldTypeInfo, options, context);
|
|
432
|
-
const {
|
|
433
|
-
fragmentKind,
|
|
434
|
-
fragmentName,
|
|
435
|
-
typeName
|
|
436
|
-
} = cachedAncestorFieldData;
|
|
437
|
-
|
|
438
|
-
CacheManager._setCachedResponseData({
|
|
439
|
-
cacheability,
|
|
440
|
-
data
|
|
441
|
-
}, cachedResponseData, keysAndPaths, {
|
|
442
|
-
dataTypeName: (0, _get2.default)(data, _core.TYPE_NAME_KEY),
|
|
443
|
-
fieldTypeName: typeName,
|
|
444
|
-
fragmentKind,
|
|
445
|
-
fragmentName
|
|
446
|
-
}, options, context);
|
|
447
|
-
|
|
448
|
-
if (!(0, _isObjectLike2.default)(data)) {
|
|
449
|
-
return;
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
const objectLikeData = data;
|
|
453
|
-
const promises = [];
|
|
454
|
-
(0, _helpers.iterateChildFields)(fieldNode, objectLikeData, context.fragmentDefinitions, (childField, childTypeName, childFragmentKind, childFragmentName, childIndex) => {
|
|
455
|
-
promises.push(this._analyzeFieldNode(childField, {
|
|
456
|
-
cacheability,
|
|
457
|
-
entityData,
|
|
458
|
-
fragmentKind: childFragmentKind,
|
|
459
|
-
fragmentName: childFragmentName,
|
|
460
|
-
index: childIndex,
|
|
461
|
-
requestFieldCacheKey,
|
|
462
|
-
requestFieldPath,
|
|
463
|
-
requestFieldPathData,
|
|
464
|
-
typeName: childTypeName
|
|
465
|
-
}, { ...cachedResponseData,
|
|
466
|
-
data: cachedResponseData.data[propNameOrIndex]
|
|
467
|
-
}, options, context));
|
|
468
|
-
});
|
|
469
|
-
await Promise.all(promises);
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
_buildCacheMetadata({
|
|
473
|
-
ast
|
|
474
|
-
}, {
|
|
475
|
-
data,
|
|
476
|
-
...otherProps
|
|
477
|
-
}, options, context) {
|
|
478
|
-
const cacheMetadata = this._createCacheMetadata({
|
|
479
|
-
data,
|
|
480
|
-
...otherProps
|
|
481
|
-
}, context);
|
|
482
|
-
|
|
483
|
-
const queryNode = (0, _helpers.getOperationDefinitions)(ast, context.operation)[0];
|
|
484
|
-
const fieldsAndTypeNames = (0, _helpers.getChildFields)(queryNode);
|
|
485
|
-
|
|
486
|
-
if (!fieldsAndTypeNames) {
|
|
487
|
-
return cacheMetadata;
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
fieldsAndTypeNames.forEach(({
|
|
491
|
-
fieldNode
|
|
492
|
-
}) => this._setFieldCacheability(fieldNode, {
|
|
493
|
-
requestFieldPath: context.operation
|
|
494
|
-
}, {
|
|
495
|
-
cacheMetadata,
|
|
496
|
-
data
|
|
497
|
-
}, options, context));
|
|
498
|
-
return cacheMetadata;
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
async _cacheResponse(requestData, updatedRequestData, rawResponseData, options, context) {
|
|
502
|
-
const normalizedResponseData = (0, _normalizePatchResponseData.default)(rawResponseData, context);
|
|
503
|
-
let responseDataForCaching = normalizedResponseData;
|
|
504
|
-
|
|
505
|
-
if ((0, _isNotLastResponseChunk.default)(rawResponseData, context)) {
|
|
506
|
-
this._setResponseChunksAwaitingCaching(normalizedResponseData, context);
|
|
507
|
-
|
|
508
|
-
responseDataForCaching = undefined;
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
if ((0, _isLastResponseChunk.default)(rawResponseData, context)) {
|
|
512
|
-
responseDataForCaching = this._retrieveResponseDataForCaching(normalizedResponseData, context);
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
const dataCaching = [];
|
|
516
|
-
|
|
517
|
-
if (responseDataForCaching) {
|
|
518
|
-
const {
|
|
519
|
-
data
|
|
520
|
-
} = responseDataForCaching;
|
|
521
|
-
|
|
522
|
-
const cacheMetadata = this._buildCacheMetadata(requestData, responseDataForCaching, options, context);
|
|
523
|
-
|
|
524
|
-
dataCaching.push(this._setEntityAndRequestFieldPathCacheEntries(requestData, {
|
|
525
|
-
cacheMetadata,
|
|
526
|
-
entityData: (0, _cloneDeep2.default)(data),
|
|
527
|
-
requestFieldPathData: (0, _cloneDeep2.default)(data)
|
|
528
|
-
}, options, context));
|
|
529
|
-
let queryCacheMetadata;
|
|
530
|
-
let queryData;
|
|
531
|
-
|
|
532
|
-
if (context.operation === _core.QUERY) {
|
|
533
|
-
let partialQueryResponse;
|
|
534
|
-
|
|
535
|
-
if (context.queryFiltered && updatedRequestData) {
|
|
536
|
-
dataCaching.push(this._setQueryResponseCacheEntry(updatedRequestData.hash, {
|
|
537
|
-
cacheMetadata,
|
|
538
|
-
data
|
|
539
|
-
}, options, context));
|
|
540
|
-
partialQueryResponse = this._getPartialQueryResponse(requestData.hash);
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
queryCacheMetadata = CacheManager._mergeResponseCacheMetadata(cacheMetadata, partialQueryResponse);
|
|
544
|
-
queryData = this._mergeResponseData(data, partialQueryResponse);
|
|
545
|
-
dataCaching.push(this._setQueryResponseCacheEntry(requestData.hash, {
|
|
546
|
-
cacheMetadata: queryCacheMetadata,
|
|
547
|
-
data: queryData
|
|
548
|
-
}, options, context));
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
if (options.awaitDataCaching) {
|
|
552
|
-
await Promise.all(dataCaching);
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
if ((0, _isNotResponseChunk.default)(normalizedResponseData, context) && queryCacheMetadata && queryData) {
|
|
556
|
-
return {
|
|
557
|
-
cacheMetadata: queryCacheMetadata,
|
|
558
|
-
data: queryData
|
|
559
|
-
};
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
const {
|
|
564
|
-
data,
|
|
565
|
-
hasNext,
|
|
566
|
-
paths
|
|
567
|
-
} = normalizedResponseData;
|
|
568
|
-
return {
|
|
569
|
-
cacheMetadata: this._buildCacheMetadata(requestData, normalizedResponseData, options, context),
|
|
570
|
-
data,
|
|
571
|
-
hasNext,
|
|
572
|
-
paths
|
|
573
|
-
};
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
async _checkCacheEntry(cacheType, hash, options, context) {
|
|
577
|
-
try {
|
|
578
|
-
const cacheability = await this._hasCacheEntry(cacheType, hash);
|
|
579
|
-
|
|
580
|
-
if (!cacheability || !CacheManager._isValid(cacheability)) {
|
|
581
|
-
return false;
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
const entry = await this._getCacheEntry(cacheType, hash, options, context);
|
|
585
|
-
|
|
586
|
-
if ((0, _isUndefined2.default)(entry)) {
|
|
587
|
-
return false;
|
|
588
|
-
}
|
|
589
|
-
|
|
590
|
-
return {
|
|
591
|
-
cacheability,
|
|
592
|
-
entry
|
|
593
|
-
};
|
|
594
|
-
} catch (error) {
|
|
595
|
-
return false;
|
|
596
|
-
}
|
|
597
|
-
}
|
|
598
|
-
|
|
599
|
-
_createCacheMetadata({
|
|
600
|
-
_cacheMetadata,
|
|
601
|
-
headers
|
|
602
|
-
}, {
|
|
603
|
-
operation
|
|
604
|
-
}) {
|
|
605
|
-
const cacheMetadata = new Map();
|
|
606
|
-
const cacheability = (0, _deriveOpCacheability.default)({
|
|
607
|
-
_cacheMetadata,
|
|
608
|
-
fallback: this._fallbackOperationCacheability,
|
|
609
|
-
headers
|
|
610
|
-
});
|
|
611
|
-
cacheMetadata.set(operation, cacheability);
|
|
612
|
-
|
|
613
|
-
if (_cacheMetadata) {
|
|
614
|
-
(0, _helpers.rehydrateCacheMetadata)(_cacheMetadata, cacheMetadata);
|
|
615
|
-
}
|
|
616
|
-
|
|
617
|
-
return cacheMetadata;
|
|
618
|
-
}
|
|
619
|
-
|
|
620
|
-
async _getCacheEntry(cacheType, hash, _options, _context) {
|
|
621
|
-
try {
|
|
622
|
-
return await this._cache.get(`${cacheType}::${hash}`);
|
|
623
|
-
} catch (errors) {
|
|
624
|
-
return Promise.reject(errors);
|
|
625
|
-
}
|
|
626
|
-
}
|
|
627
|
-
|
|
628
|
-
_getPartialQueryResponse(hash) {
|
|
629
|
-
const partialQueryResponse = this._partialQueryResponses.get(hash);
|
|
630
|
-
|
|
631
|
-
this._partialQueryResponses.delete(hash);
|
|
632
|
-
|
|
633
|
-
return partialQueryResponse;
|
|
634
|
-
}
|
|
635
|
-
|
|
636
|
-
async _hasCacheEntry(cacheType, hash) {
|
|
637
|
-
try {
|
|
638
|
-
return await this._cache.has(`${cacheType}::${hash}`);
|
|
639
|
-
} catch (error) {
|
|
640
|
-
return false;
|
|
641
|
-
}
|
|
642
|
-
}
|
|
643
|
-
|
|
644
|
-
_isFieldEntity(fieldData, {
|
|
645
|
-
isEntity,
|
|
646
|
-
possibleTypes
|
|
647
|
-
}) {
|
|
648
|
-
if (!(0, _get2.default)(fieldData, this._typeIDKey, null)) {
|
|
649
|
-
return false;
|
|
650
|
-
}
|
|
651
|
-
|
|
652
|
-
if (isEntity) {
|
|
653
|
-
return true;
|
|
654
|
-
}
|
|
655
|
-
|
|
656
|
-
if (!possibleTypes.length) {
|
|
657
|
-
return false;
|
|
658
|
-
}
|
|
659
|
-
|
|
660
|
-
return possibleTypes.some(type => type.typeName === fieldData.__typename);
|
|
661
|
-
}
|
|
662
|
-
|
|
663
|
-
_mergeObjects(obj, src) {
|
|
664
|
-
return (0, _helpers.mergeObjects)(obj, src, (_key, val) => {
|
|
665
|
-
return (0, _isPlainObject2.default)(val) && val[this._typeIDKey] ? val[this._typeIDKey] : undefined;
|
|
666
|
-
});
|
|
667
|
-
}
|
|
668
|
-
|
|
669
|
-
_mergeResponseData(responseData, partialQueryResponse) {
|
|
670
|
-
if (!partialQueryResponse) {
|
|
671
|
-
return responseData;
|
|
672
|
-
}
|
|
673
|
-
|
|
674
|
-
return this._mergeObjects(partialQueryResponse.data, responseData);
|
|
675
|
-
}
|
|
676
|
-
|
|
677
|
-
async _parseEntityAndRequestFieldPathCacheEntryData(field, ancestorKeysAndPaths, {
|
|
678
|
-
cacheMetadata,
|
|
679
|
-
entityData,
|
|
680
|
-
requestFieldPathData
|
|
681
|
-
}, options, context) {
|
|
682
|
-
const keysAndPaths = (0, _helpers.buildFieldKeysAndPaths)(field, ancestorKeysAndPaths, context);
|
|
683
|
-
const {
|
|
684
|
-
requestFieldCacheKey,
|
|
685
|
-
requestFieldPath,
|
|
686
|
-
responseDataPath
|
|
687
|
-
} = keysAndPaths;
|
|
688
|
-
const fieldData = (0, _get2.default)(requestFieldPathData, responseDataPath);
|
|
689
|
-
const fieldTypeInfo = context.fieldTypeMap.get(requestFieldPath);
|
|
690
|
-
|
|
691
|
-
if (!(0, _isObjectLike2.default)(fieldData) && !(fieldTypeInfo !== null && fieldTypeInfo !== void 0 && fieldTypeInfo.hasDirectives)) {
|
|
692
|
-
return;
|
|
693
|
-
}
|
|
694
|
-
|
|
695
|
-
if ((0, _isObjectLike2.default)(fieldData)) {
|
|
696
|
-
const promises = [];
|
|
697
|
-
(0, _helpers.iterateChildFields)(field, fieldData, context.fragmentDefinitions, (childField, _typeName, _fragmentKind, _fragmentName, childIndex) => {
|
|
698
|
-
promises.push(this._parseEntityAndRequestFieldPathCacheEntryData(childField, {
|
|
699
|
-
index: childIndex,
|
|
700
|
-
requestFieldCacheKey,
|
|
701
|
-
requestFieldPath,
|
|
702
|
-
responseDataPath
|
|
703
|
-
}, {
|
|
704
|
-
cacheMetadata,
|
|
705
|
-
entityData,
|
|
706
|
-
requestFieldPathData
|
|
707
|
-
}, options, context));
|
|
708
|
-
});
|
|
709
|
-
await Promise.all(promises);
|
|
710
|
-
}
|
|
711
|
-
|
|
712
|
-
await this._setEntityAndRequestFieldPathCacheEntry(field, keysAndPaths, {
|
|
713
|
-
cacheMetadata,
|
|
714
|
-
entityData,
|
|
715
|
-
requestFieldPathData
|
|
716
|
-
}, options, context);
|
|
717
|
-
}
|
|
718
|
-
|
|
719
|
-
async _retrieveCachedEntityData(validTypeIDValue, {
|
|
720
|
-
possibleTypes,
|
|
721
|
-
typeName
|
|
722
|
-
}, options, context) {
|
|
723
|
-
const typeNames = [...possibleTypes.map(type => type.typeName), typeName];
|
|
724
|
-
const checkResults = await Promise.all(typeNames.map(name => this._checkCacheEntry(_core.DATA_ENTITIES, `${name}::${validTypeIDValue}`, options, context)));
|
|
725
|
-
const validResults = checkResults.filter(result => !!result);
|
|
726
|
-
let validResult;
|
|
727
|
-
|
|
728
|
-
if (validResults.length === 1) {
|
|
729
|
-
validResult = validResults[0];
|
|
730
|
-
} else if (validResults.length > 1) {
|
|
731
|
-
validResults.sort(({
|
|
732
|
-
cacheability: a
|
|
733
|
-
}, {
|
|
734
|
-
cacheability: b
|
|
735
|
-
}) => a.metadata.ttl - b.metadata.ttl);
|
|
736
|
-
validResult = {
|
|
737
|
-
cacheability: validResults[0].cacheability,
|
|
738
|
-
entry: validResults.reduce((obj, {
|
|
739
|
-
entry
|
|
740
|
-
}) => this._mergeObjects(obj, entry), {})
|
|
741
|
-
};
|
|
742
|
-
}
|
|
743
|
-
|
|
744
|
-
return validResult || {};
|
|
745
|
-
}
|
|
746
|
-
|
|
747
|
-
async _retrieveCachedParentNodeData({
|
|
748
|
-
entityData: ancestorEntityData,
|
|
749
|
-
requestFieldPathData: ancestorRequestFieldPathData
|
|
750
|
-
}, {
|
|
751
|
-
hashedRequestFieldCacheKey,
|
|
752
|
-
propNameOrIndex,
|
|
753
|
-
requestFieldCacheKey
|
|
754
|
-
}, fieldTypeInfo, options, context) {
|
|
755
|
-
var _entityData;
|
|
756
|
-
|
|
757
|
-
let entityData = CacheManager._getFieldDataFromAncestor(ancestorEntityData, propNameOrIndex);
|
|
758
|
-
|
|
759
|
-
let requestFieldPathData = CacheManager._getFieldDataFromAncestor(ancestorRequestFieldPathData, propNameOrIndex);
|
|
760
|
-
|
|
761
|
-
let cacheability;
|
|
762
|
-
|
|
763
|
-
if (CacheManager._isNodeRequestFieldPath(fieldTypeInfo)) {
|
|
764
|
-
const {
|
|
765
|
-
cacheability: entryCacheability,
|
|
766
|
-
entry
|
|
767
|
-
} = await this._retrieveCachedRequestFieldPathData(hashedRequestFieldCacheKey, requestFieldCacheKey, options, context);
|
|
768
|
-
|
|
769
|
-
if (entry) {
|
|
770
|
-
requestFieldPathData = this._mergeObjects(requestFieldPathData, entry);
|
|
771
|
-
}
|
|
772
|
-
|
|
773
|
-
if (entryCacheability) {
|
|
774
|
-
cacheability = entryCacheability;
|
|
775
|
-
}
|
|
776
|
-
}
|
|
777
|
-
|
|
778
|
-
const validTypeIDValue = (0, _validTypeIDValue.getValidTypeIDValue)(requestFieldPathData, fieldTypeInfo, this._typeIDKey);
|
|
779
|
-
|
|
780
|
-
if (CacheManager._isNodeEntity(fieldTypeInfo) && validTypeIDValue) {
|
|
781
|
-
var _cacheability;
|
|
782
|
-
|
|
783
|
-
const {
|
|
784
|
-
cacheability: entryCacheability,
|
|
785
|
-
entry
|
|
786
|
-
} = await this._retrieveCachedEntityData(validTypeIDValue, fieldTypeInfo, options, context);
|
|
787
|
-
|
|
788
|
-
if (entry) {
|
|
789
|
-
entityData = this._mergeObjects(entityData, entry);
|
|
790
|
-
}
|
|
791
|
-
|
|
792
|
-
if (entryCacheability && (!cacheability || entryCacheability.metadata.ttl > ((_cacheability = cacheability) === null || _cacheability === void 0 ? void 0 : _cacheability.metadata.ttl))) {
|
|
793
|
-
cacheability = entryCacheability;
|
|
794
|
-
}
|
|
795
|
-
}
|
|
796
|
-
|
|
797
|
-
const data = !(0, _isUndefined2.default)(requestFieldPathData) || !(0, _isUndefined2.default)(entityData) ? this._mergeObjects(requestFieldPathData, entityData) : (_entityData = entityData) !== null && _entityData !== void 0 ? _entityData : requestFieldPathData;
|
|
798
|
-
return {
|
|
799
|
-
cacheability,
|
|
800
|
-
data,
|
|
801
|
-
entityData,
|
|
802
|
-
requestFieldPathData
|
|
803
|
-
};
|
|
804
|
-
}
|
|
805
|
-
|
|
806
|
-
async _retrieveCachedRequestFieldPathData(hash, requestFieldCacheKey, options, context) {
|
|
807
|
-
return this._checkCacheEntry(_core.REQUEST_FIELD_PATHS, hash, options, { ...context,
|
|
808
|
-
requestFieldCacheKey
|
|
809
|
-
}) || {};
|
|
810
|
-
}
|
|
811
|
-
|
|
812
|
-
async _retrieveCachedResponseData({
|
|
813
|
-
ast
|
|
814
|
-
}, options, context) {
|
|
815
|
-
const cachedResponseData = {
|
|
816
|
-
cacheMetadata: new Map(),
|
|
817
|
-
data: {},
|
|
818
|
-
fieldCount: {
|
|
819
|
-
missing: 0,
|
|
820
|
-
total: 0
|
|
821
|
-
},
|
|
822
|
-
fieldPathChecklist: new Map()
|
|
823
|
-
};
|
|
824
|
-
const queryNode = (0, _helpers.getOperationDefinitions)(ast, context.operation)[0];
|
|
825
|
-
const fieldsAndTypeNames = (0, _helpers.getChildFields)(queryNode);
|
|
826
|
-
|
|
827
|
-
if (!fieldsAndTypeNames) {
|
|
828
|
-
return cachedResponseData;
|
|
829
|
-
}
|
|
830
|
-
|
|
831
|
-
await Promise.all(fieldsAndTypeNames.map(({
|
|
832
|
-
fieldNode
|
|
833
|
-
}) => this._analyzeFieldNode(fieldNode, {
|
|
834
|
-
requestFieldPath: context.operation
|
|
835
|
-
}, cachedResponseData, options, context)));
|
|
836
|
-
cachedResponseData.fieldCount = CacheManager._countFieldPathChecklist(cachedResponseData.fieldPathChecklist);
|
|
837
|
-
return cachedResponseData;
|
|
838
|
-
}
|
|
839
|
-
|
|
840
|
-
_retrieveResponseDataForCaching(normalizedResponseData, context) {
|
|
841
|
-
const responseChunks = this._responseChunksAwaitingCaching.get(context.requestID);
|
|
842
|
-
|
|
843
|
-
this._responseChunksAwaitingCaching.delete(context.requestID);
|
|
844
|
-
|
|
845
|
-
return (0, _mergeResponseDataSets.default)([...responseChunks, normalizedResponseData]);
|
|
846
|
-
}
|
|
847
|
-
|
|
848
|
-
async _setCacheEntry(cacheType, hash, value, cachemapOptions, _options, _context) {
|
|
849
|
-
try {
|
|
850
|
-
await this._cache.set(`${cacheType}::${hash}`, (0, _cloneDeep2.default)(value), cachemapOptions);
|
|
851
|
-
} catch (error) {}
|
|
852
|
-
}
|
|
853
|
-
|
|
854
|
-
async _setEntityAndRequestFieldPathCacheEntries(requestData, responseData, options, context) {
|
|
855
|
-
const operationNode = (0, _helpers.getOperationDefinitions)(requestData.ast, context.operation)[0];
|
|
856
|
-
const fieldsAndTypeNames = (0, _helpers.getChildFields)(operationNode);
|
|
857
|
-
|
|
858
|
-
if (!fieldsAndTypeNames) {
|
|
859
|
-
return;
|
|
860
|
-
}
|
|
861
|
-
|
|
862
|
-
await Promise.all(fieldsAndTypeNames.map(({
|
|
863
|
-
fieldNode
|
|
864
|
-
}) => {
|
|
865
|
-
return this._parseEntityAndRequestFieldPathCacheEntryData(fieldNode, {
|
|
866
|
-
requestFieldPath: context.operation
|
|
867
|
-
}, responseData, options, context);
|
|
868
|
-
}));
|
|
869
|
-
}
|
|
870
|
-
|
|
871
|
-
async _setEntityAndRequestFieldPathCacheEntry(field, keysAndPaths, {
|
|
872
|
-
cacheMetadata,
|
|
873
|
-
entityData,
|
|
874
|
-
requestFieldPathData
|
|
875
|
-
}, options, context) {
|
|
876
|
-
const {
|
|
877
|
-
requestFieldPath,
|
|
878
|
-
responseDataPath
|
|
879
|
-
} = keysAndPaths;
|
|
880
|
-
const fieldData = (0, _get2.default)(entityData, responseDataPath);
|
|
881
|
-
const fieldTypeInfo = context.fieldTypeMap.get(requestFieldPath);
|
|
882
|
-
const cacheability = cacheMetadata.get(requestFieldPath);
|
|
883
|
-
|
|
884
|
-
if ((0, _isUndefined2.default)(fieldData) || !fieldTypeInfo || !cacheability) {
|
|
885
|
-
return;
|
|
886
|
-
}
|
|
887
|
-
|
|
888
|
-
const promises = [];
|
|
889
|
-
promises.push(this._setRequestFieldPathCacheEntry(field, keysAndPaths, {
|
|
890
|
-
cacheability,
|
|
891
|
-
data: requestFieldPathData,
|
|
892
|
-
fieldTypeInfo
|
|
893
|
-
}, options, context));
|
|
894
|
-
|
|
895
|
-
const isEntity = this._isFieldEntity(fieldData, fieldTypeInfo);
|
|
896
|
-
|
|
897
|
-
if (!isEntity && fieldTypeInfo.hasArguments) {
|
|
898
|
-
(0, _unset2.default)(entityData, responseDataPath);
|
|
899
|
-
}
|
|
900
|
-
|
|
901
|
-
if (isEntity) {
|
|
902
|
-
promises.push(this._setEntityCacheEntry(keysAndPaths, {
|
|
903
|
-
cacheability,
|
|
904
|
-
data: entityData,
|
|
905
|
-
fieldTypeInfo
|
|
906
|
-
}, options, context));
|
|
907
|
-
}
|
|
908
|
-
|
|
909
|
-
await Promise.all(promises);
|
|
910
|
-
}
|
|
911
|
-
|
|
912
|
-
async _setEntityCacheEntry({
|
|
913
|
-
responseDataPath
|
|
914
|
-
}, {
|
|
915
|
-
cacheability,
|
|
916
|
-
data,
|
|
917
|
-
fieldTypeInfo
|
|
918
|
-
}, options, context) {
|
|
919
|
-
let fieldData = (0, _get2.default)(data, responseDataPath);
|
|
920
|
-
const fieldTypeName = fieldTypeInfo.isEntity ? fieldTypeInfo.typeName : fieldData.__typename;
|
|
921
|
-
const entityDataKey = `${fieldTypeName}::${fieldData[this._typeIDKey]}`;
|
|
922
|
-
const result = await this._checkCacheEntry(_core.DATA_ENTITIES, entityDataKey, options, context);
|
|
923
|
-
|
|
924
|
-
if (result) {
|
|
925
|
-
fieldData = this._mergeObjects(result.entry, fieldData);
|
|
926
|
-
}
|
|
927
|
-
|
|
928
|
-
await this._setCacheEntry(_core.DATA_ENTITIES, entityDataKey, fieldData, {
|
|
929
|
-
cacheHeaders: {
|
|
930
|
-
cacheControl: cacheability.printCacheControl()
|
|
931
|
-
},
|
|
932
|
-
tag: options.tag
|
|
933
|
-
}, options, context);
|
|
934
|
-
(0, _set2.default)(data, responseDataPath, {
|
|
935
|
-
__cacheKey: `${_core.DATA_ENTITIES}::${entityDataKey}`
|
|
936
|
-
});
|
|
937
|
-
}
|
|
938
|
-
|
|
939
|
-
_setFieldCacheability(field, ancestorKeysAndPaths, {
|
|
940
|
-
cacheMetadata,
|
|
941
|
-
data
|
|
942
|
-
}, options, context) {
|
|
943
|
-
const {
|
|
944
|
-
requestFieldPath: ancestorRequestFieldPath
|
|
945
|
-
} = ancestorKeysAndPaths;
|
|
946
|
-
const keysAndPaths = (0, _helpers.buildFieldKeysAndPaths)(field, ancestorKeysAndPaths, context);
|
|
947
|
-
const {
|
|
948
|
-
requestFieldPath,
|
|
949
|
-
responseDataPath
|
|
950
|
-
} = keysAndPaths;
|
|
951
|
-
const fieldData = (0, _get2.default)(data, responseDataPath);
|
|
952
|
-
const fieldTypeInfo = context.fieldTypeMap.get(requestFieldPath);
|
|
953
|
-
|
|
954
|
-
if (!(0, _isObjectLike2.default)(fieldData) && !(fieldTypeInfo !== null && fieldTypeInfo !== void 0 && fieldTypeInfo.hasDirectives)) {
|
|
955
|
-
return;
|
|
956
|
-
}
|
|
957
|
-
|
|
958
|
-
this._setFieldTypeCacheDirective(cacheMetadata, {
|
|
959
|
-
ancestorRequestFieldPath,
|
|
960
|
-
requestFieldPath
|
|
961
|
-
}, context);
|
|
962
|
-
|
|
963
|
-
if ((0, _isObjectLike2.default)(fieldData)) {
|
|
964
|
-
(0, _helpers.iterateChildFields)(field, fieldData, context.fragmentDefinitions, (childField, _typeName, _fragmentKind, _fragmentName, childIndex) => {
|
|
965
|
-
this._setFieldCacheability(childField, {
|
|
966
|
-
index: childIndex,
|
|
967
|
-
requestFieldPath,
|
|
968
|
-
responseDataPath
|
|
969
|
-
}, {
|
|
970
|
-
cacheMetadata,
|
|
971
|
-
data
|
|
972
|
-
}, options, context);
|
|
973
|
-
});
|
|
974
|
-
}
|
|
975
|
-
}
|
|
976
|
-
|
|
977
|
-
_setFieldTypeCacheDirective(cacheMetadata, {
|
|
978
|
-
ancestorRequestFieldPath,
|
|
979
|
-
requestFieldPath
|
|
980
|
-
}, {
|
|
981
|
-
fieldTypeMap,
|
|
982
|
-
operation
|
|
983
|
-
}) {
|
|
984
|
-
if (cacheMetadata.has(requestFieldPath)) {
|
|
985
|
-
return;
|
|
986
|
-
}
|
|
987
|
-
|
|
988
|
-
const fieldTypeInfo = fieldTypeMap.get(requestFieldPath);
|
|
989
|
-
|
|
990
|
-
if (fieldTypeInfo && this._typeCacheDirectives[fieldTypeInfo.typeName]) {
|
|
991
|
-
const cacheability = new _cacheability2.default({
|
|
992
|
-
cacheControl: this._typeCacheDirectives[fieldTypeInfo.typeName]
|
|
993
|
-
});
|
|
994
|
-
|
|
995
|
-
CacheManager._setCacheMetadata(cacheMetadata, cacheability, requestFieldPath, operation);
|
|
996
|
-
} else if (this._cascadeCacheControl && ancestorRequestFieldPath) {
|
|
997
|
-
CacheManager._setCacheMetadata(cacheMetadata, cacheMetadata.get(ancestorRequestFieldPath), requestFieldPath, operation);
|
|
998
|
-
}
|
|
999
|
-
}
|
|
1000
|
-
|
|
1001
|
-
async _setPartialQueryResponse(hash, partialQueryResponse, _options, _context) {
|
|
1002
|
-
this._partialQueryResponses.set(hash, partialQueryResponse);
|
|
1003
|
-
}
|
|
1004
|
-
|
|
1005
|
-
async _setQueryResponseCacheEntry(hash, {
|
|
1006
|
-
cacheMetadata,
|
|
1007
|
-
data
|
|
1008
|
-
}, options, context) {
|
|
1009
|
-
const dehydratedCacheMetadata = (0, _helpers.dehydrateCacheMetadata)(cacheMetadata);
|
|
1010
|
-
|
|
1011
|
-
const cacheControl = CacheManager._getOperationCacheControl(cacheMetadata, context.operation);
|
|
1012
|
-
|
|
1013
|
-
await this._setCacheEntry(_core.QUERY_RESPONSES, hash, {
|
|
1014
|
-
cacheMetadata: dehydratedCacheMetadata,
|
|
1015
|
-
data
|
|
1016
|
-
}, {
|
|
1017
|
-
cacheHeaders: {
|
|
1018
|
-
cacheControl
|
|
1019
|
-
},
|
|
1020
|
-
tag: options.tag
|
|
1021
|
-
}, options, context);
|
|
1022
|
-
}
|
|
1023
|
-
|
|
1024
|
-
async _setRequestFieldPathCacheEntry(field, keysAndPaths, {
|
|
1025
|
-
cacheability,
|
|
1026
|
-
data,
|
|
1027
|
-
fieldTypeInfo
|
|
1028
|
-
}, options, context) {
|
|
1029
|
-
const {
|
|
1030
|
-
hashedRequestFieldCacheKey,
|
|
1031
|
-
requestFieldCacheKey,
|
|
1032
|
-
responseDataPath
|
|
1033
|
-
} = keysAndPaths;
|
|
1034
|
-
let fieldData = (0, _get2.default)(data, responseDataPath);
|
|
1035
|
-
|
|
1036
|
-
const isEntity = this._isFieldEntity(fieldData, fieldTypeInfo);
|
|
1037
|
-
|
|
1038
|
-
const hasArgsOrDirectives = fieldTypeInfo.hasArguments || fieldTypeInfo.hasDirectives;
|
|
1039
|
-
|
|
1040
|
-
if (context.operation === _core.QUERY && (isEntity || hasArgsOrDirectives)) {
|
|
1041
|
-
var _field$selectionSet;
|
|
1042
|
-
|
|
1043
|
-
if ((0, _isPlainObject2.default)(fieldData) && (_field$selectionSet = field.selectionSet) !== null && _field$selectionSet !== void 0 && _field$selectionSet.selections) {
|
|
1044
|
-
fieldData = (0, _filterOutPropsWithArgsOrDirectives.default)(fieldData, field.selectionSet.selections, keysAndPaths, context);
|
|
1045
|
-
}
|
|
1046
|
-
|
|
1047
|
-
const result = await this._checkCacheEntry(_core.REQUEST_FIELD_PATHS, hashedRequestFieldCacheKey, options, { ...context,
|
|
1048
|
-
requestFieldCacheKey
|
|
1049
|
-
});
|
|
1050
|
-
|
|
1051
|
-
if (result && (0, _isObjectLike2.default)(fieldData)) {
|
|
1052
|
-
fieldData = this._mergeObjects(result.entry, fieldData);
|
|
1053
|
-
}
|
|
1054
|
-
|
|
1055
|
-
await this._setCacheEntry(_core.REQUEST_FIELD_PATHS, hashedRequestFieldCacheKey, fieldData, {
|
|
1056
|
-
cacheHeaders: {
|
|
1057
|
-
cacheControl: cacheability.printCacheControl()
|
|
1058
|
-
},
|
|
1059
|
-
tag: options.tag
|
|
1060
|
-
}, options, { ...context,
|
|
1061
|
-
requestFieldCacheKey
|
|
1062
|
-
});
|
|
1063
|
-
|
|
1064
|
-
if ((0, _helpers.hasChildFields)(field, {
|
|
1065
|
-
fragmentDefinitions: context.fragmentDefinitions
|
|
1066
|
-
})) {
|
|
1067
|
-
if (isEntity) {
|
|
1068
|
-
(0, _set2.default)(data, responseDataPath, {
|
|
1069
|
-
__cacheKey: `${_core.REQUEST_FIELD_PATHS}::${hashedRequestFieldCacheKey}`
|
|
1070
|
-
});
|
|
1071
|
-
} else {
|
|
1072
|
-
(0, _unset2.default)(data, responseDataPath);
|
|
1073
|
-
}
|
|
1074
|
-
}
|
|
1075
|
-
}
|
|
1076
|
-
}
|
|
1077
|
-
|
|
1078
|
-
_setResponseChunksAwaitingCaching(normalizedResponseData, context) {
|
|
1079
|
-
const responseChunks = this._responseChunksAwaitingCaching.get(context.requestID);
|
|
1080
|
-
|
|
1081
|
-
if (responseChunks) {
|
|
1082
|
-
this._responseChunksAwaitingCaching.set(context.requestID, [...responseChunks, normalizedResponseData]);
|
|
1083
|
-
} else {
|
|
1084
|
-
this._responseChunksAwaitingCaching.set(context.requestID, [normalizedResponseData]);
|
|
1085
|
-
}
|
|
1086
|
-
}
|
|
1087
|
-
|
|
1088
|
-
}, ((0, _applyDecoratedDescriptor2.default)(_class.prototype, "_getCacheEntry", [_dec], Object.getOwnPropertyDescriptor(_class.prototype, "_getCacheEntry"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "_setCacheEntry", [_dec2], Object.getOwnPropertyDescriptor(_class.prototype, "_setCacheEntry"), _class.prototype), (0, _applyDecoratedDescriptor2.default)(_class.prototype, "_setPartialQueryResponse", [_dec3], Object.getOwnPropertyDescriptor(_class.prototype, "_setPartialQueryResponse"), _class.prototype)), _class));
|
|
1089
|
-
exports.default = CacheManager;
|
|
1090
|
-
//# sourceMappingURL=index.js.map
|