@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/src/constants.ts
ADDED
package/src/debug/index.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
1
|
+
export * from './logCacheEntry.ts';
|
|
2
|
+
export * from './logCacheQuery.ts';
|
|
3
|
+
export * from './logPartialCompiled.ts';
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { CACHE_ENTRY_ADDED, type CacheTypes, type CachemapOptions, type RequestOptions } from '@graphql-box/core';
|
|
2
|
+
import type { CacheManagerContext, CacheManagerDef } from '../types.ts';
|
|
3
|
+
|
|
4
|
+
type Descriptor = (
|
|
5
|
+
cacheType: CacheTypes,
|
|
6
|
+
hash: string,
|
|
7
|
+
value: unknown,
|
|
8
|
+
cachemapOptions: CachemapOptions,
|
|
9
|
+
options: RequestOptions,
|
|
10
|
+
context: CacheManagerContext & { requestFieldCacheKey?: string }
|
|
11
|
+
) => Promise<void>;
|
|
12
|
+
|
|
13
|
+
export const logCacheEntry = () => {
|
|
14
|
+
return (_target: CacheManagerDef, _propertyName: string, descriptor: TypedPropertyDescriptor<Descriptor>): void => {
|
|
15
|
+
const method = descriptor.value;
|
|
16
|
+
|
|
17
|
+
if (!method) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
descriptor.value = async function descriptorValue(...args: Parameters<Descriptor>): ReturnType<Descriptor> {
|
|
22
|
+
return new Promise<void>(resolve => {
|
|
23
|
+
void (async () => {
|
|
24
|
+
const { debugManager, requestFieldCacheKey, ...otherContext } = args[5];
|
|
25
|
+
|
|
26
|
+
if (!debugManager) {
|
|
27
|
+
await method.apply(this, args);
|
|
28
|
+
resolve();
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const startTime = debugManager.now();
|
|
33
|
+
await method.apply(this, args);
|
|
34
|
+
const endTime = debugManager.now();
|
|
35
|
+
const duration = endTime - startTime;
|
|
36
|
+
resolve();
|
|
37
|
+
|
|
38
|
+
const payload = {
|
|
39
|
+
cacheType: args[0],
|
|
40
|
+
cachemapOptions: args[3],
|
|
41
|
+
context: otherContext,
|
|
42
|
+
options: args[4],
|
|
43
|
+
requestHash: args[1],
|
|
44
|
+
stats: { duration, endTime, startTime },
|
|
45
|
+
value: args[2],
|
|
46
|
+
...(requestFieldCacheKey ? { decryptedCacheKey: requestFieldCacheKey } : {}),
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
debugManager.log(CACHE_ENTRY_ADDED, payload);
|
|
50
|
+
})();
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
};
|
|
@@ -1,20 +1,25 @@
|
|
|
1
|
-
import { CACHE_ENTRY_QUERIED,
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { CACHE_ENTRY_QUERIED, type CacheTypes, type RequestOptions } from '@graphql-box/core';
|
|
2
|
+
import type { CacheManagerContext, CacheManagerDef } from '../types.ts';
|
|
3
|
+
|
|
4
|
+
type Descriptor = (
|
|
5
|
+
cacheType: CacheTypes,
|
|
6
|
+
hash: string,
|
|
7
|
+
options: RequestOptions,
|
|
8
|
+
context: CacheManagerContext & { requestFieldCacheKey?: string }
|
|
9
|
+
) => Promise<never | undefined>;
|
|
10
|
+
|
|
11
|
+
export const logCacheQuery = () => {
|
|
12
|
+
return (_target: CacheManagerDef, _propertyName: string, descriptor: TypedPropertyDescriptor<Descriptor>): void => {
|
|
9
13
|
const method = descriptor.value;
|
|
10
|
-
if (!method) return;
|
|
11
14
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
if (!method) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
descriptor.value = async function descriptorValue(...args: Parameters<Descriptor>): ReturnType<Descriptor> {
|
|
20
|
+
return new Promise(resolve => {
|
|
21
|
+
void (async () => {
|
|
22
|
+
const { debugManager, requestFieldCacheKey, ...otherContext } = args[3];
|
|
18
23
|
|
|
19
24
|
if (!debugManager) {
|
|
20
25
|
resolve(await method.apply(this, args));
|
|
@@ -38,10 +43,8 @@ export default function logCacheQuery() {
|
|
|
38
43
|
};
|
|
39
44
|
|
|
40
45
|
debugManager.log(CACHE_ENTRY_QUERIED, payload);
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
return Promise.reject(error);
|
|
44
|
-
}
|
|
46
|
+
})();
|
|
47
|
+
});
|
|
45
48
|
};
|
|
46
49
|
};
|
|
47
|
-
}
|
|
50
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { PARTIAL_QUERY_COMPILED, type RequestOptions } from '@graphql-box/core';
|
|
2
|
+
import type { CacheManagerContext, CacheManagerDef, PartialQueryResponse } from '../types.ts';
|
|
3
|
+
|
|
4
|
+
type Descriptor = (
|
|
5
|
+
hash: string,
|
|
6
|
+
partialQueryResponse: PartialQueryResponse,
|
|
7
|
+
options: RequestOptions,
|
|
8
|
+
context: CacheManagerContext
|
|
9
|
+
) => void;
|
|
10
|
+
|
|
11
|
+
export const logPartialCompiled = () => {
|
|
12
|
+
return (_target: CacheManagerDef, _propertyName: string, descriptor: TypedPropertyDescriptor<Descriptor>): void => {
|
|
13
|
+
const method = descriptor.value;
|
|
14
|
+
|
|
15
|
+
if (!method) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
descriptor.value = function descriptorValue(...args: Parameters<Descriptor>): ReturnType<Descriptor> {
|
|
20
|
+
const { debugManager, ...otherContext } = args[3];
|
|
21
|
+
|
|
22
|
+
if (!debugManager) {
|
|
23
|
+
method.apply(this, args);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const startTime = debugManager.now();
|
|
28
|
+
method.apply(this, args);
|
|
29
|
+
const endTime = debugManager.now();
|
|
30
|
+
const duration = endTime - startTime;
|
|
31
|
+
|
|
32
|
+
debugManager.log(PARTIAL_QUERY_COMPILED, {
|
|
33
|
+
context: otherContext,
|
|
34
|
+
options: args[2],
|
|
35
|
+
requestHash: args[0],
|
|
36
|
+
result: args[1],
|
|
37
|
+
stats: { duration, endTime, startTime },
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { isArray, isPlainObject } from
|
|
1
|
+
import type { PlainData } from '@graphql-box/core';
|
|
2
|
+
import { isArray, isPlainObject } from '@graphql-box/helpers';
|
|
3
|
+
import { isNumber, isString } from 'lodash-es';
|
|
3
4
|
|
|
4
|
-
const checkValue = (value:
|
|
5
|
+
const checkValue = (value: unknown, typeIDKey: string): boolean => {
|
|
5
6
|
if (isArray(value)) {
|
|
6
|
-
return value.reduce((
|
|
7
|
-
if (!
|
|
7
|
+
return value.reduce<boolean>((acc, entry) => {
|
|
8
|
+
if (!acc) {
|
|
8
9
|
return false;
|
|
9
10
|
}
|
|
10
11
|
|
|
@@ -19,22 +20,28 @@ const checkValue = (value: any, typeIDKey: string): boolean => {
|
|
|
19
20
|
return false;
|
|
20
21
|
};
|
|
21
22
|
|
|
22
|
-
const recursivelyCheckProps = (data:
|
|
23
|
-
const keys = Object.keys(data);
|
|
23
|
+
const recursivelyCheckProps = (data: PlainData, typeIDKey: string): boolean => {
|
|
24
|
+
const keys = isPlainObject(data) ? Object.keys(data) : [...data.keys()];
|
|
24
25
|
|
|
25
|
-
if (keys.length === 1 && !!data[typeIDKey]) {
|
|
26
|
+
if (keys.length === 1 && isPlainObject(data) && !!data[typeIDKey]) {
|
|
26
27
|
return true;
|
|
27
28
|
}
|
|
28
29
|
|
|
29
|
-
return keys.reduce((
|
|
30
|
-
if (!
|
|
30
|
+
return keys.reduce<boolean>((acc, key) => {
|
|
31
|
+
if (!acc) {
|
|
31
32
|
return false;
|
|
32
33
|
}
|
|
33
34
|
|
|
34
|
-
|
|
35
|
+
if (isNumber(key) && isArray(data)) {
|
|
36
|
+
return checkValue(data[key], typeIDKey);
|
|
37
|
+
} else if (isString(key) && isPlainObject(data)) {
|
|
38
|
+
return checkValue(data[key], typeIDKey);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return acc;
|
|
35
42
|
}, true);
|
|
36
43
|
};
|
|
37
44
|
|
|
38
|
-
export
|
|
45
|
+
export const areOnlyPopulatedFieldsTypeIdKeys = (data: PlainData, typeIDKey: string) => {
|
|
39
46
|
return recursivelyCheckProps(data, typeIDKey);
|
|
40
47
|
};
|
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
import { CheckFieldPathChecklistResult, FieldPathChecklistValue } from
|
|
1
|
+
import { type CheckFieldPathChecklistResult, type FieldPathChecklistValue } from '../types.ts';
|
|
2
2
|
|
|
3
|
-
export
|
|
3
|
+
export const checkFieldPathChecklist = (
|
|
4
4
|
fieldPathChecklistValues: FieldPathChecklistValue[] | undefined,
|
|
5
|
-
fieldTypeName: string | undefined
|
|
5
|
+
fieldTypeName: string | undefined
|
|
6
6
|
): CheckFieldPathChecklistResult => {
|
|
7
|
-
if (!fieldPathChecklistValues ||
|
|
7
|
+
if (!fieldPathChecklistValues || fieldPathChecklistValues.length === 0) {
|
|
8
8
|
return { hasData: false, typeUnused: !!fieldTypeName };
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
const [fieldPathChecklistValue] = fieldPathChecklistValues;
|
|
12
|
+
|
|
13
|
+
if (fieldPathChecklistValue) {
|
|
14
|
+
const { hasData, typeName } = fieldPathChecklistValue;
|
|
15
|
+
const typeUnused = typeName ? typeName !== fieldTypeName : undefined;
|
|
14
16
|
return { hasData, typeUnused };
|
|
15
17
|
}
|
|
16
18
|
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { isObjectLike } from '@graphql-box/helpers';
|
|
2
|
+
import { mergeDataSets } from './mergeObjects.ts';
|
|
3
|
+
|
|
4
|
+
export const combineDataSets = (dataSetA: unknown, dataSetB: unknown, typeIDKey: string) => {
|
|
5
|
+
if (!dataSetA && dataSetB) {
|
|
6
|
+
return dataSetB;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
if (isObjectLike(dataSetA) && isObjectLike(dataSetB)) {
|
|
10
|
+
return mergeDataSets(dataSetA, dataSetB, typeIDKey);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return dataSetA;
|
|
14
|
+
};
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import { RequestData } from
|
|
2
|
-
import { keys } from
|
|
3
|
-
import { CacheManagerContext } from
|
|
1
|
+
import { type RequestData } from '@graphql-box/core';
|
|
2
|
+
import { keys } from 'lodash-es';
|
|
3
|
+
import { type CacheManagerContext } from '../types.ts';
|
|
4
4
|
|
|
5
|
-
export type FragmentSpreadCheckist =
|
|
6
|
-
|
|
5
|
+
export type FragmentSpreadCheckist = Record<
|
|
6
|
+
string,
|
|
7
|
+
{
|
|
7
8
|
deleted: number;
|
|
8
9
|
paths: string[];
|
|
9
10
|
total: number;
|
|
10
|
-
}
|
|
11
|
-
|
|
11
|
+
}
|
|
12
|
+
>;
|
|
12
13
|
|
|
13
|
-
export
|
|
14
|
-
keys(fragmentDefinitions ?? {}).reduce((acc
|
|
15
|
-
acc[name] = { deleted: 0, paths: [], total: (request.match(new RegExp(`\\.\\.\\.${name}`,
|
|
14
|
+
export const createFragmentSpreadChecklist = ({ request }: RequestData, { fragmentDefinitions }: CacheManagerContext) =>
|
|
15
|
+
keys(fragmentDefinitions ?? {}).reduce<FragmentSpreadCheckist>((acc, name) => {
|
|
16
|
+
acc[name] = { deleted: 0, paths: [], total: (request.match(new RegExp(`\\.\\.\\.${name}`, 'g')) ?? []).length };
|
|
16
17
|
return acc;
|
|
17
18
|
}, {});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { DehydratedCacheMetadata } from
|
|
2
|
-
import Cacheability from
|
|
3
|
-
import { isEmpty } from
|
|
4
|
-
import { HEADER_CACHE_CONTROL } from
|
|
1
|
+
import { type DehydratedCacheMetadata } from '@graphql-box/core';
|
|
2
|
+
import { Cacheability } from 'cacheability';
|
|
3
|
+
import { isEmpty } from 'lodash-es';
|
|
4
|
+
import { HEADER_CACHE_CONTROL } from '../constants.ts';
|
|
5
5
|
|
|
6
6
|
export type Params = {
|
|
7
7
|
_cacheMetadata?: DehydratedCacheMetadata;
|
|
@@ -9,12 +9,16 @@ export type Params = {
|
|
|
9
9
|
headers?: Headers;
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
-
export
|
|
12
|
+
export const deriveOpCacheability = ({ _cacheMetadata, fallback, headers }: Params): Cacheability => {
|
|
13
13
|
if (_cacheMetadata && !isEmpty(_cacheMetadata)) {
|
|
14
14
|
const [first, ...rest] = Object.values(_cacheMetadata);
|
|
15
15
|
|
|
16
16
|
return new Cacheability({
|
|
17
17
|
metadata: rest.reduce((acc, metadata) => {
|
|
18
|
+
if (!acc) {
|
|
19
|
+
return metadata;
|
|
20
|
+
}
|
|
21
|
+
|
|
18
22
|
if (metadata.ttl < acc.ttl) {
|
|
19
23
|
return metadata;
|
|
20
24
|
}
|
|
@@ -24,7 +28,7 @@ export default ({ _cacheMetadata, fallback, headers }: Params): Cacheability =>
|
|
|
24
28
|
});
|
|
25
29
|
}
|
|
26
30
|
|
|
27
|
-
if (headers
|
|
31
|
+
if (headers?.has(HEADER_CACHE_CONTROL)) {
|
|
28
32
|
return new Cacheability({ headers });
|
|
29
33
|
}
|
|
30
34
|
|
|
@@ -1,26 +1,25 @@
|
|
|
1
|
-
import { TYPE_NAME_KEY } from
|
|
1
|
+
import { TYPE_NAME_KEY } from '@graphql-box/core';
|
|
2
2
|
import {
|
|
3
|
-
FRAGMENT_SPREAD,
|
|
4
3
|
buildFieldKeysAndPaths,
|
|
5
4
|
deleteChildFields,
|
|
6
5
|
getChildFields,
|
|
7
6
|
getName,
|
|
8
7
|
hasChildFields,
|
|
9
|
-
} from
|
|
10
|
-
import { FieldNode, FragmentDefinitionNode, OperationDefinitionNode } from
|
|
11
|
-
import { CacheManagerContext, FieldPathChecklist, FragmentSpreadFieldCounter } from
|
|
12
|
-
import checkFieldPathChecklist from
|
|
13
|
-
import { FragmentSpreadCheckist } from
|
|
14
|
-
import filterFragmentSpreads from
|
|
15
|
-
import filterIDsAndTypeNames from
|
|
16
|
-
import filterInlineFragments from
|
|
8
|
+
} from '@graphql-box/helpers';
|
|
9
|
+
import { type FieldNode, type FragmentDefinitionNode, Kind, type OperationDefinitionNode } from 'graphql';
|
|
10
|
+
import { type CacheManagerContext, type FieldPathChecklist, type FragmentSpreadFieldCounter } from '../types.ts';
|
|
11
|
+
import { checkFieldPathChecklist } from './checkFieldPathChecklist.ts';
|
|
12
|
+
import { type FragmentSpreadCheckist } from './createFragmentSpreadChecklist.ts';
|
|
13
|
+
import { filterFragmentSpreads } from './filterFragmentSpreads.ts';
|
|
14
|
+
import { filterIDsAndTypeNames } from './filterIDsAndTypeNames.ts';
|
|
15
|
+
import { filterInlineFragments } from './filterInlineFragments.ts';
|
|
17
16
|
|
|
18
|
-
const filterField = (
|
|
17
|
+
export const filterField = (
|
|
19
18
|
field: FieldNode | FragmentDefinitionNode | OperationDefinitionNode,
|
|
20
19
|
fieldPathChecklist: FieldPathChecklist,
|
|
21
20
|
fragmentSpreadChecklist: FragmentSpreadCheckist,
|
|
22
21
|
ancestorRequestFieldPath: string,
|
|
23
|
-
context: CacheManagerContext
|
|
22
|
+
context: CacheManagerContext
|
|
24
23
|
): boolean => {
|
|
25
24
|
const { fragmentDefinitions, typeIDKey } = context;
|
|
26
25
|
const fieldsAndTypeNames = getChildFields(field, { fragmentDefinitions });
|
|
@@ -31,14 +30,20 @@ const filterField = (
|
|
|
31
30
|
|
|
32
31
|
const fragmentSpreadFieldCounter: FragmentSpreadFieldCounter = {};
|
|
33
32
|
|
|
34
|
-
for (let
|
|
35
|
-
const
|
|
33
|
+
for (let index = fieldsAndTypeNames.length - 1; index >= 0; index -= 1) {
|
|
34
|
+
const fieldAndTypeName = fieldsAndTypeNames[index];
|
|
36
35
|
|
|
37
|
-
if (
|
|
36
|
+
if (!fieldAndTypeName) {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const { fieldNode: childField, fragmentKind, fragmentName, typeName: childTypeName } = fieldAndTypeName;
|
|
41
|
+
|
|
42
|
+
if (fragmentKind === Kind.FRAGMENT_SPREAD && fragmentName && !fragmentSpreadFieldCounter[fragmentName]) {
|
|
38
43
|
fragmentSpreadFieldCounter[fragmentName] = {
|
|
39
44
|
hasData: 0,
|
|
40
45
|
total: fragmentDefinitions?.[fragmentName]
|
|
41
|
-
? getChildFields(fragmentDefinitions
|
|
46
|
+
? getChildFields(fragmentDefinitions[fragmentName]!, { fragmentDefinitions })?.length ?? 0
|
|
42
47
|
: 0,
|
|
43
48
|
};
|
|
44
49
|
}
|
|
@@ -54,14 +59,18 @@ const filterField = (
|
|
|
54
59
|
{
|
|
55
60
|
requestFieldPath: ancestorRequestFieldPath,
|
|
56
61
|
},
|
|
57
|
-
context
|
|
62
|
+
context
|
|
58
63
|
);
|
|
59
64
|
|
|
60
65
|
const { hasData, typeUnused } = checkFieldPathChecklist(fieldPathChecklist.get(requestFieldPath), childTypeName);
|
|
61
66
|
|
|
62
67
|
if (hasData || typeUnused) {
|
|
63
|
-
if (fragmentKind === FRAGMENT_SPREAD) {
|
|
64
|
-
fragmentSpreadFieldCounter[fragmentName
|
|
68
|
+
if (fragmentKind === Kind.FRAGMENT_SPREAD && fragmentName) {
|
|
69
|
+
const counter = fragmentSpreadFieldCounter[fragmentName];
|
|
70
|
+
|
|
71
|
+
if (counter) {
|
|
72
|
+
counter.hasData += 1;
|
|
73
|
+
}
|
|
65
74
|
} else if (!hasChildFields(childField, { fragmentDefinitions })) {
|
|
66
75
|
deleteChildFields(field, childField);
|
|
67
76
|
} else if (filterField(childField, fieldPathChecklist, fragmentSpreadChecklist, requestFieldPath, context)) {
|
|
@@ -75,5 +84,3 @@ const filterField = (
|
|
|
75
84
|
filterIDsAndTypeNames(field, context);
|
|
76
85
|
return !hasChildFields(field, { fragmentDefinitions });
|
|
77
86
|
};
|
|
78
|
-
|
|
79
|
-
export default filterField;
|
|
@@ -1,40 +1,54 @@
|
|
|
1
|
-
import { deleteFragmentDefinitions } from
|
|
2
|
-
import { DocumentNode } from
|
|
3
|
-
import { keys } from
|
|
4
|
-
import { CacheManagerContext, FieldPathChecklist } from
|
|
5
|
-
import { FragmentSpreadCheckist } from
|
|
6
|
-
import filterField from
|
|
7
|
-
|
|
8
|
-
export
|
|
1
|
+
import { deleteFragmentDefinitions } from '@graphql-box/helpers';
|
|
2
|
+
import { type DocumentNode } from 'graphql';
|
|
3
|
+
import { keys } from 'lodash-es';
|
|
4
|
+
import { type CacheManagerContext, type FieldPathChecklist } from '../types.ts';
|
|
5
|
+
import { type FragmentSpreadCheckist } from './createFragmentSpreadChecklist.ts';
|
|
6
|
+
import { filterField } from './filterField.ts';
|
|
7
|
+
|
|
8
|
+
export const filterFragmentDefinitions = (
|
|
9
9
|
ast: DocumentNode,
|
|
10
10
|
fieldPathChecklist: FieldPathChecklist,
|
|
11
11
|
fragmentSpreadChecklist: FragmentSpreadCheckist,
|
|
12
|
-
context: CacheManagerContext
|
|
12
|
+
context: CacheManagerContext
|
|
13
13
|
) => {
|
|
14
|
-
const definitionsToFilter = keys(fragmentSpreadChecklist).reduce(
|
|
15
|
-
(namesAndPaths
|
|
16
|
-
const
|
|
14
|
+
const definitionsToFilter = keys(fragmentSpreadChecklist).reduce<{ name: string; path: string }[]>(
|
|
15
|
+
(namesAndPaths, key) => {
|
|
16
|
+
const checklist = fragmentSpreadChecklist[key];
|
|
17
|
+
|
|
18
|
+
if (!checklist) {
|
|
19
|
+
return namesAndPaths;
|
|
20
|
+
}
|
|
17
21
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
: namesAndPaths;
|
|
22
|
+
const { deleted, paths, total } = checklist;
|
|
23
|
+
return deleted === 0 && total === 1 ? [...namesAndPaths, { name: key, path: paths[0]! }] : namesAndPaths;
|
|
21
24
|
},
|
|
22
|
-
[]
|
|
25
|
+
[]
|
|
23
26
|
);
|
|
24
27
|
|
|
25
28
|
const { fragmentDefinitions = {} } = context;
|
|
26
29
|
|
|
27
|
-
|
|
30
|
+
for (const { name, path } of definitionsToFilter) {
|
|
28
31
|
const fragmentDefinition = fragmentDefinitions[name];
|
|
32
|
+
|
|
33
|
+
if (!fragmentDefinition) {
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
|
|
29
37
|
filterField(fragmentDefinition, fieldPathChecklist, fragmentSpreadChecklist, path, context);
|
|
30
|
-
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const definitionsToDelete = keys(fragmentSpreadChecklist).reduce<string[]>((names, key) => {
|
|
41
|
+
const checklist = fragmentSpreadChecklist[key];
|
|
42
|
+
|
|
43
|
+
if (!checklist) {
|
|
44
|
+
return names;
|
|
45
|
+
}
|
|
31
46
|
|
|
32
|
-
|
|
33
|
-
const { deleted, total } = fragmentSpreadChecklist[key];
|
|
47
|
+
const { deleted, total } = checklist;
|
|
34
48
|
return deleted > 0 && deleted === total ? [...names, key] : names;
|
|
35
49
|
}, []);
|
|
36
50
|
|
|
37
|
-
if (
|
|
51
|
+
if (definitionsToDelete.length === 0) {
|
|
38
52
|
return ast;
|
|
39
53
|
}
|
|
40
54
|
|
|
@@ -1,27 +1,32 @@
|
|
|
1
|
-
import { deleteFragmentSpreads } from
|
|
2
|
-
import { FieldNode, FragmentDefinitionNode, OperationDefinitionNode } from
|
|
3
|
-
import { isEmpty
|
|
4
|
-
import { FragmentSpreadFieldCounter } from
|
|
5
|
-
import { FragmentSpreadCheckist } from
|
|
1
|
+
import { deleteFragmentSpreads } from '@graphql-box/helpers';
|
|
2
|
+
import { type FieldNode, type FragmentDefinitionNode, type OperationDefinitionNode } from 'graphql';
|
|
3
|
+
import { isEmpty } from 'lodash-es';
|
|
4
|
+
import { type FragmentSpreadFieldCounter } from '../types.ts';
|
|
5
|
+
import { type FragmentSpreadCheckist } from './createFragmentSpreadChecklist.ts';
|
|
6
6
|
|
|
7
|
-
export
|
|
7
|
+
export const filterFragmentSpreads = (
|
|
8
8
|
field: FieldNode | FragmentDefinitionNode | OperationDefinitionNode,
|
|
9
9
|
fragmentSpreadFieldCounter: FragmentSpreadFieldCounter,
|
|
10
10
|
fragmentSpreadChecklist: FragmentSpreadCheckist,
|
|
11
|
-
ancestorRequestFieldPath: string
|
|
11
|
+
ancestorRequestFieldPath: string
|
|
12
12
|
) => {
|
|
13
13
|
if (isEmpty(fragmentSpreadFieldCounter)) {
|
|
14
14
|
return;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
keys(fragmentSpreadFieldCounter)
|
|
18
|
-
fragmentSpreadChecklist[key]
|
|
17
|
+
for (const key of Object.keys(fragmentSpreadFieldCounter)) {
|
|
18
|
+
const checklist = fragmentSpreadChecklist[key];
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
if (!checklist) {
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
checklist.paths.push(ancestorRequestFieldPath);
|
|
25
|
+
const { hasData, total } = fragmentSpreadFieldCounter[key]!;
|
|
21
26
|
|
|
22
27
|
if (hasData === total) {
|
|
23
28
|
deleteFragmentSpreads(field, key);
|
|
24
|
-
|
|
29
|
+
checklist.deleted += 1;
|
|
25
30
|
}
|
|
26
|
-
}
|
|
31
|
+
}
|
|
27
32
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { TYPE_NAME_KEY } from
|
|
2
|
-
import { deleteChildFields, getChildFields, getName } from
|
|
3
|
-
import { FieldNode, FragmentDefinitionNode, OperationDefinitionNode } from
|
|
4
|
-
import { CacheManagerContext } from
|
|
1
|
+
import { TYPE_NAME_KEY } from '@graphql-box/core';
|
|
2
|
+
import { deleteChildFields, getChildFields, getName } from '@graphql-box/helpers';
|
|
3
|
+
import { type FieldNode, type FragmentDefinitionNode, type OperationDefinitionNode } from 'graphql';
|
|
4
|
+
import { type CacheManagerContext } from '../types.ts';
|
|
5
5
|
|
|
6
|
-
export
|
|
6
|
+
export const filterIDsAndTypeNames = (
|
|
7
7
|
field: FieldNode | FragmentDefinitionNode | OperationDefinitionNode,
|
|
8
|
-
{ fragmentDefinitions, typeIDKey }: CacheManagerContext
|
|
8
|
+
{ fragmentDefinitions, typeIDKey }: CacheManagerContext
|
|
9
9
|
) => {
|
|
10
10
|
const fieldsAndTypeNames = getChildFields(field, { fragmentDefinitions });
|
|
11
11
|
|
|
@@ -13,21 +13,25 @@ export default (
|
|
|
13
13
|
return false;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
const fieldNames = fieldsAndTypeNames.map(({ fieldNode }) => getName(fieldNode)
|
|
16
|
+
const fieldNames = fieldsAndTypeNames.map(({ fieldNode }) => getName(fieldNode)!);
|
|
17
17
|
|
|
18
18
|
if (fieldNames.length === 2 && fieldNames.every(name => name === typeIDKey || name === TYPE_NAME_KEY)) {
|
|
19
19
|
deleteChildFields(
|
|
20
20
|
field,
|
|
21
|
-
fieldsAndTypeNames.map(({ fieldNode }) => fieldNode)
|
|
21
|
+
fieldsAndTypeNames.map(({ fieldNode }) => fieldNode)
|
|
22
22
|
);
|
|
23
23
|
|
|
24
24
|
return true;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
if ((fieldNames.length === 1 && fieldNames[0] === typeIDKey) || fieldNames[0] === TYPE_NAME_KEY) {
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
const [fieldAndTypeName] = fieldsAndTypeNames;
|
|
29
|
+
|
|
30
|
+
if (fieldAndTypeName) {
|
|
31
|
+
const { fieldNode } = fieldAndTypeName;
|
|
32
|
+
deleteChildFields(field, fieldNode);
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
31
35
|
}
|
|
32
36
|
|
|
33
37
|
return false;
|
|
@@ -1,32 +1,34 @@
|
|
|
1
|
-
import { deleteInlineFragments, getChildFields, getInlineFragments, getName } from
|
|
2
|
-
import { FieldNode, FragmentDefinitionNode, OperationDefinitionNode } from
|
|
3
|
-
import { CacheManagerContext } from
|
|
1
|
+
import { deleteInlineFragments, getChildFields, getInlineFragments, getName } from '@graphql-box/helpers';
|
|
2
|
+
import { type FieldNode, type FragmentDefinitionNode, type OperationDefinitionNode } from 'graphql';
|
|
3
|
+
import { type CacheManagerContext } from '../types.ts';
|
|
4
4
|
|
|
5
|
-
export
|
|
5
|
+
export const filterInlineFragments = (
|
|
6
6
|
field: FieldNode | FragmentDefinitionNode | OperationDefinitionNode,
|
|
7
|
-
{ fragmentDefinitions, typeIDKey }: CacheManagerContext
|
|
7
|
+
{ fragmentDefinitions, typeIDKey }: CacheManagerContext
|
|
8
8
|
) => {
|
|
9
9
|
const inlineFragments = getInlineFragments(field);
|
|
10
10
|
let filtered = false;
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
for (const fragment of inlineFragments) {
|
|
13
13
|
const fieldsAndTypeNames = getChildFields(fragment, { fragmentDefinitions });
|
|
14
14
|
|
|
15
|
-
if (!fieldsAndTypeNames ||
|
|
15
|
+
if (!fieldsAndTypeNames || fieldsAndTypeNames.length === 0) {
|
|
16
16
|
deleteInlineFragments(field, fragment);
|
|
17
17
|
filtered = true;
|
|
18
|
-
|
|
18
|
+
continue;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
const [fieldAndTypeName] = fieldsAndTypeNames;
|
|
22
|
+
|
|
23
|
+
if (fieldAndTypeName) {
|
|
24
|
+
const { fieldNode } = fieldAndTypeName;
|
|
23
25
|
|
|
24
26
|
if (getName(fieldNode) === typeIDKey) {
|
|
25
27
|
deleteInlineFragments(field, fragment);
|
|
26
28
|
filtered = true;
|
|
27
29
|
}
|
|
28
30
|
}
|
|
29
|
-
}
|
|
31
|
+
}
|
|
30
32
|
|
|
31
33
|
return filtered;
|
|
32
34
|
};
|