@graphitation/apollo-react-relay-duct-tape 1.0.28 → 1.0.30
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/.eslintcache +1 -1
- package/CHANGELOG.md +18 -2
- package/README.md +43 -14
- package/lib/storeObservation/compiledHooks/useCompiledFragment.d.ts.map +1 -1
- package/lib/storeObservation/compiledHooks/useCompiledFragment.js +25 -3
- package/lib/storeObservation/compiledHooks/useCompiledFragment.js.map +2 -2
- package/lib/storeObservation/compiledHooks/useCompiledFragment.mjs +25 -3
- package/lib/storeObservation/compiledHooks/useCompiledFragment.mjs.map +2 -2
- package/lib/storeObservation/compiledHooks/useCompiledPaginationFragment.d.ts.map +1 -1
- package/lib/storeObservation/compiledHooks/useCompiledPaginationFragment.js +13 -2
- package/lib/storeObservation/compiledHooks/useCompiledPaginationFragment.js.map +2 -2
- package/lib/storeObservation/compiledHooks/useCompiledPaginationFragment.mjs +14 -3
- package/lib/storeObservation/compiledHooks/useCompiledPaginationFragment.mjs.map +2 -2
- package/package.json +1 -1
package/.eslintcache
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
[{"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/__tests__/hooks.test.tsx":"1","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/__tests__/useOverridenOrDefaultApolloClient.test.tsx":"2","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/convertFetchPolicy.ts":"3","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/hooks.ts":"4","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/index.ts":"5","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/__tests__/compiledHooks.test.tsx":"6","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/__tests__/fragmentReferencesFieldPolicy.test.ts":"7","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/__tests__/getPossibleTypesAndDataIdFromNode.test.ts":"8","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/__tests__/nodeFromCacheFieldPolicy.test.ts":"9","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/compiledHooks/index.ts":"10","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/compiledHooks/types.ts":"11","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/compiledHooks/useCompiledFragment.ts":"12","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/compiledHooks/useCompiledLazyLoadQuery.ts":"13","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/compiledHooks/useCompiledPaginationFragment.ts":"14","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/compiledHooks/useCompiledRefetchableFragment.ts":"15","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/compiledHooks/useDeepCompareMemoize.ts":"16","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/compiledHooks/useForceUpdate.ts":"17","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/fragmentReferencesFieldPolicy.ts":"18","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/getPossibleTypesAndDataIdFromNode.ts":"19","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/index.ts":"20","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/nodeFromCacheFieldPolicy.ts":"21","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/shallowCompareFragmentReferences.ts":"22","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/typePolicies.ts":"23","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/types.ts":"24","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/useOverridenOrDefaultApolloClient.ts":"25"},{"size":11195,"mtime":1705378760997,"results":"26","hashOfConfig":"27"},{"size":1917,"mtime":1705378760997,"results":"28","hashOfConfig":"27"},{"size":690,"mtime":1705378760997,"results":"29","hashOfConfig":"27"},{"size":12265,"mtime":1705378760997,"results":"30","hashOfConfig":"27"},{"size":174,"mtime":1705378760997,"results":"31","hashOfConfig":"27"},{"size":33980,"mtime":1705378761001,"results":"32","hashOfConfig":"27"},{"size":1839,"mtime":1705378761001,"results":"33","hashOfConfig":"27"},{"size":1709,"mtime":1705378761001,"results":"34","hashOfConfig":"27"},{"size":3041,"mtime":1705378761001,"results":"35","hashOfConfig":"27"},{"size":445,"mtime":1705378761001,"results":"36","hashOfConfig":"27"},{"size":575,"mtime":1705378761001,"results":"37","hashOfConfig":"27"},{"size":2426,"mtime":1705378761001,"results":"38","hashOfConfig":"27"},{"size":3662,"mtime":1705378761001,"results":"39","hashOfConfig":"27"},{"size":9406,"mtime":1705378761001,"results":"40","hashOfConfig":"27"},{"size":5414,"mtime":1705378761001,"results":"41","hashOfConfig":"27"},{"size":843,"mtime":1705378761001,"results":"42","hashOfConfig":"27"},{"size":152,"mtime":1705378761001,"results":"43","hashOfConfig":"27"},{"size":286,"mtime":1705378761001,"results":"44","hashOfConfig":"27"},{"size":1243,"mtime":1705378761001,"results":"45","hashOfConfig":"27"},{"size":230,"mtime":1705378761001,"results":"46","hashOfConfig":"27"},{"size":2829,"mtime":1705378761001,"results":"47","hashOfConfig":"27"},{"size":2322,"mtime":1705378761001,"results":"48","hashOfConfig":"27"},{"size":1110,"mtime":1705378761001,"results":"49","hashOfConfig":"27"},{"size":2058,"mtime":1705378761001,"results":"50","hashOfConfig":"27"},{"size":1314,"mtime":1705378761001,"results":"51","hashOfConfig":"27"},{"filePath":"52","messages":"53","suppressedMessages":"54","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"1nrapia",{"filePath":"55","messages":"56","suppressedMessages":"57","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"58","messages":"59","suppressedMessages":"60","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"61","messages":"62","suppressedMessages":"63","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"64","messages":"65","suppressedMessages":"66","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"67","messages":"68","suppressedMessages":"69","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"70","messages":"71","suppressedMessages":"72","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"73","messages":"74","suppressedMessages":"75","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"76","messages":"77","suppressedMessages":"78","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"79","messages":"80","suppressedMessages":"81","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"82","messages":"83","suppressedMessages":"84","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"85","messages":"86","suppressedMessages":"87","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"88","messages":"89","suppressedMessages":"90","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"91","messages":"92","suppressedMessages":"93","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"94","messages":"95","suppressedMessages":"96","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"97","messages":"98","suppressedMessages":"99","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"100","messages":"101","suppressedMessages":"102","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"103","messages":"104","suppressedMessages":"105","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"106","messages":"107","suppressedMessages":"108","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"109","messages":"110","suppressedMessages":"111","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"112","messages":"113","suppressedMessages":"114","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"115","messages":"116","suppressedMessages":"117","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"118","messages":"119","suppressedMessages":"120","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"121","messages":"122","suppressedMessages":"123","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"124","messages":"125","suppressedMessages":"126","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/__tests__/hooks.test.tsx",[],[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/__tests__/useOverridenOrDefaultApolloClient.test.tsx",[],[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/convertFetchPolicy.ts",[],[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/hooks.ts",[],["127"],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/index.ts",[],[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/__tests__/compiledHooks.test.tsx",[],[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/__tests__/fragmentReferencesFieldPolicy.test.ts",[],[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/__tests__/getPossibleTypesAndDataIdFromNode.test.ts",[],[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/__tests__/nodeFromCacheFieldPolicy.test.ts",[],[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/compiledHooks/index.ts",[],[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/compiledHooks/types.ts",[],["128"],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/compiledHooks/useCompiledFragment.ts",[],[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/compiledHooks/useCompiledLazyLoadQuery.ts",[],["129"],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/compiledHooks/useCompiledPaginationFragment.ts",[],["130","131","132","133","134"],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/compiledHooks/useCompiledRefetchableFragment.ts",[],["135"],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/compiledHooks/useDeepCompareMemoize.ts",[],[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/compiledHooks/useForceUpdate.ts",[],[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/fragmentReferencesFieldPolicy.ts",[],[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/getPossibleTypesAndDataIdFromNode.ts",[],[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/index.ts",[],[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/nodeFromCacheFieldPolicy.ts",[],[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/shallowCompareFragmentReferences.ts",[],[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/typePolicies.ts",[],[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/types.ts",[],["136","137"],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/useOverridenOrDefaultApolloClient.ts",[],["138"],{"ruleId":"139","severity":1,"message":"140","line":319,"column":38,"nodeType":"141","messageId":"142","endLine":319,"endColumn":41,"suggestions":"143","suppressions":"144"},{"ruleId":"139","severity":1,"message":"140","line":16,"column":32,"nodeType":"141","messageId":"142","endLine":16,"endColumn":35,"suggestions":"145","suppressions":"146"},{"ruleId":"139","severity":1,"message":"140","line":87,"column":28,"nodeType":"141","messageId":"142","endLine":87,"endColumn":31,"suggestions":"147","suppressions":"148"},{"ruleId":"139","severity":1,"message":"140","line":165,"column":24,"nodeType":"141","messageId":"142","endLine":165,"endColumn":27,"suggestions":"149","suppressions":"150"},{"ruleId":"139","severity":1,"message":"140","line":168,"column":4,"nodeType":"141","messageId":"142","endLine":168,"endColumn":7,"suggestions":"151","suppressions":"152"},{"ruleId":"139","severity":1,"message":"140","line":170,"column":30,"nodeType":"141","messageId":"142","endLine":170,"endColumn":33,"suggestions":"153","suppressions":"154"},{"ruleId":"139","severity":1,"message":"140","line":180,"column":24,"nodeType":"141","messageId":"142","endLine":180,"endColumn":27,"suggestions":"155","suppressions":"156"},{"ruleId":"139","severity":1,"message":"140","line":216,"column":9,"nodeType":"141","messageId":"142","endLine":216,"endColumn":12,"suggestions":"157","suppressions":"158"},{"ruleId":"139","severity":1,"message":"140","line":38,"column":26,"nodeType":"141","messageId":"142","endLine":38,"endColumn":29,"suggestions":"159","suppressions":"160"},{"ruleId":"139","severity":1,"message":"140","line":5,"column":19,"nodeType":"141","messageId":"142","endLine":5,"endColumn":22,"suggestions":"161","suppressions":"162"},{"ruleId":"139","severity":1,"message":"140","line":10,"column":19,"nodeType":"141","messageId":"142","endLine":10,"endColumn":22,"suggestions":"163","suppressions":"164"},{"ruleId":"139","severity":1,"message":"140","line":17,"column":51,"nodeType":"141","messageId":"142","endLine":17,"endColumn":54,"suggestions":"165","suppressions":"166"},"@typescript-eslint/no-explicit-any","Unexpected any. Specify a different type.","TSAnyKeyword","unexpectedAny",["167","168"],["169"],["170","171"],["172"],["173","174"],["175"],["176","177"],["178"],["179","180"],["181"],["182","183"],["184"],["185","186"],["187"],["188","189"],["190"],["191","192"],["193"],["194","195"],["196"],["197","198"],["199"],["200","201"],["202"],{"messageId":"203","fix":"204","desc":"205"},{"messageId":"206","fix":"207","desc":"208"},{"kind":"209","justification":"210"},{"messageId":"203","fix":"211","desc":"205"},{"messageId":"206","fix":"212","desc":"208"},{"kind":"209","justification":"210"},{"messageId":"203","fix":"213","desc":"205"},{"messageId":"206","fix":"214","desc":"208"},{"kind":"209","justification":"210"},{"messageId":"203","fix":"215","desc":"205"},{"messageId":"206","fix":"216","desc":"208"},{"kind":"209","justification":"210"},{"messageId":"203","fix":"217","desc":"205"},{"messageId":"206","fix":"218","desc":"208"},{"kind":"209","justification":"210"},{"messageId":"203","fix":"219","desc":"205"},{"messageId":"206","fix":"220","desc":"208"},{"kind":"209","justification":"210"},{"messageId":"203","fix":"221","desc":"205"},{"messageId":"206","fix":"222","desc":"208"},{"kind":"209","justification":"210"},{"messageId":"203","fix":"223","desc":"205"},{"messageId":"206","fix":"224","desc":"208"},{"kind":"209","justification":"210"},{"messageId":"203","fix":"225","desc":"205"},{"messageId":"206","fix":"226","desc":"208"},{"kind":"209","justification":"210"},{"messageId":"203","fix":"227","desc":"205"},{"messageId":"206","fix":"228","desc":"208"},{"kind":"209","justification":"210"},{"messageId":"203","fix":"229","desc":"205"},{"messageId":"206","fix":"230","desc":"208"},{"kind":"209","justification":"210"},{"messageId":"203","fix":"231","desc":"205"},{"messageId":"206","fix":"232","desc":"208"},{"kind":"209","justification":"210"},"suggestUnknown",{"range":"233","text":"234"},"Use `unknown` instead, this will force you to explicitly, and safely assert the type is correct.","suggestNever",{"range":"233","text":"235"},"Use `never` instead, this is useful when instantiating generic type parameters that you don't need to know the type of.","directive","",{"range":"236","text":"234"},{"range":"236","text":"235"},{"range":"237","text":"234"},{"range":"237","text":"235"},{"range":"238","text":"234"},{"range":"238","text":"235"},{"range":"239","text":"234"},{"range":"239","text":"235"},{"range":"240","text":"234"},{"range":"240","text":"235"},{"range":"241","text":"234"},{"range":"241","text":"235"},{"range":"242","text":"234"},{"range":"242","text":"235"},{"range":"243","text":"234"},{"range":"243","text":"235"},{"range":"244","text":"234"},{"range":"244","text":"235"},{"range":"245","text":"234"},{"range":"245","text":"235"},{"range":"246","text":"234"},{"range":"246","text":"235"},[11682,11685],"unknown","never",[567,570],[2626,2629],[5546,5549],[5647,5650],[5747,5750],[6036,6039],[7100,7103],[1283,1286],[158,161],[276,279],[455,458]]
|
|
1
|
+
[{"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/__tests__/hooks.test.tsx":"1","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/__tests__/useOverridenOrDefaultApolloClient.test.tsx":"2","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/convertFetchPolicy.ts":"3","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/hooks.ts":"4","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/index.ts":"5","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/__tests__/compiledHooks.test.tsx":"6","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/__tests__/fragmentReferencesFieldPolicy.test.ts":"7","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/__tests__/getPossibleTypesAndDataIdFromNode.test.ts":"8","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/__tests__/nodeFromCacheFieldPolicy.test.ts":"9","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/compiledHooks/index.ts":"10","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/compiledHooks/types.ts":"11","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/compiledHooks/useCompiledFragment.ts":"12","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/compiledHooks/useCompiledLazyLoadQuery.ts":"13","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/compiledHooks/useCompiledPaginationFragment.ts":"14","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/compiledHooks/useCompiledRefetchableFragment.ts":"15","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/compiledHooks/useDeepCompareMemoize.ts":"16","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/compiledHooks/useForceUpdate.ts":"17","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/fragmentReferencesFieldPolicy.ts":"18","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/getPossibleTypesAndDataIdFromNode.ts":"19","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/index.ts":"20","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/nodeFromCacheFieldPolicy.ts":"21","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/shallowCompareFragmentReferences.ts":"22","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/typePolicies.ts":"23","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/types.ts":"24","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/useOverridenOrDefaultApolloClient.ts":"25"},{"size":11195,"mtime":1707241841783,"results":"26","hashOfConfig":"27"},{"size":1917,"mtime":1707241841783,"results":"28","hashOfConfig":"27"},{"size":690,"mtime":1707241841783,"results":"29","hashOfConfig":"27"},{"size":12265,"mtime":1707241841783,"results":"30","hashOfConfig":"27"},{"size":174,"mtime":1707241841783,"results":"31","hashOfConfig":"27"},{"size":37593,"mtime":1707241841787,"results":"32","hashOfConfig":"27"},{"size":1839,"mtime":1707241841787,"results":"33","hashOfConfig":"27"},{"size":1709,"mtime":1707241841787,"results":"34","hashOfConfig":"27"},{"size":3041,"mtime":1707241841787,"results":"35","hashOfConfig":"27"},{"size":445,"mtime":1707241841787,"results":"36","hashOfConfig":"27"},{"size":575,"mtime":1707241841787,"results":"37","hashOfConfig":"27"},{"size":3668,"mtime":1707241841787,"results":"38","hashOfConfig":"27"},{"size":3662,"mtime":1707241841787,"results":"39","hashOfConfig":"27"},{"size":10442,"mtime":1707241841787,"results":"40","hashOfConfig":"27"},{"size":5414,"mtime":1707241841787,"results":"41","hashOfConfig":"27"},{"size":843,"mtime":1707241841787,"results":"42","hashOfConfig":"27"},{"size":152,"mtime":1707241841787,"results":"43","hashOfConfig":"27"},{"size":286,"mtime":1707241841787,"results":"44","hashOfConfig":"27"},{"size":1243,"mtime":1707241841787,"results":"45","hashOfConfig":"27"},{"size":230,"mtime":1707241841787,"results":"46","hashOfConfig":"27"},{"size":2829,"mtime":1707241841787,"results":"47","hashOfConfig":"27"},{"size":2322,"mtime":1707241841787,"results":"48","hashOfConfig":"27"},{"size":1110,"mtime":1707241841787,"results":"49","hashOfConfig":"27"},{"size":2058,"mtime":1707241841787,"results":"50","hashOfConfig":"27"},{"size":1314,"mtime":1707241841787,"results":"51","hashOfConfig":"27"},{"filePath":"52","messages":"53","suppressedMessages":"54","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"1nrapia",{"filePath":"55","messages":"56","suppressedMessages":"57","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"58","messages":"59","suppressedMessages":"60","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"61","messages":"62","suppressedMessages":"63","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"64","messages":"65","suppressedMessages":"66","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"67","messages":"68","suppressedMessages":"69","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"70","messages":"71","suppressedMessages":"72","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"73","messages":"74","suppressedMessages":"75","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"76","messages":"77","suppressedMessages":"78","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"79","messages":"80","suppressedMessages":"81","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"82","messages":"83","suppressedMessages":"84","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"85","messages":"86","suppressedMessages":"87","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"88","messages":"89","suppressedMessages":"90","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"91","messages":"92","suppressedMessages":"93","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"94","messages":"95","suppressedMessages":"96","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"97","messages":"98","suppressedMessages":"99","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"100","messages":"101","suppressedMessages":"102","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"103","messages":"104","suppressedMessages":"105","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"106","messages":"107","suppressedMessages":"108","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"109","messages":"110","suppressedMessages":"111","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"112","messages":"113","suppressedMessages":"114","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"115","messages":"116","suppressedMessages":"117","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"118","messages":"119","suppressedMessages":"120","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"121","messages":"122","suppressedMessages":"123","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"124","messages":"125","suppressedMessages":"126","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/__tests__/hooks.test.tsx",[],[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/__tests__/useOverridenOrDefaultApolloClient.test.tsx",[],[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/convertFetchPolicy.ts",[],[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/hooks.ts",[],["127"],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/index.ts",[],[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/__tests__/compiledHooks.test.tsx",[],[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/__tests__/fragmentReferencesFieldPolicy.test.ts",[],[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/__tests__/getPossibleTypesAndDataIdFromNode.test.ts",[],[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/__tests__/nodeFromCacheFieldPolicy.test.ts",[],[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/compiledHooks/index.ts",[],[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/compiledHooks/types.ts",[],["128"],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/compiledHooks/useCompiledFragment.ts",[],[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/compiledHooks/useCompiledLazyLoadQuery.ts",[],["129"],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/compiledHooks/useCompiledPaginationFragment.ts",[],["130","131","132","133","134"],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/compiledHooks/useCompiledRefetchableFragment.ts",[],["135"],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/compiledHooks/useDeepCompareMemoize.ts",[],[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/compiledHooks/useForceUpdate.ts",[],[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/fragmentReferencesFieldPolicy.ts",[],[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/getPossibleTypesAndDataIdFromNode.ts",[],[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/index.ts",[],[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/nodeFromCacheFieldPolicy.ts",[],[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/shallowCompareFragmentReferences.ts",[],[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/typePolicies.ts",[],[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/types.ts",[],["136","137"],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/useOverridenOrDefaultApolloClient.ts",[],["138"],{"ruleId":"139","severity":1,"message":"140","line":319,"column":38,"nodeType":"141","messageId":"142","endLine":319,"endColumn":41,"suggestions":"143","suppressions":"144"},{"ruleId":"139","severity":1,"message":"140","line":16,"column":32,"nodeType":"141","messageId":"142","endLine":16,"endColumn":35,"suggestions":"145","suppressions":"146"},{"ruleId":"139","severity":1,"message":"140","line":87,"column":28,"nodeType":"141","messageId":"142","endLine":87,"endColumn":31,"suggestions":"147","suppressions":"148"},{"ruleId":"139","severity":1,"message":"140","line":170,"column":24,"nodeType":"141","messageId":"142","endLine":170,"endColumn":27,"suggestions":"149","suppressions":"150"},{"ruleId":"139","severity":1,"message":"140","line":173,"column":4,"nodeType":"141","messageId":"142","endLine":173,"endColumn":7,"suggestions":"151","suppressions":"152"},{"ruleId":"139","severity":1,"message":"140","line":175,"column":30,"nodeType":"141","messageId":"142","endLine":175,"endColumn":33,"suggestions":"153","suppressions":"154"},{"ruleId":"139","severity":1,"message":"140","line":185,"column":24,"nodeType":"141","messageId":"142","endLine":185,"endColumn":27,"suggestions":"155","suppressions":"156"},{"ruleId":"139","severity":1,"message":"140","line":221,"column":9,"nodeType":"141","messageId":"142","endLine":221,"endColumn":12,"suggestions":"157","suppressions":"158"},{"ruleId":"139","severity":1,"message":"140","line":38,"column":26,"nodeType":"141","messageId":"142","endLine":38,"endColumn":29,"suggestions":"159","suppressions":"160"},{"ruleId":"139","severity":1,"message":"140","line":5,"column":19,"nodeType":"141","messageId":"142","endLine":5,"endColumn":22,"suggestions":"161","suppressions":"162"},{"ruleId":"139","severity":1,"message":"140","line":10,"column":19,"nodeType":"141","messageId":"142","endLine":10,"endColumn":22,"suggestions":"163","suppressions":"164"},{"ruleId":"139","severity":1,"message":"140","line":17,"column":51,"nodeType":"141","messageId":"142","endLine":17,"endColumn":54,"suggestions":"165","suppressions":"166"},"@typescript-eslint/no-explicit-any","Unexpected any. Specify a different type.","TSAnyKeyword","unexpectedAny",["167","168"],["169"],["170","171"],["172"],["173","174"],["175"],["176","177"],["178"],["179","180"],["181"],["182","183"],["184"],["185","186"],["187"],["188","189"],["190"],["191","192"],["193"],["194","195"],["196"],["197","198"],["199"],["200","201"],["202"],{"messageId":"203","fix":"204","desc":"205"},{"messageId":"206","fix":"207","desc":"208"},{"kind":"209","justification":"210"},{"messageId":"203","fix":"211","desc":"205"},{"messageId":"206","fix":"212","desc":"208"},{"kind":"209","justification":"210"},{"messageId":"203","fix":"213","desc":"205"},{"messageId":"206","fix":"214","desc":"208"},{"kind":"209","justification":"210"},{"messageId":"203","fix":"215","desc":"205"},{"messageId":"206","fix":"216","desc":"208"},{"kind":"209","justification":"210"},{"messageId":"203","fix":"217","desc":"205"},{"messageId":"206","fix":"218","desc":"208"},{"kind":"209","justification":"210"},{"messageId":"203","fix":"219","desc":"205"},{"messageId":"206","fix":"220","desc":"208"},{"kind":"209","justification":"210"},{"messageId":"203","fix":"221","desc":"205"},{"messageId":"206","fix":"222","desc":"208"},{"kind":"209","justification":"210"},{"messageId":"203","fix":"223","desc":"205"},{"messageId":"206","fix":"224","desc":"208"},{"kind":"209","justification":"210"},{"messageId":"203","fix":"225","desc":"205"},{"messageId":"206","fix":"226","desc":"208"},{"kind":"209","justification":"210"},{"messageId":"203","fix":"227","desc":"205"},{"messageId":"206","fix":"228","desc":"208"},{"kind":"209","justification":"210"},{"messageId":"203","fix":"229","desc":"205"},{"messageId":"206","fix":"230","desc":"208"},{"kind":"209","justification":"210"},{"messageId":"203","fix":"231","desc":"205"},{"messageId":"206","fix":"232","desc":"208"},{"kind":"209","justification":"210"},"suggestUnknown",{"range":"233","text":"234"},"Use `unknown` instead, this will force you to explicitly, and safely assert the type is correct.","suggestNever",{"range":"233","text":"235"},"Use `never` instead, this is useful when instantiating generic type parameters that you don't need to know the type of.","directive","",{"range":"236","text":"234"},{"range":"236","text":"235"},{"range":"237","text":"234"},{"range":"237","text":"235"},{"range":"238","text":"234"},{"range":"238","text":"235"},{"range":"239","text":"234"},{"range":"239","text":"235"},{"range":"240","text":"234"},{"range":"240","text":"235"},{"range":"241","text":"234"},{"range":"241","text":"235"},{"range":"242","text":"234"},{"range":"242","text":"235"},{"range":"243","text":"234"},{"range":"243","text":"235"},{"range":"244","text":"234"},{"range":"244","text":"235"},{"range":"245","text":"234"},{"range":"245","text":"235"},{"range":"246","text":"234"},{"range":"246","text":"235"},[11682,11685],"unknown","never",[567,570],[2626,2629],[5796,5799],[5897,5900],[5997,6000],[6286,6289],[7350,7353],[1283,1286],[158,161],[276,279],[455,458]]
|
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,28 @@
|
|
|
1
1
|
# Change Log - @graphitation/apollo-react-relay-duct-tape
|
|
2
2
|
|
|
3
|
-
This log was last generated on Tue,
|
|
3
|
+
This log was last generated on Tue, 06 Feb 2024 17:55:50 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 1.0.30
|
|
8
|
+
|
|
9
|
+
Tue, 06 Feb 2024 17:55:50 GMT
|
|
10
|
+
|
|
11
|
+
### Patches
|
|
12
|
+
|
|
13
|
+
- use correct id for compiled fragment, add check for partial result (Stanislaw.Wilczynski@microsoft.com)
|
|
14
|
+
|
|
15
|
+
## 1.0.29
|
|
16
|
+
|
|
17
|
+
Tue, 30 Jan 2024 10:24:57 GMT
|
|
18
|
+
|
|
19
|
+
### Patches
|
|
20
|
+
|
|
21
|
+
- make sure pagination respected variables used in refetch (Stanislaw.Wilczynski@microsoft.com)
|
|
22
|
+
|
|
7
23
|
## 1.0.28
|
|
8
24
|
|
|
9
|
-
Tue, 16 Jan 2024 04:23:
|
|
25
|
+
Tue, 16 Jan 2024 04:23:53 GMT
|
|
10
26
|
|
|
11
27
|
### Patches
|
|
12
28
|
|
package/README.md
CHANGED
|
@@ -28,13 +28,13 @@ Use this together with [@graphitation/apollo-react-relay-duct-tape-compiler](../
|
|
|
28
28
|
TODO:
|
|
29
29
|
|
|
30
30
|
- We cannot support the default apollo cache keys for fragments on Node [derived] interfaces. Seeing as Node semantics are so core to the ability to provide these APIs, it makes sense to remove the apollo default cache key support.
|
|
31
|
-
- Copy apollo cache config required from the example app. This includes getting the list of possible types and the dataIdFromObject
|
|
31
|
+
- Copy apollo cache config required from the example app. This includes getting the list of possible types and the dataIdFromObject implementation.
|
|
32
32
|
|
|
33
33
|
- Configure Apollo Client's cache to automatically add `__typename` field selections, which concrete types implement the `Node` interface, and the type-policies needed to read the watch query data from the store:
|
|
34
34
|
|
|
35
35
|
```ts
|
|
36
36
|
import { InMemoryCache } from "@apollo/client";
|
|
37
|
-
import { typePolicies } from "@graphitation/apollo-react-relay-duct-tape";
|
|
37
|
+
import { typePoliciesWithGlobalObjectIdStoreKeys as typePolicies } from "@graphitation/apollo-react-relay-duct-tape";
|
|
38
38
|
|
|
39
39
|
const cache = new InMemoryCache({
|
|
40
40
|
addTypename: true,
|
|
@@ -43,7 +43,7 @@ TODO:
|
|
|
43
43
|
possibleTypes: {
|
|
44
44
|
Node: ["Todo"],
|
|
45
45
|
},
|
|
46
|
-
// Either use the `
|
|
46
|
+
// Either use the `typePoliciesWithGlobalObjectIdStoreKeys` object directly or otherwise extend appropriately. Alternatively you can also use typePoliciesWithDefaultApolloClientStoreKeys
|
|
47
47
|
typePolicies: {
|
|
48
48
|
Query: {
|
|
49
49
|
fields: {
|
|
@@ -63,28 +63,57 @@ TODO:
|
|
|
63
63
|
},
|
|
64
64
|
},
|
|
65
65
|
},
|
|
66
|
+
// Make sure to specify the dataIdFromObject implementation if you rely on typePoliciesWithGlobalObjectIdStoreKeys
|
|
67
|
+
dataIdFromObject(responseObject, keyFieldsContext) {
|
|
68
|
+
if (
|
|
69
|
+
responseObject.id &&
|
|
70
|
+
responseObject.__typename &&
|
|
71
|
+
possibleTypes?.Node.includes(responseObject.__typename)
|
|
72
|
+
) {
|
|
73
|
+
return responseObject.id as string;
|
|
74
|
+
}
|
|
75
|
+
// fallback to default way of doing it
|
|
76
|
+
return defaultDataIdFromObject(responseObject, keyFieldsContext);
|
|
77
|
+
},
|
|
66
78
|
});
|
|
67
79
|
```
|
|
68
80
|
|
|
69
|
-
|
|
81
|
+
In most cases as in [the example app](../../examples/apollo-watch-fragments/src/graphql.ts), you can just build the configuration using utilities exported from `@graphitation/apollo-react-relay-duct-tape`:
|
|
70
82
|
|
|
71
83
|
```ts
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
84
|
+
import { InMemoryCache, defaultDataIdFromObject } from "@apollo/client";
|
|
85
|
+
import { schema } from "fileWithYourSchema";
|
|
86
|
+
import {
|
|
87
|
+
typePoliciesWithGlobalObjectIdStoreKeys,
|
|
88
|
+
getPossibleTypesAndDataIdFromNode,
|
|
89
|
+
} from "@graphitation/apollo-react-relay-duct-tape";
|
|
75
90
|
|
|
91
|
+
const { possibleTypes, dataIdFromObject } =
|
|
92
|
+
getPossibleTypesAndDataIdFromNode(schema);
|
|
93
|
+
|
|
94
|
+
const cache = new InMemoryCache({
|
|
95
|
+
addTypename: true,
|
|
96
|
+
possibleTypes, // already makes sure to contain all possible types for Node interface
|
|
97
|
+
typePolicies: typePoliciesWithGlobalObjectIdStoreKeys,
|
|
98
|
+
dataIdFromObject(responseObject, keyFieldsContext) {
|
|
99
|
+
return (
|
|
100
|
+
dataIdFromNode(responseObject, keyFieldsContext) ||
|
|
101
|
+
defaultDataIdFromObject(responseObject, keyFieldsContext)
|
|
102
|
+
);
|
|
103
|
+
},
|
|
104
|
+
});
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
- Configure webpack to transform your code by replacing inline GraphQL documents with their compiled artefacts:
|
|
108
|
+
|
|
109
|
+
```ts
|
|
76
110
|
const config: webpack.Configuration = {
|
|
77
111
|
module: {
|
|
78
112
|
rules: [
|
|
79
113
|
{
|
|
80
|
-
test:
|
|
81
|
-
loader: "
|
|
114
|
+
test: /.+?\.tsx?$/,
|
|
115
|
+
loader: "@graphitation/embedded-document-artefact-loader/webpack",
|
|
82
116
|
exclude: /node_modules/,
|
|
83
|
-
options: {
|
|
84
|
-
getCustomTransformers: () => ({
|
|
85
|
-
before: [createImportDocumentsTransform()],
|
|
86
|
-
}),
|
|
87
|
-
},
|
|
88
117
|
},
|
|
89
118
|
],
|
|
90
119
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCompiledFragment.d.ts","sourceRoot":"","sources":["../../../src/storeObservation/compiledHooks/useCompiledFragment.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qDAAqD,CAAC;
|
|
1
|
+
{"version":3,"file":"useCompiledFragment.d.ts","sourceRoot":"","sources":["../../../src/storeObservation/compiledHooks/useCompiledFragment.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qDAAqD,CAAC;AAGlG;;;;GAIG;AAEH,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,sBAAsB,EACjC,iBAAiB,EAAE,iBAAiB,GACnC,MAAM,CAiFR"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __create = Object.create;
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
|
+
var __defProps = Object.defineProperties;
|
|
4
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
5
7
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
8
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
7
9
|
var __getProtoOf = Object.getPrototypeOf;
|
|
@@ -19,6 +21,7 @@ var __spreadValues = (a, b) => {
|
|
|
19
21
|
}
|
|
20
22
|
return a;
|
|
21
23
|
};
|
|
24
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
22
25
|
var __export = (target, all) => {
|
|
23
26
|
for (var name in all)
|
|
24
27
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -50,6 +53,7 @@ var import_invariant = __toESM(require("invariant"));
|
|
|
50
53
|
var import_useForceUpdate = require("./useForceUpdate");
|
|
51
54
|
var import_useOverridenOrDefaultApolloClient = require("../../useOverridenOrDefaultApolloClient");
|
|
52
55
|
function useCompiledFragment(documents, fragmentReference) {
|
|
56
|
+
var _a, _b, _c, _d;
|
|
53
57
|
(0, import_invariant.default)(
|
|
54
58
|
fragmentReference,
|
|
55
59
|
"useFragment(): Expected metadata to have been extracted from the fragment. Did you forget to invoke the compiler?"
|
|
@@ -66,10 +70,10 @@ function useCompiledFragment(documents, fragmentReference) {
|
|
|
66
70
|
fetchPolicy: "cache-only",
|
|
67
71
|
query: watchQueryDocument,
|
|
68
72
|
returnPartialData: false,
|
|
69
|
-
variables: __spreadValues({
|
|
73
|
+
variables: __spreadProps(__spreadValues({}, fragmentReference.__fragments), {
|
|
70
74
|
id: fragmentReference.id,
|
|
71
75
|
__fragments: fragmentReference.__fragments
|
|
72
|
-
}
|
|
76
|
+
})
|
|
73
77
|
}),
|
|
74
78
|
[client, fragmentReference.id, fragmentReference.__fragments]
|
|
75
79
|
);
|
|
@@ -90,13 +94,31 @@ function useCompiledFragment(documents, fragmentReference) {
|
|
|
90
94
|
return () => subscription.unsubscribe();
|
|
91
95
|
}, [observableQuery]);
|
|
92
96
|
const result = observableQuery.getCurrentResult();
|
|
97
|
+
if (result.partial) {
|
|
98
|
+
(0, import_invariant.default)(
|
|
99
|
+
false,
|
|
100
|
+
"useFragment(): Missing data expected to be seeded by the execution query document: %s. Please check your type policies and possibleTypes configuration. If only subset of properties is missing you might need to configure merge functions for non-normalized types.",
|
|
101
|
+
JSON.stringify(
|
|
102
|
+
// we need the cast because queryInfo and lastDiff are private but very useful for debugging
|
|
103
|
+
(_d = (_c = (_b = (_a = observableQuery.queryInfo) == null ? void 0 : _a.lastDiff) == null ? void 0 : _b.diff) == null ? void 0 : _c.missing) == null ? void 0 : _d.map((e) => e.path)
|
|
104
|
+
)
|
|
105
|
+
);
|
|
106
|
+
}
|
|
93
107
|
let data = result.data;
|
|
94
108
|
if (metadata == null ? void 0 : metadata.rootSelection) {
|
|
109
|
+
(0, import_invariant.default)(
|
|
110
|
+
data,
|
|
111
|
+
"useFragment(): Expected Apollo to respond with previously seeded data of the execution query document: %s. Did you configure your type policies and possibleTypes correctly? Check apollo-react-relay-duct-tape README for more details.",
|
|
112
|
+
JSON.stringify({
|
|
113
|
+
selection: metadata.rootSelection,
|
|
114
|
+
mainFragment: metadata.mainFragment
|
|
115
|
+
})
|
|
116
|
+
);
|
|
95
117
|
data = data[metadata.rootSelection];
|
|
96
118
|
}
|
|
97
119
|
(0, import_invariant.default)(
|
|
98
120
|
data,
|
|
99
|
-
"useFragment(): Expected Apollo to respond with previously seeded data of the execution query document"
|
|
121
|
+
"useFragment(): Expected Apollo to respond with previously seeded data of the execution query document. Did you configure your type policies and possibleTypes correctly? Check apollo-react-relay-duct-tape README for more details."
|
|
100
122
|
);
|
|
101
123
|
return data;
|
|
102
124
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/storeObservation/compiledHooks/useCompiledFragment.ts"],
|
|
4
|
-
"sourcesContent": ["import { useEffect, useMemo } from \"react\";\nimport invariant from \"invariant\";\nimport { useForceUpdate } from \"./useForceUpdate\";\nimport { useOverridenOrDefaultApolloClient } from \"../../useOverridenOrDefaultApolloClient\";\n\nimport type { FragmentReference } from \"./types\";\nimport type { CompiledArtefactModule } from \"@graphitation/apollo-react-relay-duct-tape-compiler\";\n\n/**\n * @param documents Compiled watch query document that is used to setup a narrow\n * observable for just the data selected by the original fragment.\n * @param fragmentReference A Node object that has a globally unique `id` field.\n */\n\nexport function useCompiledFragment(\n documents: CompiledArtefactModule,\n fragmentReference: FragmentReference,\n): object {\n invariant(\n fragmentReference,\n \"useFragment(): Expected metadata to have been extracted from \" +\n \"the fragment. Did you forget to invoke the compiler?\",\n );\n const { watchQueryDocument, metadata } = documents;\n invariant(\n watchQueryDocument,\n \"useFragment(): Expected a `watchQueryDocument` to have been \" +\n \"extracted. Did you forget to invoke the compiler?\",\n );\n\n const client = useOverridenOrDefaultApolloClient();\n const forceUpdate = useForceUpdate();\n\n const observableQuery = useMemo(\n () =>\n client.watchQuery({\n fetchPolicy: \"cache-only\",\n query: watchQueryDocument,\n returnPartialData: false,\n variables: {\n id: fragmentReference.id,\n __fragments: fragmentReference.__fragments,\n
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import { useEffect, useMemo } from \"react\";\nimport invariant from \"invariant\";\nimport { useForceUpdate } from \"./useForceUpdate\";\nimport { useOverridenOrDefaultApolloClient } from \"../../useOverridenOrDefaultApolloClient\";\n\nimport type { FragmentReference } from \"./types\";\nimport type { CompiledArtefactModule } from \"@graphitation/apollo-react-relay-duct-tape-compiler\";\nimport { Cache } from \"@apollo/client/core\";\n\n/**\n * @param documents Compiled watch query document that is used to setup a narrow\n * observable for just the data selected by the original fragment.\n * @param fragmentReference A Node object that has a globally unique `id` field.\n */\n\nexport function useCompiledFragment(\n documents: CompiledArtefactModule,\n fragmentReference: FragmentReference,\n): object {\n invariant(\n fragmentReference,\n \"useFragment(): Expected metadata to have been extracted from \" +\n \"the fragment. Did you forget to invoke the compiler?\",\n );\n const { watchQueryDocument, metadata } = documents;\n invariant(\n watchQueryDocument,\n \"useFragment(): Expected a `watchQueryDocument` to have been \" +\n \"extracted. Did you forget to invoke the compiler?\",\n );\n\n const client = useOverridenOrDefaultApolloClient();\n const forceUpdate = useForceUpdate();\n\n const observableQuery = useMemo(\n () =>\n client.watchQuery({\n fetchPolicy: \"cache-only\",\n query: watchQueryDocument,\n returnPartialData: false,\n variables: {\n ...fragmentReference.__fragments,\n id: fragmentReference.id,\n __fragments: fragmentReference.__fragments,\n },\n }),\n [client, fragmentReference.id, fragmentReference.__fragments],\n );\n\n useEffect(() => {\n let skipFirst = true;\n const subscription = observableQuery.subscribe(\n () => {\n // Unclear why, but this yields twice with the same results, so skip one.\n if (skipFirst) {\n skipFirst = false;\n } else {\n forceUpdate();\n }\n },\n (error) => {\n console.log(error);\n },\n );\n return () => subscription.unsubscribe();\n }, [observableQuery]);\n\n const result = observableQuery.getCurrentResult();\n if (result.partial) {\n invariant(\n false,\n \"useFragment(): Missing data expected to be seeded by the execution query document: %s. Please check your type policies and possibleTypes configuration. If only subset of properties is missing you might need to configure merge functions for non-normalized types.\",\n JSON.stringify(\n // we need the cast because queryInfo and lastDiff are private but very useful for debugging\n (\n observableQuery as unknown as {\n queryInfo?: { lastDiff?: { diff?: Cache.DiffResult<unknown> } };\n }\n ).queryInfo?.lastDiff?.diff?.missing?.map((e) => e.path),\n ),\n );\n }\n let data = result.data;\n if (metadata?.rootSelection) {\n invariant(\n data,\n \"useFragment(): Expected Apollo to respond with previously seeded data of the execution query document: %s. Did you configure your type policies and possibleTypes correctly? Check apollo-react-relay-duct-tape README for more details.\",\n JSON.stringify({\n selection: metadata.rootSelection,\n mainFragment: metadata.mainFragment,\n }),\n );\n data = data[metadata.rootSelection];\n }\n invariant(\n data,\n \"useFragment(): Expected Apollo to respond with previously seeded data of the execution query document. Did you configure your type policies and possibleTypes correctly? Check apollo-react-relay-duct-tape README for more details.\",\n );\n return data;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAmC;AACnC,uBAAsB;AACtB,4BAA+B;AAC/B,+CAAkD;AAY3C,SAAS,oBACd,WACA,mBACQ;AAlBV;AAmBE,uBAAAA;AAAA,IACE;AAAA,IACA;AAAA,EAEF;AACA,QAAM,EAAE,oBAAoB,SAAS,IAAI;AACzC,uBAAAA;AAAA,IACE;AAAA,IACA;AAAA,EAEF;AAEA,QAAM,aAAS,4EAAkC;AACjD,QAAM,kBAAc,sCAAe;AAEnC,QAAM,sBAAkB;AAAA,IACtB,MACE,OAAO,WAAW;AAAA,MAChB,aAAa;AAAA,MACb,OAAO;AAAA,MACP,mBAAmB;AAAA,MACnB,WAAW,iCACN,kBAAkB,cADZ;AAAA,QAET,IAAI,kBAAkB;AAAA,QACtB,aAAa,kBAAkB;AAAA,MACjC;AAAA,IACF,CAAC;AAAA,IACH,CAAC,QAAQ,kBAAkB,IAAI,kBAAkB,WAAW;AAAA,EAC9D;AAEA,8BAAU,MAAM;AACd,QAAI,YAAY;AAChB,UAAM,eAAe,gBAAgB;AAAA,MACnC,MAAM;AAEJ,YAAI,WAAW;AACb,sBAAY;AAAA,QACd,OAAO;AACL,sBAAY;AAAA,QACd;AAAA,MACF;AAAA,MACA,CAAC,UAAU;AACT,gBAAQ,IAAI,KAAK;AAAA,MACnB;AAAA,IACF;AACA,WAAO,MAAM,aAAa,YAAY;AAAA,EACxC,GAAG,CAAC,eAAe,CAAC;AAEpB,QAAM,SAAS,gBAAgB,iBAAiB;AAChD,MAAI,OAAO,SAAS;AAClB,yBAAAA;AAAA,MACE;AAAA,MACA;AAAA,MACA,KAAK;AAAA;AAAA,SAGD,uCAGA,cAHA,mBAGW,aAHX,mBAGqB,SAHrB,mBAG2B,YAH3B,mBAGoC,IAAI,CAAC,MAAM,EAAE;AAAA,MACrD;AAAA,IACF;AAAA,EACF;AACA,MAAI,OAAO,OAAO;AAClB,MAAI,qCAAU,eAAe;AAC3B,yBAAAA;AAAA,MACE;AAAA,MACA;AAAA,MACA,KAAK,UAAU;AAAA,QACb,WAAW,SAAS;AAAA,QACpB,cAAc,SAAS;AAAA,MACzB,CAAC;AAAA,IACH;AACA,WAAO,KAAK,SAAS,aAAa;AAAA,EACpC;AACA,uBAAAA;AAAA,IACE;AAAA,IACA;AAAA,EACF;AACA,SAAO;AACT;",
|
|
6
6
|
"names": ["invariant"]
|
|
7
7
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
2
4
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
6
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
@@ -14,6 +16,7 @@ var __spreadValues = (a, b) => {
|
|
|
14
16
|
}
|
|
15
17
|
return a;
|
|
16
18
|
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
17
20
|
|
|
18
21
|
// src/storeObservation/compiledHooks/useCompiledFragment.ts
|
|
19
22
|
import { useEffect, useMemo } from "react";
|
|
@@ -21,6 +24,7 @@ import invariant from "invariant";
|
|
|
21
24
|
import { useForceUpdate } from "./useForceUpdate.mjs";
|
|
22
25
|
import { useOverridenOrDefaultApolloClient } from "../../useOverridenOrDefaultApolloClient.mjs";
|
|
23
26
|
function useCompiledFragment(documents, fragmentReference) {
|
|
27
|
+
var _a, _b, _c, _d;
|
|
24
28
|
invariant(
|
|
25
29
|
fragmentReference,
|
|
26
30
|
"useFragment(): Expected metadata to have been extracted from the fragment. Did you forget to invoke the compiler?"
|
|
@@ -37,10 +41,10 @@ function useCompiledFragment(documents, fragmentReference) {
|
|
|
37
41
|
fetchPolicy: "cache-only",
|
|
38
42
|
query: watchQueryDocument,
|
|
39
43
|
returnPartialData: false,
|
|
40
|
-
variables: __spreadValues({
|
|
44
|
+
variables: __spreadProps(__spreadValues({}, fragmentReference.__fragments), {
|
|
41
45
|
id: fragmentReference.id,
|
|
42
46
|
__fragments: fragmentReference.__fragments
|
|
43
|
-
}
|
|
47
|
+
})
|
|
44
48
|
}),
|
|
45
49
|
[client, fragmentReference.id, fragmentReference.__fragments]
|
|
46
50
|
);
|
|
@@ -61,13 +65,31 @@ function useCompiledFragment(documents, fragmentReference) {
|
|
|
61
65
|
return () => subscription.unsubscribe();
|
|
62
66
|
}, [observableQuery]);
|
|
63
67
|
const result = observableQuery.getCurrentResult();
|
|
68
|
+
if (result.partial) {
|
|
69
|
+
invariant(
|
|
70
|
+
false,
|
|
71
|
+
"useFragment(): Missing data expected to be seeded by the execution query document: %s. Please check your type policies and possibleTypes configuration. If only subset of properties is missing you might need to configure merge functions for non-normalized types.",
|
|
72
|
+
JSON.stringify(
|
|
73
|
+
// we need the cast because queryInfo and lastDiff are private but very useful for debugging
|
|
74
|
+
(_d = (_c = (_b = (_a = observableQuery.queryInfo) == null ? void 0 : _a.lastDiff) == null ? void 0 : _b.diff) == null ? void 0 : _c.missing) == null ? void 0 : _d.map((e) => e.path)
|
|
75
|
+
)
|
|
76
|
+
);
|
|
77
|
+
}
|
|
64
78
|
let data = result.data;
|
|
65
79
|
if (metadata == null ? void 0 : metadata.rootSelection) {
|
|
80
|
+
invariant(
|
|
81
|
+
data,
|
|
82
|
+
"useFragment(): Expected Apollo to respond with previously seeded data of the execution query document: %s. Did you configure your type policies and possibleTypes correctly? Check apollo-react-relay-duct-tape README for more details.",
|
|
83
|
+
JSON.stringify({
|
|
84
|
+
selection: metadata.rootSelection,
|
|
85
|
+
mainFragment: metadata.mainFragment
|
|
86
|
+
})
|
|
87
|
+
);
|
|
66
88
|
data = data[metadata.rootSelection];
|
|
67
89
|
}
|
|
68
90
|
invariant(
|
|
69
91
|
data,
|
|
70
|
-
"useFragment(): Expected Apollo to respond with previously seeded data of the execution query document"
|
|
92
|
+
"useFragment(): Expected Apollo to respond with previously seeded data of the execution query document. Did you configure your type policies and possibleTypes correctly? Check apollo-react-relay-duct-tape README for more details."
|
|
71
93
|
);
|
|
72
94
|
return data;
|
|
73
95
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/storeObservation/compiledHooks/useCompiledFragment.ts"],
|
|
4
|
-
"sourcesContent": ["import { useEffect, useMemo } from \"react\";\nimport invariant from \"invariant\";\nimport { useForceUpdate } from \"./useForceUpdate\";\nimport { useOverridenOrDefaultApolloClient } from \"../../useOverridenOrDefaultApolloClient\";\n\nimport type { FragmentReference } from \"./types\";\nimport type { CompiledArtefactModule } from \"@graphitation/apollo-react-relay-duct-tape-compiler\";\n\n/**\n * @param documents Compiled watch query document that is used to setup a narrow\n * observable for just the data selected by the original fragment.\n * @param fragmentReference A Node object that has a globally unique `id` field.\n */\n\nexport function useCompiledFragment(\n documents: CompiledArtefactModule,\n fragmentReference: FragmentReference,\n): object {\n invariant(\n fragmentReference,\n \"useFragment(): Expected metadata to have been extracted from \" +\n \"the fragment. Did you forget to invoke the compiler?\",\n );\n const { watchQueryDocument, metadata } = documents;\n invariant(\n watchQueryDocument,\n \"useFragment(): Expected a `watchQueryDocument` to have been \" +\n \"extracted. Did you forget to invoke the compiler?\",\n );\n\n const client = useOverridenOrDefaultApolloClient();\n const forceUpdate = useForceUpdate();\n\n const observableQuery = useMemo(\n () =>\n client.watchQuery({\n fetchPolicy: \"cache-only\",\n query: watchQueryDocument,\n returnPartialData: false,\n variables: {\n id: fragmentReference.id,\n __fragments: fragmentReference.__fragments,\n
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import { useEffect, useMemo } from \"react\";\nimport invariant from \"invariant\";\nimport { useForceUpdate } from \"./useForceUpdate\";\nimport { useOverridenOrDefaultApolloClient } from \"../../useOverridenOrDefaultApolloClient\";\n\nimport type { FragmentReference } from \"./types\";\nimport type { CompiledArtefactModule } from \"@graphitation/apollo-react-relay-duct-tape-compiler\";\nimport { Cache } from \"@apollo/client/core\";\n\n/**\n * @param documents Compiled watch query document that is used to setup a narrow\n * observable for just the data selected by the original fragment.\n * @param fragmentReference A Node object that has a globally unique `id` field.\n */\n\nexport function useCompiledFragment(\n documents: CompiledArtefactModule,\n fragmentReference: FragmentReference,\n): object {\n invariant(\n fragmentReference,\n \"useFragment(): Expected metadata to have been extracted from \" +\n \"the fragment. Did you forget to invoke the compiler?\",\n );\n const { watchQueryDocument, metadata } = documents;\n invariant(\n watchQueryDocument,\n \"useFragment(): Expected a `watchQueryDocument` to have been \" +\n \"extracted. Did you forget to invoke the compiler?\",\n );\n\n const client = useOverridenOrDefaultApolloClient();\n const forceUpdate = useForceUpdate();\n\n const observableQuery = useMemo(\n () =>\n client.watchQuery({\n fetchPolicy: \"cache-only\",\n query: watchQueryDocument,\n returnPartialData: false,\n variables: {\n ...fragmentReference.__fragments,\n id: fragmentReference.id,\n __fragments: fragmentReference.__fragments,\n },\n }),\n [client, fragmentReference.id, fragmentReference.__fragments],\n );\n\n useEffect(() => {\n let skipFirst = true;\n const subscription = observableQuery.subscribe(\n () => {\n // Unclear why, but this yields twice with the same results, so skip one.\n if (skipFirst) {\n skipFirst = false;\n } else {\n forceUpdate();\n }\n },\n (error) => {\n console.log(error);\n },\n );\n return () => subscription.unsubscribe();\n }, [observableQuery]);\n\n const result = observableQuery.getCurrentResult();\n if (result.partial) {\n invariant(\n false,\n \"useFragment(): Missing data expected to be seeded by the execution query document: %s. Please check your type policies and possibleTypes configuration. If only subset of properties is missing you might need to configure merge functions for non-normalized types.\",\n JSON.stringify(\n // we need the cast because queryInfo and lastDiff are private but very useful for debugging\n (\n observableQuery as unknown as {\n queryInfo?: { lastDiff?: { diff?: Cache.DiffResult<unknown> } };\n }\n ).queryInfo?.lastDiff?.diff?.missing?.map((e) => e.path),\n ),\n );\n }\n let data = result.data;\n if (metadata?.rootSelection) {\n invariant(\n data,\n \"useFragment(): Expected Apollo to respond with previously seeded data of the execution query document: %s. Did you configure your type policies and possibleTypes correctly? Check apollo-react-relay-duct-tape README for more details.\",\n JSON.stringify({\n selection: metadata.rootSelection,\n mainFragment: metadata.mainFragment,\n }),\n );\n data = data[metadata.rootSelection];\n }\n invariant(\n data,\n \"useFragment(): Expected Apollo to respond with previously seeded data of the execution query document. Did you configure your type policies and possibleTypes correctly? Check apollo-react-relay-duct-tape README for more details.\",\n );\n return data;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,WAAW,eAAe;AACnC,OAAO,eAAe;AACtB,SAAS,sBAAsB;AAC/B,SAAS,yCAAyC;AAY3C,SAAS,oBACd,WACA,mBACQ;AAlBV;AAmBE;AAAA,IACE;AAAA,IACA;AAAA,EAEF;AACA,QAAM,EAAE,oBAAoB,SAAS,IAAI;AACzC;AAAA,IACE;AAAA,IACA;AAAA,EAEF;AAEA,QAAM,SAAS,kCAAkC;AACjD,QAAM,cAAc,eAAe;AAEnC,QAAM,kBAAkB;AAAA,IACtB,MACE,OAAO,WAAW;AAAA,MAChB,aAAa;AAAA,MACb,OAAO;AAAA,MACP,mBAAmB;AAAA,MACnB,WAAW,iCACN,kBAAkB,cADZ;AAAA,QAET,IAAI,kBAAkB;AAAA,QACtB,aAAa,kBAAkB;AAAA,MACjC;AAAA,IACF,CAAC;AAAA,IACH,CAAC,QAAQ,kBAAkB,IAAI,kBAAkB,WAAW;AAAA,EAC9D;AAEA,YAAU,MAAM;AACd,QAAI,YAAY;AAChB,UAAM,eAAe,gBAAgB;AAAA,MACnC,MAAM;AAEJ,YAAI,WAAW;AACb,sBAAY;AAAA,QACd,OAAO;AACL,sBAAY;AAAA,QACd;AAAA,MACF;AAAA,MACA,CAAC,UAAU;AACT,gBAAQ,IAAI,KAAK;AAAA,MACnB;AAAA,IACF;AACA,WAAO,MAAM,aAAa,YAAY;AAAA,EACxC,GAAG,CAAC,eAAe,CAAC;AAEpB,QAAM,SAAS,gBAAgB,iBAAiB;AAChD,MAAI,OAAO,SAAS;AAClB;AAAA,MACE;AAAA,MACA;AAAA,MACA,KAAK;AAAA;AAAA,SAGD,uCAGA,cAHA,mBAGW,aAHX,mBAGqB,SAHrB,mBAG2B,YAH3B,mBAGoC,IAAI,CAAC,MAAM,EAAE;AAAA,MACrD;AAAA,IACF;AAAA,EACF;AACA,MAAI,OAAO,OAAO;AAClB,MAAI,qCAAU,eAAe;AAC3B;AAAA,MACE;AAAA,MACA;AAAA,MACA,KAAK,UAAU;AAAA,QACb,WAAW,SAAS;AAAA,QACpB,cAAc,SAAS;AAAA,MACzB,CAAC;AAAA,IACH;AACA,WAAO,KAAK,SAAS,aAAa;AAAA,EACpC;AACA;AAAA,IACE;AAAA,IACA;AAAA,EACF;AACA,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCompiledPaginationFragment.d.ts","sourceRoot":"","sources":["../../../src/storeObservation/compiledHooks/useCompiledPaginationFragment.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,KAAK,EACV,SAAS,EACT,UAAU,EAEV,cAAc,EACf,MAAM,kCAAkC,CAAC;AAC1C,OAAO,KAAK,EACV,sBAAsB,EAEvB,MAAM,qDAAqD,CAAC;
|
|
1
|
+
{"version":3,"file":"useCompiledPaginationFragment.d.ts","sourceRoot":"","sources":["../../../src/storeObservation/compiledHooks/useCompiledPaginationFragment.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,KAAK,EACV,SAAS,EACT,UAAU,EAEV,cAAc,EACf,MAAM,kCAAkC,CAAC;AAC1C,OAAO,KAAK,EACV,sBAAsB,EAEvB,MAAM,qDAAqD,CAAC;AAI7D,MAAM,MAAM,YAAY,GAAG,CACzB,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,cAAc,KACrB,UAAU,CAAC;AAgMhB,wBAAgB,6BAA6B,CAC3C,SAAS,EAAE,sBAAsB,EACjC,iBAAiB,EAAE,iBAAiB,GACnC;IAED,IAAI,EAAE,GAAG,CAAC;IACV,QAAQ,EAAE,YAAY,CAAC;IACvB,YAAY,EAAE,YAAY,CAAC;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,OAAO,CAAC;IACrB,aAAa,EAAE,OAAO,CAAC;IACvB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,OAAO,EAAE,SAAS,CAAC;CACpB,CA0EA"}
|
|
@@ -55,6 +55,7 @@ var import_useOverridenOrDefaultApolloClient = require("../../useOverridenOrDefa
|
|
|
55
55
|
function useLoadMore({
|
|
56
56
|
fragmentReference,
|
|
57
57
|
refetch,
|
|
58
|
+
latestVariablesUsedByStandaloneRefetch,
|
|
58
59
|
metadata,
|
|
59
60
|
executionQueryDocument,
|
|
60
61
|
cache,
|
|
@@ -80,7 +81,7 @@ function useLoadMore({
|
|
|
80
81
|
cursorValue,
|
|
81
82
|
"usePaginationFragment(): Expected a cursor value to exist"
|
|
82
83
|
);
|
|
83
|
-
const previousVariables = __spreadProps(__spreadValues(__spreadValues({}, (_a = metadata.connection) == null ? void 0 : _a.filterVariableDefaults), fragmentReference.__fragments), {
|
|
84
|
+
const previousVariables = __spreadProps(__spreadValues(__spreadValues(__spreadValues({}, (_a = metadata.connection) == null ? void 0 : _a.filterVariableDefaults), latestVariablesUsedByStandaloneRefetch), fragmentReference.__fragments), {
|
|
84
85
|
id: fragmentReference.id
|
|
85
86
|
});
|
|
86
87
|
const newVariables = __spreadProps(__spreadValues({}, previousVariables), {
|
|
@@ -147,6 +148,7 @@ function useLoadMore({
|
|
|
147
148
|
fragmentReference.id,
|
|
148
149
|
fragmentReference.__fragments,
|
|
149
150
|
refetch,
|
|
151
|
+
latestVariablesUsedByStandaloneRefetch,
|
|
150
152
|
metadata,
|
|
151
153
|
executionQueryDocument,
|
|
152
154
|
cache,
|
|
@@ -202,9 +204,18 @@ function useCompiledPaginationFragment(documents, fragmentReference) {
|
|
|
202
204
|
documents,
|
|
203
205
|
fragmentReference
|
|
204
206
|
);
|
|
207
|
+
const latestVariablesUsedByStandaloneRefetch = (0, import_react.useRef)({});
|
|
208
|
+
const storeVariablesAndRefetch = (0, import_react.useCallback)(
|
|
209
|
+
(variables, options) => {
|
|
210
|
+
latestVariablesUsedByStandaloneRefetch.current = variables;
|
|
211
|
+
return refetch(variables, options);
|
|
212
|
+
},
|
|
213
|
+
[]
|
|
214
|
+
);
|
|
205
215
|
const commonPaginationParams = {
|
|
206
216
|
fragmentReference,
|
|
207
217
|
refetch,
|
|
218
|
+
latestVariablesUsedByStandaloneRefetch: latestVariablesUsedByStandaloneRefetch.current,
|
|
208
219
|
metadata,
|
|
209
220
|
executionQueryDocument,
|
|
210
221
|
cache: (0, import_useOverridenOrDefaultApolloClient.useOverridenOrDefaultApolloClient)().cache,
|
|
@@ -225,7 +236,7 @@ function useCompiledPaginationFragment(documents, fragmentReference) {
|
|
|
225
236
|
}));
|
|
226
237
|
return {
|
|
227
238
|
data,
|
|
228
|
-
refetch,
|
|
239
|
+
refetch: storeVariablesAndRefetch,
|
|
229
240
|
hasNext: !!(pageInfo == null ? void 0 : pageInfo.hasNextPage),
|
|
230
241
|
hasPrevious: !!(pageInfo == null ? void 0 : pageInfo.hasPreviousPage),
|
|
231
242
|
isLoadingNext,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/storeObservation/compiledHooks/useCompiledPaginationFragment.ts"],
|
|
4
|
-
"sourcesContent": ["import { useState, useCallback } from \"react\";\nimport { ApolloCache, DataProxy } from \"@apollo/client\";\nimport invariant from \"invariant\";\nimport { useCompiledRefetchableFragment } from \"./useCompiledRefetchableFragment\";\nimport { useOverridenOrDefaultApolloClient } from \"../../useOverridenOrDefaultApolloClient\";\n\nimport type { FragmentReference } from \"./types\";\nimport type {\n RefetchFn,\n Disposable,\n PrivateRefetchOptions,\n RefetchOptions,\n} from \"./useCompiledRefetchableFragment\";\nimport type {\n CompiledArtefactModule,\n Metadata,\n} from \"@graphitation/apollo-react-relay-duct-tape-compiler\";\nimport type { DocumentNode } from \"graphql\";\n\nexport type PaginationFn = (\n count: number,\n options?: RefetchOptions,\n) => Disposable;\n\ninterface PaginationParams {\n fragmentReference: FragmentReference;\n refetch: RefetchFn;\n metadata: Metadata;\n executionQueryDocument: DocumentNode;\n cache: ApolloCache<unknown>;\n countVariable: string | undefined;\n cursorVariable: string | undefined;\n connectionSelectionPath: string[];\n cursorValue: string | undefined;\n updater: <T>(existing: T[], incoming: T[]) => T[];\n}\n\nfunction useLoadMore({\n fragmentReference,\n refetch,\n metadata,\n executionQueryDocument,\n cache,\n countVariable,\n cursorVariable,\n connectionSelectionPath,\n cursorValue,\n updater,\n}: PaginationParams): [loadPage: PaginationFn, isLoadingMore: boolean] {\n const [isLoadingMore, setIsLoadingMore] = useState(false);\n const loadPage = useCallback<PaginationFn>(\n (countValue, options) => {\n invariant(\n countVariable,\n \"usePaginationFragment(): Expected a count variable to exist\",\n );\n invariant(\n cursorVariable,\n \"usePaginationFragment(): Expected a cursor variable to exist\",\n );\n invariant(\n cursorValue,\n \"usePaginationFragment(): Expected a cursor value to exist\",\n );\n const previousVariables = {\n ...metadata.connection?.filterVariableDefaults,\n ...fragmentReference.__fragments,\n id: fragmentReference.id,\n };\n const newVariables = {\n ...previousVariables,\n [countVariable]: countValue,\n [cursorVariable]: cursorValue,\n };\n const refetchOptions: PrivateRefetchOptions = {\n fetchPolicy: \"no-cache\",\n UNSTABLE_onCompletedWithData: (error, data) => {\n // NOTE: We can do this now already, because `refetch` wraps the\n // onCompleted callback in a batchedUpdates callback.\n setIsLoadingMore(false);\n\n if (!error) {\n invariant(\n data,\n \"usePaginationFragment(): Expected to have response data\",\n );\n const newData = metadata.rootSelection\n ? data[metadata.rootSelection]\n : data;\n const mainFragment = metadata.mainFragment;\n invariant(\n mainFragment,\n \"usePaginationFragment(): Expected mainFragment metadata\",\n );\n const cacheSelector: DataProxy.Fragment<unknown, object> = {\n // TODO: If we're dropping default Apollo Cache keys, we can probably just do the below\n id: fragmentReference.id as string,\n // id: cache.identify({\n // __typename: mainFragment.typeCondition,\n // id: fragmentReference.id as StoreValue,\n // }),\n variables: previousVariables,\n fragmentName: mainFragment.name,\n // Create new document with operation filtered out.\n fragment: {\n kind: \"Document\",\n definitions: executionQueryDocument.definitions.filter(\n (def) => def.kind === \"FragmentDefinition\",\n ),\n },\n };\n /**\n * Note: Even though we already have the latest data from the\n * useCompiledFragment hook, we can't really use that as it may contain\n * __fragments fields and we don't want to write those to the cache. If\n * we figure out a way from a field-policy's merge function to not write\n * to the cache, then that would be preferable.\n */\n const existingData = cache.readFragment(cacheSelector);\n invariant(existingData, \"Expected existing data\");\n const newCacheData = mergeEdges(\n connectionSelectionPath,\n newData,\n existingData,\n updater,\n );\n cache.writeFragment({\n ...cacheSelector,\n variables: newVariables,\n data: newCacheData,\n });\n }\n\n options?.onCompleted?.(error);\n },\n };\n // TODO: Measure if invoking `refetch` leads to React updates and if it\n // makes sense to wrap it and the following setIsLoadingMore(true)\n // call in a batchedUpdates callback.\n const disposable = refetch(\n newVariables,\n refetchOptions as RefetchOptions,\n );\n setIsLoadingMore(true);\n return disposable;\n },\n [\n fragmentReference.id,\n fragmentReference.__fragments,\n refetch,\n metadata,\n executionQueryDocument,\n cache,\n countVariable,\n cursorVariable,\n connectionSelectionPath,\n cursorValue,\n ],\n );\n return [loadPage, isLoadingMore];\n}\n\nfunction getValueAtSelectionPath(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n data: Record<string, any>,\n selectionPath: string[],\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): any {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let object: Record<string, any> = data;\n selectionPath.forEach((field) => {\n object = object[field];\n invariant(object, \"Expected path to connection in response to exist\");\n });\n return object;\n}\n\nfunction getPageInfo(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n data: Record<string, any>,\n selectionPath: string[],\n): {\n startCursor?: string;\n endCursor?: string;\n hasPreviousPage?: boolean;\n hasNextPage?: boolean;\n} {\n const object = getValueAtSelectionPath(data, selectionPath);\n const pageInfo = object.pageInfo;\n invariant(pageInfo, \"Expected to find the connection's page info object\");\n return pageInfo;\n}\n\nfunction mergeEdges(\n connectionPath: string[],\n destination: object,\n source: object,\n updater: <T>(existing: T[], incoming: T[]) => T[],\n) {\n const edgesPath = [...connectionPath, \"edges\"];\n const existingEdges = getValueAtSelectionPath(source, edgesPath);\n const newEdges = getValueAtSelectionPath(destination, edgesPath);\n const allEdges = updater(existingEdges, newEdges);\n\n const connection = getValueAtSelectionPath(destination, connectionPath);\n connection[\"edges\"] = allEdges;\n\n return destination;\n}\n\nexport function useCompiledPaginationFragment(\n documents: CompiledArtefactModule,\n fragmentReference: FragmentReference,\n): {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n data: any;\n loadNext: PaginationFn;\n loadPrevious: PaginationFn;\n hasNext: boolean;\n hasPrevious: boolean;\n isLoadingNext: boolean;\n isLoadingPrevious: boolean;\n refetch: RefetchFn;\n} {\n const { executionQueryDocument, metadata } = documents;\n invariant(\n metadata && metadata.mainFragment,\n \"usePaginationFragment(): Expected metadata to have been extracted from \" +\n \"the fragment. Did you forget to invoke the compiler?\",\n );\n invariant(\n executionQueryDocument,\n \"usePaginationFragment(): Expected fragment `%s` to be refetchable when \" +\n \"using `usePaginationFragment`. Did you forget to add a @refetchable \" +\n \"directive to the fragment?\",\n metadata.mainFragment.name,\n );\n const connectionMetadata = metadata.connection;\n invariant(\n connectionMetadata,\n \"usePaginationFragment: Expected fragment `%s` to include a \" +\n \"connection when using `usePaginationFragment`. Did you forget to add a @connection \" +\n \"directive to the connection field in the fragment?\",\n metadata.mainFragment.name,\n );\n const [data, refetch] = useCompiledRefetchableFragment(\n documents,\n fragmentReference,\n );\n const commonPaginationParams = {\n fragmentReference,\n refetch,\n metadata,\n executionQueryDocument,\n cache: useOverridenOrDefaultApolloClient().cache,\n connectionSelectionPath: connectionMetadata.selectionPath,\n };\n const pageInfo = getPageInfo(data, connectionMetadata.selectionPath);\n const [loadNext, isLoadingNext] = useLoadMore({\n ...commonPaginationParams,\n countVariable: connectionMetadata.forwardCountVariable,\n cursorVariable: connectionMetadata.forwardCursorVariable,\n cursorValue: pageInfo?.endCursor,\n updater: (existing, incoming) => [...existing, ...incoming],\n });\n const [loadPrevious, isLoadingPrevious] = useLoadMore({\n ...commonPaginationParams,\n countVariable: connectionMetadata.backwardCountVariable,\n cursorVariable: connectionMetadata.backwardCursorVariable,\n cursorValue: pageInfo?.startCursor,\n updater: (existing, incoming) => [...incoming, ...existing],\n });\n return {\n data,\n refetch,\n hasNext: !!pageInfo?.hasNextPage,\n hasPrevious: !!pageInfo?.hasPreviousPage,\n isLoadingNext,\n isLoadingPrevious,\n loadNext,\n loadPrevious,\n };\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,
|
|
4
|
+
"sourcesContent": ["import { useState, useCallback, useRef } from \"react\";\nimport { ApolloCache, DataProxy } from \"@apollo/client\";\nimport invariant from \"invariant\";\nimport { useCompiledRefetchableFragment } from \"./useCompiledRefetchableFragment\";\nimport { useOverridenOrDefaultApolloClient } from \"../../useOverridenOrDefaultApolloClient\";\n\nimport type { FragmentReference } from \"./types\";\nimport type {\n RefetchFn,\n Disposable,\n PrivateRefetchOptions,\n RefetchOptions,\n} from \"./useCompiledRefetchableFragment\";\nimport type {\n CompiledArtefactModule,\n Metadata,\n} from \"@graphitation/apollo-react-relay-duct-tape-compiler\";\nimport type { DocumentNode } from \"graphql\";\nimport { Variables } from \"../../types\";\n\nexport type PaginationFn = (\n count: number,\n options?: RefetchOptions,\n) => Disposable;\n\ninterface PaginationParams {\n fragmentReference: FragmentReference;\n refetch: RefetchFn;\n latestVariablesUsedByStandaloneRefetch: Partial<Variables>;\n metadata: Metadata;\n executionQueryDocument: DocumentNode;\n cache: ApolloCache<unknown>;\n countVariable: string | undefined;\n cursorVariable: string | undefined;\n connectionSelectionPath: string[];\n cursorValue: string | undefined;\n updater: <T>(existing: T[], incoming: T[]) => T[];\n}\n\nfunction useLoadMore({\n fragmentReference,\n refetch,\n latestVariablesUsedByStandaloneRefetch,\n metadata,\n executionQueryDocument,\n cache,\n countVariable,\n cursorVariable,\n connectionSelectionPath,\n cursorValue,\n updater,\n}: PaginationParams): [loadPage: PaginationFn, isLoadingMore: boolean] {\n const [isLoadingMore, setIsLoadingMore] = useState(false);\n const loadPage = useCallback<PaginationFn>(\n (countValue, options) => {\n invariant(\n countVariable,\n \"usePaginationFragment(): Expected a count variable to exist\",\n );\n invariant(\n cursorVariable,\n \"usePaginationFragment(): Expected a cursor variable to exist\",\n );\n invariant(\n cursorValue,\n \"usePaginationFragment(): Expected a cursor value to exist\",\n );\n const previousVariables = {\n ...metadata.connection?.filterVariableDefaults,\n ...latestVariablesUsedByStandaloneRefetch,\n ...fragmentReference.__fragments,\n id: fragmentReference.id,\n };\n const newVariables = {\n ...previousVariables,\n [countVariable]: countValue,\n [cursorVariable]: cursorValue,\n };\n const refetchOptions: PrivateRefetchOptions = {\n fetchPolicy: \"no-cache\",\n UNSTABLE_onCompletedWithData: (error, data) => {\n // NOTE: We can do this now already, because `refetch` wraps the\n // onCompleted callback in a batchedUpdates callback.\n setIsLoadingMore(false);\n\n if (!error) {\n invariant(\n data,\n \"usePaginationFragment(): Expected to have response data\",\n );\n const newData = metadata.rootSelection\n ? data[metadata.rootSelection]\n : data;\n const mainFragment = metadata.mainFragment;\n invariant(\n mainFragment,\n \"usePaginationFragment(): Expected mainFragment metadata\",\n );\n const cacheSelector: DataProxy.Fragment<unknown, object> = {\n // TODO: If we're dropping default Apollo Cache keys, we can probably just do the below\n id: fragmentReference.id as string,\n // id: cache.identify({\n // __typename: mainFragment.typeCondition,\n // id: fragmentReference.id as StoreValue,\n // }),\n variables: previousVariables,\n fragmentName: mainFragment.name,\n // Create new document with operation filtered out.\n fragment: {\n kind: \"Document\",\n definitions: executionQueryDocument.definitions.filter(\n (def) => def.kind === \"FragmentDefinition\",\n ),\n },\n };\n /**\n * Note: Even though we already have the latest data from the\n * useCompiledFragment hook, we can't really use that as it may contain\n * __fragments fields and we don't want to write those to the cache. If\n * we figure out a way from a field-policy's merge function to not write\n * to the cache, then that would be preferable.\n */\n const existingData = cache.readFragment(cacheSelector);\n invariant(existingData, \"Expected existing data\");\n const newCacheData = mergeEdges(\n connectionSelectionPath,\n newData,\n existingData,\n updater,\n );\n cache.writeFragment({\n ...cacheSelector,\n variables: newVariables,\n data: newCacheData,\n });\n }\n\n options?.onCompleted?.(error);\n },\n };\n // TODO: Measure if invoking `refetch` leads to React updates and if it\n // makes sense to wrap it and the following setIsLoadingMore(true)\n // call in a batchedUpdates callback.\n const disposable = refetch(\n newVariables,\n refetchOptions as RefetchOptions,\n );\n setIsLoadingMore(true);\n return disposable;\n },\n [\n fragmentReference.id,\n fragmentReference.__fragments,\n refetch,\n latestVariablesUsedByStandaloneRefetch,\n metadata,\n executionQueryDocument,\n cache,\n countVariable,\n cursorVariable,\n connectionSelectionPath,\n cursorValue,\n ],\n );\n return [loadPage, isLoadingMore];\n}\n\nfunction getValueAtSelectionPath(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n data: Record<string, any>,\n selectionPath: string[],\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): any {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let object: Record<string, any> = data;\n selectionPath.forEach((field) => {\n object = object[field];\n invariant(object, \"Expected path to connection in response to exist\");\n });\n return object;\n}\n\nfunction getPageInfo(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n data: Record<string, any>,\n selectionPath: string[],\n): {\n startCursor?: string;\n endCursor?: string;\n hasPreviousPage?: boolean;\n hasNextPage?: boolean;\n} {\n const object = getValueAtSelectionPath(data, selectionPath);\n const pageInfo = object.pageInfo;\n invariant(pageInfo, \"Expected to find the connection's page info object\");\n return pageInfo;\n}\n\nfunction mergeEdges(\n connectionPath: string[],\n destination: object,\n source: object,\n updater: <T>(existing: T[], incoming: T[]) => T[],\n) {\n const edgesPath = [...connectionPath, \"edges\"];\n const existingEdges = getValueAtSelectionPath(source, edgesPath);\n const newEdges = getValueAtSelectionPath(destination, edgesPath);\n const allEdges = updater(existingEdges, newEdges);\n\n const connection = getValueAtSelectionPath(destination, connectionPath);\n connection[\"edges\"] = allEdges;\n\n return destination;\n}\n\nexport function useCompiledPaginationFragment(\n documents: CompiledArtefactModule,\n fragmentReference: FragmentReference,\n): {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n data: any;\n loadNext: PaginationFn;\n loadPrevious: PaginationFn;\n hasNext: boolean;\n hasPrevious: boolean;\n isLoadingNext: boolean;\n isLoadingPrevious: boolean;\n refetch: RefetchFn;\n} {\n const { executionQueryDocument, metadata } = documents;\n invariant(\n metadata && metadata.mainFragment,\n \"usePaginationFragment(): Expected metadata to have been extracted from \" +\n \"the fragment. Did you forget to invoke the compiler?\",\n );\n invariant(\n executionQueryDocument,\n \"usePaginationFragment(): Expected fragment `%s` to be refetchable when \" +\n \"using `usePaginationFragment`. Did you forget to add a @refetchable \" +\n \"directive to the fragment?\",\n metadata.mainFragment.name,\n );\n const connectionMetadata = metadata.connection;\n invariant(\n connectionMetadata,\n \"usePaginationFragment: Expected fragment `%s` to include a \" +\n \"connection when using `usePaginationFragment`. Did you forget to add a @connection \" +\n \"directive to the connection field in the fragment?\",\n metadata.mainFragment.name,\n );\n const [data, refetch] = useCompiledRefetchableFragment(\n documents,\n fragmentReference,\n );\n\n // Consumers might want to not only use loadNext/loadPrevious with pagination fragment but also standalone refetch,\n // for example to change the variables that decide on connection filtering. To make sure that loadNext/loadPrevious\n // respects the variables used by standalone refetch, we store them in a ref and pass them to useLoadMore.\n const latestVariablesUsedByStandaloneRefetch = useRef({});\n const storeVariablesAndRefetch = useCallback<RefetchFn>(\n (variables: Partial<Variables>, options?: RefetchOptions) => {\n latestVariablesUsedByStandaloneRefetch.current = variables;\n return refetch(variables, options);\n },\n [],\n );\n\n const commonPaginationParams = {\n fragmentReference,\n refetch,\n latestVariablesUsedByStandaloneRefetch:\n latestVariablesUsedByStandaloneRefetch.current,\n metadata,\n executionQueryDocument,\n cache: useOverridenOrDefaultApolloClient().cache,\n connectionSelectionPath: connectionMetadata.selectionPath,\n };\n const pageInfo = getPageInfo(data, connectionMetadata.selectionPath);\n const [loadNext, isLoadingNext] = useLoadMore({\n ...commonPaginationParams,\n countVariable: connectionMetadata.forwardCountVariable,\n cursorVariable: connectionMetadata.forwardCursorVariable,\n cursorValue: pageInfo?.endCursor,\n updater: (existing, incoming) => [...existing, ...incoming],\n });\n const [loadPrevious, isLoadingPrevious] = useLoadMore({\n ...commonPaginationParams,\n countVariable: connectionMetadata.backwardCountVariable,\n cursorVariable: connectionMetadata.backwardCursorVariable,\n cursorValue: pageInfo?.startCursor,\n updater: (existing, incoming) => [...incoming, ...existing],\n });\n return {\n data,\n refetch: storeVariablesAndRefetch,\n hasNext: !!pageInfo?.hasNextPage,\n hasPrevious: !!pageInfo?.hasPreviousPage,\n isLoadingNext,\n isLoadingPrevious,\n loadNext,\n loadPrevious,\n };\n}\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
6
|
"names": ["invariant", "_a"]
|
|
7
7
|
}
|
|
@@ -19,13 +19,14 @@ var __spreadValues = (a, b) => {
|
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
20
|
|
|
21
21
|
// src/storeObservation/compiledHooks/useCompiledPaginationFragment.ts
|
|
22
|
-
import { useState, useCallback } from "react";
|
|
22
|
+
import { useState, useCallback, useRef } from "react";
|
|
23
23
|
import invariant from "invariant";
|
|
24
24
|
import { useCompiledRefetchableFragment } from "./useCompiledRefetchableFragment.mjs";
|
|
25
25
|
import { useOverridenOrDefaultApolloClient } from "../../useOverridenOrDefaultApolloClient.mjs";
|
|
26
26
|
function useLoadMore({
|
|
27
27
|
fragmentReference,
|
|
28
28
|
refetch,
|
|
29
|
+
latestVariablesUsedByStandaloneRefetch,
|
|
29
30
|
metadata,
|
|
30
31
|
executionQueryDocument,
|
|
31
32
|
cache,
|
|
@@ -51,7 +52,7 @@ function useLoadMore({
|
|
|
51
52
|
cursorValue,
|
|
52
53
|
"usePaginationFragment(): Expected a cursor value to exist"
|
|
53
54
|
);
|
|
54
|
-
const previousVariables = __spreadProps(__spreadValues(__spreadValues({}, (_a = metadata.connection) == null ? void 0 : _a.filterVariableDefaults), fragmentReference.__fragments), {
|
|
55
|
+
const previousVariables = __spreadProps(__spreadValues(__spreadValues(__spreadValues({}, (_a = metadata.connection) == null ? void 0 : _a.filterVariableDefaults), latestVariablesUsedByStandaloneRefetch), fragmentReference.__fragments), {
|
|
55
56
|
id: fragmentReference.id
|
|
56
57
|
});
|
|
57
58
|
const newVariables = __spreadProps(__spreadValues({}, previousVariables), {
|
|
@@ -118,6 +119,7 @@ function useLoadMore({
|
|
|
118
119
|
fragmentReference.id,
|
|
119
120
|
fragmentReference.__fragments,
|
|
120
121
|
refetch,
|
|
122
|
+
latestVariablesUsedByStandaloneRefetch,
|
|
121
123
|
metadata,
|
|
122
124
|
executionQueryDocument,
|
|
123
125
|
cache,
|
|
@@ -173,9 +175,18 @@ function useCompiledPaginationFragment(documents, fragmentReference) {
|
|
|
173
175
|
documents,
|
|
174
176
|
fragmentReference
|
|
175
177
|
);
|
|
178
|
+
const latestVariablesUsedByStandaloneRefetch = useRef({});
|
|
179
|
+
const storeVariablesAndRefetch = useCallback(
|
|
180
|
+
(variables, options) => {
|
|
181
|
+
latestVariablesUsedByStandaloneRefetch.current = variables;
|
|
182
|
+
return refetch(variables, options);
|
|
183
|
+
},
|
|
184
|
+
[]
|
|
185
|
+
);
|
|
176
186
|
const commonPaginationParams = {
|
|
177
187
|
fragmentReference,
|
|
178
188
|
refetch,
|
|
189
|
+
latestVariablesUsedByStandaloneRefetch: latestVariablesUsedByStandaloneRefetch.current,
|
|
179
190
|
metadata,
|
|
180
191
|
executionQueryDocument,
|
|
181
192
|
cache: useOverridenOrDefaultApolloClient().cache,
|
|
@@ -196,7 +207,7 @@ function useCompiledPaginationFragment(documents, fragmentReference) {
|
|
|
196
207
|
}));
|
|
197
208
|
return {
|
|
198
209
|
data,
|
|
199
|
-
refetch,
|
|
210
|
+
refetch: storeVariablesAndRefetch,
|
|
200
211
|
hasNext: !!(pageInfo == null ? void 0 : pageInfo.hasNextPage),
|
|
201
212
|
hasPrevious: !!(pageInfo == null ? void 0 : pageInfo.hasPreviousPage),
|
|
202
213
|
isLoadingNext,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/storeObservation/compiledHooks/useCompiledPaginationFragment.ts"],
|
|
4
|
-
"sourcesContent": ["import { useState, useCallback } from \"react\";\nimport { ApolloCache, DataProxy } from \"@apollo/client\";\nimport invariant from \"invariant\";\nimport { useCompiledRefetchableFragment } from \"./useCompiledRefetchableFragment\";\nimport { useOverridenOrDefaultApolloClient } from \"../../useOverridenOrDefaultApolloClient\";\n\nimport type { FragmentReference } from \"./types\";\nimport type {\n RefetchFn,\n Disposable,\n PrivateRefetchOptions,\n RefetchOptions,\n} from \"./useCompiledRefetchableFragment\";\nimport type {\n CompiledArtefactModule,\n Metadata,\n} from \"@graphitation/apollo-react-relay-duct-tape-compiler\";\nimport type { DocumentNode } from \"graphql\";\n\nexport type PaginationFn = (\n count: number,\n options?: RefetchOptions,\n) => Disposable;\n\ninterface PaginationParams {\n fragmentReference: FragmentReference;\n refetch: RefetchFn;\n metadata: Metadata;\n executionQueryDocument: DocumentNode;\n cache: ApolloCache<unknown>;\n countVariable: string | undefined;\n cursorVariable: string | undefined;\n connectionSelectionPath: string[];\n cursorValue: string | undefined;\n updater: <T>(existing: T[], incoming: T[]) => T[];\n}\n\nfunction useLoadMore({\n fragmentReference,\n refetch,\n metadata,\n executionQueryDocument,\n cache,\n countVariable,\n cursorVariable,\n connectionSelectionPath,\n cursorValue,\n updater,\n}: PaginationParams): [loadPage: PaginationFn, isLoadingMore: boolean] {\n const [isLoadingMore, setIsLoadingMore] = useState(false);\n const loadPage = useCallback<PaginationFn>(\n (countValue, options) => {\n invariant(\n countVariable,\n \"usePaginationFragment(): Expected a count variable to exist\",\n );\n invariant(\n cursorVariable,\n \"usePaginationFragment(): Expected a cursor variable to exist\",\n );\n invariant(\n cursorValue,\n \"usePaginationFragment(): Expected a cursor value to exist\",\n );\n const previousVariables = {\n ...metadata.connection?.filterVariableDefaults,\n ...fragmentReference.__fragments,\n id: fragmentReference.id,\n };\n const newVariables = {\n ...previousVariables,\n [countVariable]: countValue,\n [cursorVariable]: cursorValue,\n };\n const refetchOptions: PrivateRefetchOptions = {\n fetchPolicy: \"no-cache\",\n UNSTABLE_onCompletedWithData: (error, data) => {\n // NOTE: We can do this now already, because `refetch` wraps the\n // onCompleted callback in a batchedUpdates callback.\n setIsLoadingMore(false);\n\n if (!error) {\n invariant(\n data,\n \"usePaginationFragment(): Expected to have response data\",\n );\n const newData = metadata.rootSelection\n ? data[metadata.rootSelection]\n : data;\n const mainFragment = metadata.mainFragment;\n invariant(\n mainFragment,\n \"usePaginationFragment(): Expected mainFragment metadata\",\n );\n const cacheSelector: DataProxy.Fragment<unknown, object> = {\n // TODO: If we're dropping default Apollo Cache keys, we can probably just do the below\n id: fragmentReference.id as string,\n // id: cache.identify({\n // __typename: mainFragment.typeCondition,\n // id: fragmentReference.id as StoreValue,\n // }),\n variables: previousVariables,\n fragmentName: mainFragment.name,\n // Create new document with operation filtered out.\n fragment: {\n kind: \"Document\",\n definitions: executionQueryDocument.definitions.filter(\n (def) => def.kind === \"FragmentDefinition\",\n ),\n },\n };\n /**\n * Note: Even though we already have the latest data from the\n * useCompiledFragment hook, we can't really use that as it may contain\n * __fragments fields and we don't want to write those to the cache. If\n * we figure out a way from a field-policy's merge function to not write\n * to the cache, then that would be preferable.\n */\n const existingData = cache.readFragment(cacheSelector);\n invariant(existingData, \"Expected existing data\");\n const newCacheData = mergeEdges(\n connectionSelectionPath,\n newData,\n existingData,\n updater,\n );\n cache.writeFragment({\n ...cacheSelector,\n variables: newVariables,\n data: newCacheData,\n });\n }\n\n options?.onCompleted?.(error);\n },\n };\n // TODO: Measure if invoking `refetch` leads to React updates and if it\n // makes sense to wrap it and the following setIsLoadingMore(true)\n // call in a batchedUpdates callback.\n const disposable = refetch(\n newVariables,\n refetchOptions as RefetchOptions,\n );\n setIsLoadingMore(true);\n return disposable;\n },\n [\n fragmentReference.id,\n fragmentReference.__fragments,\n refetch,\n metadata,\n executionQueryDocument,\n cache,\n countVariable,\n cursorVariable,\n connectionSelectionPath,\n cursorValue,\n ],\n );\n return [loadPage, isLoadingMore];\n}\n\nfunction getValueAtSelectionPath(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n data: Record<string, any>,\n selectionPath: string[],\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): any {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let object: Record<string, any> = data;\n selectionPath.forEach((field) => {\n object = object[field];\n invariant(object, \"Expected path to connection in response to exist\");\n });\n return object;\n}\n\nfunction getPageInfo(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n data: Record<string, any>,\n selectionPath: string[],\n): {\n startCursor?: string;\n endCursor?: string;\n hasPreviousPage?: boolean;\n hasNextPage?: boolean;\n} {\n const object = getValueAtSelectionPath(data, selectionPath);\n const pageInfo = object.pageInfo;\n invariant(pageInfo, \"Expected to find the connection's page info object\");\n return pageInfo;\n}\n\nfunction mergeEdges(\n connectionPath: string[],\n destination: object,\n source: object,\n updater: <T>(existing: T[], incoming: T[]) => T[],\n) {\n const edgesPath = [...connectionPath, \"edges\"];\n const existingEdges = getValueAtSelectionPath(source, edgesPath);\n const newEdges = getValueAtSelectionPath(destination, edgesPath);\n const allEdges = updater(existingEdges, newEdges);\n\n const connection = getValueAtSelectionPath(destination, connectionPath);\n connection[\"edges\"] = allEdges;\n\n return destination;\n}\n\nexport function useCompiledPaginationFragment(\n documents: CompiledArtefactModule,\n fragmentReference: FragmentReference,\n): {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n data: any;\n loadNext: PaginationFn;\n loadPrevious: PaginationFn;\n hasNext: boolean;\n hasPrevious: boolean;\n isLoadingNext: boolean;\n isLoadingPrevious: boolean;\n refetch: RefetchFn;\n} {\n const { executionQueryDocument, metadata } = documents;\n invariant(\n metadata && metadata.mainFragment,\n \"usePaginationFragment(): Expected metadata to have been extracted from \" +\n \"the fragment. Did you forget to invoke the compiler?\",\n );\n invariant(\n executionQueryDocument,\n \"usePaginationFragment(): Expected fragment `%s` to be refetchable when \" +\n \"using `usePaginationFragment`. Did you forget to add a @refetchable \" +\n \"directive to the fragment?\",\n metadata.mainFragment.name,\n );\n const connectionMetadata = metadata.connection;\n invariant(\n connectionMetadata,\n \"usePaginationFragment: Expected fragment `%s` to include a \" +\n \"connection when using `usePaginationFragment`. Did you forget to add a @connection \" +\n \"directive to the connection field in the fragment?\",\n metadata.mainFragment.name,\n );\n const [data, refetch] = useCompiledRefetchableFragment(\n documents,\n fragmentReference,\n );\n const commonPaginationParams = {\n fragmentReference,\n refetch,\n metadata,\n executionQueryDocument,\n cache: useOverridenOrDefaultApolloClient().cache,\n connectionSelectionPath: connectionMetadata.selectionPath,\n };\n const pageInfo = getPageInfo(data, connectionMetadata.selectionPath);\n const [loadNext, isLoadingNext] = useLoadMore({\n ...commonPaginationParams,\n countVariable: connectionMetadata.forwardCountVariable,\n cursorVariable: connectionMetadata.forwardCursorVariable,\n cursorValue: pageInfo?.endCursor,\n updater: (existing, incoming) => [...existing, ...incoming],\n });\n const [loadPrevious, isLoadingPrevious] = useLoadMore({\n ...commonPaginationParams,\n countVariable: connectionMetadata.backwardCountVariable,\n cursorVariable: connectionMetadata.backwardCursorVariable,\n cursorValue: pageInfo?.startCursor,\n updater: (existing, incoming) => [...incoming, ...existing],\n });\n return {\n data,\n refetch,\n hasNext: !!pageInfo?.hasNextPage,\n hasPrevious: !!pageInfo?.hasPreviousPage,\n isLoadingNext,\n isLoadingPrevious,\n loadNext,\n loadPrevious,\n };\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,UAAU,
|
|
4
|
+
"sourcesContent": ["import { useState, useCallback, useRef } from \"react\";\nimport { ApolloCache, DataProxy } from \"@apollo/client\";\nimport invariant from \"invariant\";\nimport { useCompiledRefetchableFragment } from \"./useCompiledRefetchableFragment\";\nimport { useOverridenOrDefaultApolloClient } from \"../../useOverridenOrDefaultApolloClient\";\n\nimport type { FragmentReference } from \"./types\";\nimport type {\n RefetchFn,\n Disposable,\n PrivateRefetchOptions,\n RefetchOptions,\n} from \"./useCompiledRefetchableFragment\";\nimport type {\n CompiledArtefactModule,\n Metadata,\n} from \"@graphitation/apollo-react-relay-duct-tape-compiler\";\nimport type { DocumentNode } from \"graphql\";\nimport { Variables } from \"../../types\";\n\nexport type PaginationFn = (\n count: number,\n options?: RefetchOptions,\n) => Disposable;\n\ninterface PaginationParams {\n fragmentReference: FragmentReference;\n refetch: RefetchFn;\n latestVariablesUsedByStandaloneRefetch: Partial<Variables>;\n metadata: Metadata;\n executionQueryDocument: DocumentNode;\n cache: ApolloCache<unknown>;\n countVariable: string | undefined;\n cursorVariable: string | undefined;\n connectionSelectionPath: string[];\n cursorValue: string | undefined;\n updater: <T>(existing: T[], incoming: T[]) => T[];\n}\n\nfunction useLoadMore({\n fragmentReference,\n refetch,\n latestVariablesUsedByStandaloneRefetch,\n metadata,\n executionQueryDocument,\n cache,\n countVariable,\n cursorVariable,\n connectionSelectionPath,\n cursorValue,\n updater,\n}: PaginationParams): [loadPage: PaginationFn, isLoadingMore: boolean] {\n const [isLoadingMore, setIsLoadingMore] = useState(false);\n const loadPage = useCallback<PaginationFn>(\n (countValue, options) => {\n invariant(\n countVariable,\n \"usePaginationFragment(): Expected a count variable to exist\",\n );\n invariant(\n cursorVariable,\n \"usePaginationFragment(): Expected a cursor variable to exist\",\n );\n invariant(\n cursorValue,\n \"usePaginationFragment(): Expected a cursor value to exist\",\n );\n const previousVariables = {\n ...metadata.connection?.filterVariableDefaults,\n ...latestVariablesUsedByStandaloneRefetch,\n ...fragmentReference.__fragments,\n id: fragmentReference.id,\n };\n const newVariables = {\n ...previousVariables,\n [countVariable]: countValue,\n [cursorVariable]: cursorValue,\n };\n const refetchOptions: PrivateRefetchOptions = {\n fetchPolicy: \"no-cache\",\n UNSTABLE_onCompletedWithData: (error, data) => {\n // NOTE: We can do this now already, because `refetch` wraps the\n // onCompleted callback in a batchedUpdates callback.\n setIsLoadingMore(false);\n\n if (!error) {\n invariant(\n data,\n \"usePaginationFragment(): Expected to have response data\",\n );\n const newData = metadata.rootSelection\n ? data[metadata.rootSelection]\n : data;\n const mainFragment = metadata.mainFragment;\n invariant(\n mainFragment,\n \"usePaginationFragment(): Expected mainFragment metadata\",\n );\n const cacheSelector: DataProxy.Fragment<unknown, object> = {\n // TODO: If we're dropping default Apollo Cache keys, we can probably just do the below\n id: fragmentReference.id as string,\n // id: cache.identify({\n // __typename: mainFragment.typeCondition,\n // id: fragmentReference.id as StoreValue,\n // }),\n variables: previousVariables,\n fragmentName: mainFragment.name,\n // Create new document with operation filtered out.\n fragment: {\n kind: \"Document\",\n definitions: executionQueryDocument.definitions.filter(\n (def) => def.kind === \"FragmentDefinition\",\n ),\n },\n };\n /**\n * Note: Even though we already have the latest data from the\n * useCompiledFragment hook, we can't really use that as it may contain\n * __fragments fields and we don't want to write those to the cache. If\n * we figure out a way from a field-policy's merge function to not write\n * to the cache, then that would be preferable.\n */\n const existingData = cache.readFragment(cacheSelector);\n invariant(existingData, \"Expected existing data\");\n const newCacheData = mergeEdges(\n connectionSelectionPath,\n newData,\n existingData,\n updater,\n );\n cache.writeFragment({\n ...cacheSelector,\n variables: newVariables,\n data: newCacheData,\n });\n }\n\n options?.onCompleted?.(error);\n },\n };\n // TODO: Measure if invoking `refetch` leads to React updates and if it\n // makes sense to wrap it and the following setIsLoadingMore(true)\n // call in a batchedUpdates callback.\n const disposable = refetch(\n newVariables,\n refetchOptions as RefetchOptions,\n );\n setIsLoadingMore(true);\n return disposable;\n },\n [\n fragmentReference.id,\n fragmentReference.__fragments,\n refetch,\n latestVariablesUsedByStandaloneRefetch,\n metadata,\n executionQueryDocument,\n cache,\n countVariable,\n cursorVariable,\n connectionSelectionPath,\n cursorValue,\n ],\n );\n return [loadPage, isLoadingMore];\n}\n\nfunction getValueAtSelectionPath(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n data: Record<string, any>,\n selectionPath: string[],\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): any {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let object: Record<string, any> = data;\n selectionPath.forEach((field) => {\n object = object[field];\n invariant(object, \"Expected path to connection in response to exist\");\n });\n return object;\n}\n\nfunction getPageInfo(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n data: Record<string, any>,\n selectionPath: string[],\n): {\n startCursor?: string;\n endCursor?: string;\n hasPreviousPage?: boolean;\n hasNextPage?: boolean;\n} {\n const object = getValueAtSelectionPath(data, selectionPath);\n const pageInfo = object.pageInfo;\n invariant(pageInfo, \"Expected to find the connection's page info object\");\n return pageInfo;\n}\n\nfunction mergeEdges(\n connectionPath: string[],\n destination: object,\n source: object,\n updater: <T>(existing: T[], incoming: T[]) => T[],\n) {\n const edgesPath = [...connectionPath, \"edges\"];\n const existingEdges = getValueAtSelectionPath(source, edgesPath);\n const newEdges = getValueAtSelectionPath(destination, edgesPath);\n const allEdges = updater(existingEdges, newEdges);\n\n const connection = getValueAtSelectionPath(destination, connectionPath);\n connection[\"edges\"] = allEdges;\n\n return destination;\n}\n\nexport function useCompiledPaginationFragment(\n documents: CompiledArtefactModule,\n fragmentReference: FragmentReference,\n): {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n data: any;\n loadNext: PaginationFn;\n loadPrevious: PaginationFn;\n hasNext: boolean;\n hasPrevious: boolean;\n isLoadingNext: boolean;\n isLoadingPrevious: boolean;\n refetch: RefetchFn;\n} {\n const { executionQueryDocument, metadata } = documents;\n invariant(\n metadata && metadata.mainFragment,\n \"usePaginationFragment(): Expected metadata to have been extracted from \" +\n \"the fragment. Did you forget to invoke the compiler?\",\n );\n invariant(\n executionQueryDocument,\n \"usePaginationFragment(): Expected fragment `%s` to be refetchable when \" +\n \"using `usePaginationFragment`. Did you forget to add a @refetchable \" +\n \"directive to the fragment?\",\n metadata.mainFragment.name,\n );\n const connectionMetadata = metadata.connection;\n invariant(\n connectionMetadata,\n \"usePaginationFragment: Expected fragment `%s` to include a \" +\n \"connection when using `usePaginationFragment`. Did you forget to add a @connection \" +\n \"directive to the connection field in the fragment?\",\n metadata.mainFragment.name,\n );\n const [data, refetch] = useCompiledRefetchableFragment(\n documents,\n fragmentReference,\n );\n\n // Consumers might want to not only use loadNext/loadPrevious with pagination fragment but also standalone refetch,\n // for example to change the variables that decide on connection filtering. To make sure that loadNext/loadPrevious\n // respects the variables used by standalone refetch, we store them in a ref and pass them to useLoadMore.\n const latestVariablesUsedByStandaloneRefetch = useRef({});\n const storeVariablesAndRefetch = useCallback<RefetchFn>(\n (variables: Partial<Variables>, options?: RefetchOptions) => {\n latestVariablesUsedByStandaloneRefetch.current = variables;\n return refetch(variables, options);\n },\n [],\n );\n\n const commonPaginationParams = {\n fragmentReference,\n refetch,\n latestVariablesUsedByStandaloneRefetch:\n latestVariablesUsedByStandaloneRefetch.current,\n metadata,\n executionQueryDocument,\n cache: useOverridenOrDefaultApolloClient().cache,\n connectionSelectionPath: connectionMetadata.selectionPath,\n };\n const pageInfo = getPageInfo(data, connectionMetadata.selectionPath);\n const [loadNext, isLoadingNext] = useLoadMore({\n ...commonPaginationParams,\n countVariable: connectionMetadata.forwardCountVariable,\n cursorVariable: connectionMetadata.forwardCursorVariable,\n cursorValue: pageInfo?.endCursor,\n updater: (existing, incoming) => [...existing, ...incoming],\n });\n const [loadPrevious, isLoadingPrevious] = useLoadMore({\n ...commonPaginationParams,\n countVariable: connectionMetadata.backwardCountVariable,\n cursorVariable: connectionMetadata.backwardCursorVariable,\n cursorValue: pageInfo?.startCursor,\n updater: (existing, incoming) => [...incoming, ...existing],\n });\n return {\n data,\n refetch: storeVariablesAndRefetch,\n hasNext: !!pageInfo?.hasNextPage,\n hasPrevious: !!pageInfo?.hasPreviousPage,\n isLoadingNext,\n isLoadingPrevious,\n loadNext,\n loadPrevious,\n };\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,UAAU,aAAa,cAAc;AAE9C,OAAO,eAAe;AACtB,SAAS,sCAAsC;AAC/C,SAAS,yCAAyC;AAmClD,SAAS,YAAY;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAuE;AACrE,QAAM,CAAC,eAAe,gBAAgB,IAAI,SAAS,KAAK;AACxD,QAAM,WAAW;AAAA,IACf,CAAC,YAAY,YAAY;AAtD7B;AAuDM;AAAA,QACE;AAAA,QACA;AAAA,MACF;AACA;AAAA,QACE;AAAA,QACA;AAAA,MACF;AACA;AAAA,QACE;AAAA,QACA;AAAA,MACF;AACA,YAAM,oBAAoB,gEACrB,cAAS,eAAT,mBAAqB,yBACrB,yCACA,kBAAkB,cAHG;AAAA,QAIxB,IAAI,kBAAkB;AAAA,MACxB;AACA,YAAM,eAAe,iCAChB,oBADgB;AAAA,QAEnB,CAAC,aAAa,GAAG;AAAA,QACjB,CAAC,cAAc,GAAG;AAAA,MACpB;AACA,YAAM,iBAAwC;AAAA,QAC5C,aAAa;AAAA,QACb,8BAA8B,CAAC,OAAO,SAAS;AAhFvD,cAAAA;AAmFU,2BAAiB,KAAK;AAEtB,cAAI,CAAC,OAAO;AACV;AAAA,cACE;AAAA,cACA;AAAA,YACF;AACA,kBAAM,UAAU,SAAS,gBACrB,KAAK,SAAS,aAAa,IAC3B;AACJ,kBAAM,eAAe,SAAS;AAC9B;AAAA,cACE;AAAA,cACA;AAAA,YACF;AACA,kBAAM,gBAAqD;AAAA;AAAA,cAEzD,IAAI,kBAAkB;AAAA;AAAA;AAAA;AAAA;AAAA,cAKtB,WAAW;AAAA,cACX,cAAc,aAAa;AAAA;AAAA,cAE3B,UAAU;AAAA,gBACR,MAAM;AAAA,gBACN,aAAa,uBAAuB,YAAY;AAAA,kBAC9C,CAAC,QAAQ,IAAI,SAAS;AAAA,gBACxB;AAAA,cACF;AAAA,YACF;AAQA,kBAAM,eAAe,MAAM,aAAa,aAAa;AACrD,sBAAU,cAAc,wBAAwB;AAChD,kBAAM,eAAe;AAAA,cACnB;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,YACF;AACA,kBAAM,cAAc,iCACf,gBADe;AAAA,cAElB,WAAW;AAAA,cACX,MAAM;AAAA,YACR,EAAC;AAAA,UACH;AAEA,WAAAA,MAAA,mCAAS,gBAAT,gBAAAA,IAAA,cAAuB;AAAA,QACzB;AAAA,MACF;AAIA,YAAM,aAAa;AAAA,QACjB;AAAA,QACA;AAAA,MACF;AACA,uBAAiB,IAAI;AACrB,aAAO;AAAA,IACT;AAAA,IACA;AAAA,MACE,kBAAkB;AAAA,MAClB,kBAAkB;AAAA,MAClB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACA,SAAO,CAAC,UAAU,aAAa;AACjC;AAEA,SAAS,wBAEP,MACA,eAEK;AAEL,MAAI,SAA8B;AAClC,gBAAc,QAAQ,CAAC,UAAU;AAC/B,aAAS,OAAO,KAAK;AACrB,cAAU,QAAQ,kDAAkD;AAAA,EACtE,CAAC;AACD,SAAO;AACT;AAEA,SAAS,YAEP,MACA,eAMA;AACA,QAAM,SAAS,wBAAwB,MAAM,aAAa;AAC1D,QAAM,WAAW,OAAO;AACxB,YAAU,UAAU,oDAAoD;AACxE,SAAO;AACT;AAEA,SAAS,WACP,gBACA,aACA,QACA,SACA;AACA,QAAM,YAAY,CAAC,GAAG,gBAAgB,OAAO;AAC7C,QAAM,gBAAgB,wBAAwB,QAAQ,SAAS;AAC/D,QAAM,WAAW,wBAAwB,aAAa,SAAS;AAC/D,QAAM,WAAW,QAAQ,eAAe,QAAQ;AAEhD,QAAM,aAAa,wBAAwB,aAAa,cAAc;AACtE,aAAW,OAAO,IAAI;AAEtB,SAAO;AACT;AAEO,SAAS,8BACd,WACA,mBAWA;AACA,QAAM,EAAE,wBAAwB,SAAS,IAAI;AAC7C;AAAA,IACE,YAAY,SAAS;AAAA,IACrB;AAAA,EAEF;AACA;AAAA,IACE;AAAA,IACA;AAAA,IAGA,SAAS,aAAa;AAAA,EACxB;AACA,QAAM,qBAAqB,SAAS;AACpC;AAAA,IACE;AAAA,IACA;AAAA,IAGA,SAAS,aAAa;AAAA,EACxB;AACA,QAAM,CAAC,MAAM,OAAO,IAAI;AAAA,IACtB;AAAA,IACA;AAAA,EACF;AAKA,QAAM,yCAAyC,OAAO,CAAC,CAAC;AACxD,QAAM,2BAA2B;AAAA,IAC/B,CAAC,WAA+B,YAA6B;AAC3D,6CAAuC,UAAU;AACjD,aAAO,QAAQ,WAAW,OAAO;AAAA,IACnC;AAAA,IACA,CAAC;AAAA,EACH;AAEA,QAAM,yBAAyB;AAAA,IAC7B;AAAA,IACA;AAAA,IACA,wCACE,uCAAuC;AAAA,IACzC;AAAA,IACA;AAAA,IACA,OAAO,kCAAkC,EAAE;AAAA,IAC3C,yBAAyB,mBAAmB;AAAA,EAC9C;AACA,QAAM,WAAW,YAAY,MAAM,mBAAmB,aAAa;AACnE,QAAM,CAAC,UAAU,aAAa,IAAI,YAAY,iCACzC,yBADyC;AAAA,IAE5C,eAAe,mBAAmB;AAAA,IAClC,gBAAgB,mBAAmB;AAAA,IACnC,aAAa,qCAAU;AAAA,IACvB,SAAS,CAAC,UAAU,aAAa,CAAC,GAAG,UAAU,GAAG,QAAQ;AAAA,EAC5D,EAAC;AACD,QAAM,CAAC,cAAc,iBAAiB,IAAI,YAAY,iCACjD,yBADiD;AAAA,IAEpD,eAAe,mBAAmB;AAAA,IAClC,gBAAgB,mBAAmB;AAAA,IACnC,aAAa,qCAAU;AAAA,IACvB,SAAS,CAAC,UAAU,aAAa,CAAC,GAAG,UAAU,GAAG,QAAQ;AAAA,EAC5D,EAAC;AACD,SAAO;AAAA,IACL;AAAA,IACA,SAAS;AAAA,IACT,SAAS,CAAC,EAAC,qCAAU;AAAA,IACrB,aAAa,CAAC,EAAC,qCAAU;AAAA,IACzB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;",
|
|
6
6
|
"names": ["_a"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@graphitation/apollo-react-relay-duct-tape",
|
|
3
3
|
"description": "A compatibility wrapper that provides the react-relay API on top of Apollo Client.",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "1.0.
|
|
5
|
+
"version": "1.0.30",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "https://github.com/microsoft/graphitation.git",
|