@graphitation/apollo-react-relay-duct-tape 1.0.8 → 1.0.10
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 +19 -2
- package/README.md +5 -0
- package/lib/hooks.d.ts +9 -2
- package/lib/hooks.d.ts.map +1 -1
- package/lib/hooks.js +22 -6
- package/lib/hooks.js.map +2 -2
- package/lib/hooks.mjs +22 -6
- package/lib/hooks.mjs.map +2 -2
- package/lib/storeObservation/compiledHooks/useCompiledPaginationFragment.d.ts.map +1 -1
- package/lib/storeObservation/compiledHooks/useCompiledPaginationFragment.js +6 -4
- package/lib/storeObservation/compiledHooks/useCompiledPaginationFragment.js.map +2 -2
- package/lib/storeObservation/compiledHooks/useCompiledPaginationFragment.mjs +6 -4
- package/lib/storeObservation/compiledHooks/useCompiledPaginationFragment.mjs.map +2 -2
- package/lib/storeObservation/getPossibleTypesAndDataIdFromNode.d.ts +7 -0
- package/lib/storeObservation/getPossibleTypesAndDataIdFromNode.d.ts.map +1 -0
- package/lib/storeObservation/getPossibleTypesAndDataIdFromNode.js +63 -0
- package/lib/storeObservation/getPossibleTypesAndDataIdFromNode.js.map +7 -0
- package/lib/storeObservation/getPossibleTypesAndDataIdFromNode.mjs +34 -0
- package/lib/storeObservation/getPossibleTypesAndDataIdFromNode.mjs.map +7 -0
- package/lib/storeObservation/index.d.ts +1 -0
- package/lib/storeObservation/index.d.ts.map +1 -1
- package/lib/storeObservation/index.js +1 -0
- package/lib/storeObservation/index.js.map +2 -2
- package/lib/storeObservation/index.mjs +1 -0
- package/lib/storeObservation/index.mjs.map +2 -2
- package/package.json +2 -2
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__/nodeFromCacheFieldPolicy.test.ts":"8","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/compiledHooks/index.ts":"9","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/compiledHooks/types.ts":"10","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/compiledHooks/useCompiledFragment.ts":"11","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/compiledHooks/useCompiledLazyLoadQuery.ts":"12","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/compiledHooks/useCompiledPaginationFragment.ts":"13","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/compiledHooks/useCompiledRefetchableFragment.ts":"14","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/compiledHooks/useDeepCompareMemoize.ts":"15","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/compiledHooks/useForceUpdate.ts":"16","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/fragmentReferencesFieldPolicy.ts":"17","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/index.ts":"18","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/nodeFromCacheFieldPolicy.ts":"19","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/shallowCompareFragmentReferences.ts":"20","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/typePolicies.ts":"21","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/types.ts":"22","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/useOverridenOrDefaultApolloClient.ts":"23"},{"size":11195,"mtime":1690011033926,"results":"24","hashOfConfig":"25"},{"size":1917,"mtime":1690011033926,"results":"26","hashOfConfig":"25"},{"size":690,"mtime":1690011033926,"results":"27","hashOfConfig":"25"},{"size":11575,"mtime":1690011033926,"results":"28","hashOfConfig":"25"},{"size":174,"mtime":1690011033926,"results":"29","hashOfConfig":"25"},{"size":33757,"mtime":1690011033926,"results":"30","hashOfConfig":"25"},{"size":1839,"mtime":1690011033926,"results":"31","hashOfConfig":"25"},{"size":3041,"mtime":1690011033926,"results":"32","hashOfConfig":"25"},{"size":445,"mtime":1690011033926,"results":"33","hashOfConfig":"25"},{"size":575,"mtime":1690011033926,"results":"34","hashOfConfig":"25"},{"size":2426,"mtime":1690011033926,"results":"35","hashOfConfig":"25"},{"size":3662,"mtime":1690011033926,"results":"36","hashOfConfig":"25"},{"size":9254,"mtime":1690011033926,"results":"37","hashOfConfig":"25"},{"size":5414,"mtime":1690011033926,"results":"38","hashOfConfig":"25"},{"size":843,"mtime":1690011033926,"results":"39","hashOfConfig":"25"},{"size":152,"mtime":1690011033926,"results":"40","hashOfConfig":"25"},{"size":286,"mtime":1690011033926,"results":"41","hashOfConfig":"25"},{"size":342,"mtime":1690011033926,"results":"42","hashOfConfig":"25"},{"size":2829,"mtime":1690011033926,"results":"43","hashOfConfig":"25"},{"size":2322,"mtime":1690011033926,"results":"44","hashOfConfig":"25"},{"size":1110,"mtime":1690011033926,"results":"45","hashOfConfig":"25"},{"size":2058,"mtime":1690011033926,"results":"46","hashOfConfig":"25"},{"size":1314,"mtime":1690011033926,"results":"47","hashOfConfig":"25"},{"filePath":"48","messages":"49","suppressedMessages":"50","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"m9c228",{"filePath":"51","messages":"52","suppressedMessages":"53","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"54","messages":"55","suppressedMessages":"56","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"57","messages":"58","suppressedMessages":"59","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"60","messages":"61","suppressedMessages":"62","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"63","messages":"64","suppressedMessages":"65","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"66","messages":"67","suppressedMessages":"68","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"69","messages":"70","suppressedMessages":"71","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"72","messages":"73","suppressedMessages":"74","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"75","messages":"76","suppressedMessages":"77","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"78","messages":"79","suppressedMessages":"80","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"81","messages":"82","suppressedMessages":"83","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"84","messages":"85","suppressedMessages":"86","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"87","messages":"88","suppressedMessages":"89","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"90","messages":"91","suppressedMessages":"92","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"93","messages":"94","suppressedMessages":"95","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"96","messages":"97","suppressedMessages":"98","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"99","messages":"100","suppressedMessages":"101","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"102","messages":"103","suppressedMessages":"104","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"105","messages":"106","suppressedMessages":"107","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"108","messages":"109","suppressedMessages":"110","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"111","messages":"112","suppressedMessages":"113","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"114","messages":"115","suppressedMessages":"116","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",[],["117"],"/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__/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",[],["118"],"/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",[],["119"],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/compiledHooks/useCompiledPaginationFragment.ts",[],["120","121","122","123","124"],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/compiledHooks/useCompiledRefetchableFragment.ts",[],["125"],"/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/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",[],["126","127"],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/useOverridenOrDefaultApolloClient.ts",[],["128"],{"ruleId":"129","severity":1,"message":"130","line":295,"column":38,"nodeType":"131","messageId":"132","endLine":295,"endColumn":41,"suggestions":"133","suppressions":"134"},{"ruleId":"129","severity":1,"message":"130","line":16,"column":32,"nodeType":"131","messageId":"132","endLine":16,"endColumn":35,"suggestions":"135","suppressions":"136"},{"ruleId":"129","severity":1,"message":"130","line":87,"column":28,"nodeType":"131","messageId":"132","endLine":87,"endColumn":31,"suggestions":"137","suppressions":"138"},{"ruleId":"129","severity":1,"message":"130","line":163,"column":24,"nodeType":"131","messageId":"132","endLine":163,"endColumn":27,"suggestions":"139","suppressions":"140"},{"ruleId":"129","severity":1,"message":"130","line":166,"column":4,"nodeType":"131","messageId":"132","endLine":166,"endColumn":7,"suggestions":"141","suppressions":"142"},{"ruleId":"129","severity":1,"message":"130","line":168,"column":30,"nodeType":"131","messageId":"132","endLine":168,"endColumn":33,"suggestions":"143","suppressions":"144"},{"ruleId":"129","severity":1,"message":"130","line":178,"column":24,"nodeType":"131","messageId":"132","endLine":178,"endColumn":27,"suggestions":"145","suppressions":"146"},{"ruleId":"129","severity":1,"message":"130","line":214,"column":9,"nodeType":"131","messageId":"132","endLine":214,"endColumn":12,"suggestions":"147","suppressions":"148"},{"ruleId":"129","severity":1,"message":"130","line":38,"column":26,"nodeType":"131","messageId":"132","endLine":38,"endColumn":29,"suggestions":"149","suppressions":"150"},{"ruleId":"129","severity":1,"message":"130","line":5,"column":19,"nodeType":"131","messageId":"132","endLine":5,"endColumn":22,"suggestions":"151","suppressions":"152"},{"ruleId":"129","severity":1,"message":"130","line":10,"column":19,"nodeType":"131","messageId":"132","endLine":10,"endColumn":22,"suggestions":"153","suppressions":"154"},{"ruleId":"129","severity":1,"message":"130","line":17,"column":51,"nodeType":"131","messageId":"132","endLine":17,"endColumn":54,"suggestions":"155","suppressions":"156"},"@typescript-eslint/no-explicit-any","Unexpected any. Specify a different type.","TSAnyKeyword","unexpectedAny",["157","158"],["159"],["160","161"],["162"],["163","164"],["165"],["166","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"],{"messageId":"193","fix":"194","desc":"195"},{"messageId":"196","fix":"197","desc":"198"},{"kind":"199","justification":"200"},{"messageId":"193","fix":"201","desc":"195"},{"messageId":"196","fix":"202","desc":"198"},{"kind":"199","justification":"200"},{"messageId":"193","fix":"203","desc":"195"},{"messageId":"196","fix":"204","desc":"198"},{"kind":"199","justification":"200"},{"messageId":"193","fix":"205","desc":"195"},{"messageId":"196","fix":"206","desc":"198"},{"kind":"199","justification":"200"},{"messageId":"193","fix":"207","desc":"195"},{"messageId":"196","fix":"208","desc":"198"},{"kind":"199","justification":"200"},{"messageId":"193","fix":"209","desc":"195"},{"messageId":"196","fix":"210","desc":"198"},{"kind":"199","justification":"200"},{"messageId":"193","fix":"211","desc":"195"},{"messageId":"196","fix":"212","desc":"198"},{"kind":"199","justification":"200"},{"messageId":"193","fix":"213","desc":"195"},{"messageId":"196","fix":"214","desc":"198"},{"kind":"199","justification":"200"},{"messageId":"193","fix":"215","desc":"195"},{"messageId":"196","fix":"216","desc":"198"},{"kind":"199","justification":"200"},{"messageId":"193","fix":"217","desc":"195"},{"messageId":"196","fix":"218","desc":"198"},{"kind":"199","justification":"200"},{"messageId":"193","fix":"219","desc":"195"},{"messageId":"196","fix":"220","desc":"198"},{"kind":"199","justification":"200"},{"messageId":"193","fix":"221","desc":"195"},{"messageId":"196","fix":"222","desc":"198"},{"kind":"199","justification":"200"},"suggestUnknown",{"range":"223","text":"224"},"Use `unknown` instead, this will force you to explicitly, and safely assert the type is correct.","suggestNever",{"range":"223","text":"225"},"Use `never` instead, this is useful when instantiating generic type parameters that you don't need to know the type of.","directive","",{"range":"226","text":"224"},{"range":"226","text":"225"},{"range":"227","text":"224"},{"range":"227","text":"225"},{"range":"228","text":"224"},{"range":"228","text":"225"},{"range":"229","text":"224"},{"range":"229","text":"225"},{"range":"230","text":"224"},{"range":"230","text":"225"},{"range":"231","text":"224"},{"range":"231","text":"225"},{"range":"232","text":"224"},{"range":"232","text":"225"},{"range":"233","text":"224"},{"range":"233","text":"225"},{"range":"234","text":"224"},{"range":"234","text":"225"},{"range":"235","text":"224"},{"range":"235","text":"225"},{"range":"236","text":"224"},{"range":"236","text":"225"},[11025,11028],"unknown","never",[567,570],[2626,2629],[5394,5397],[5495,5498],[5595,5598],[5884,5887],[6948,6951],[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":1692167191888,"results":"26","hashOfConfig":"27"},{"size":1917,"mtime":1692167191888,"results":"28","hashOfConfig":"27"},{"size":690,"mtime":1692167191888,"results":"29","hashOfConfig":"27"},{"size":12265,"mtime":1692167191888,"results":"30","hashOfConfig":"27"},{"size":174,"mtime":1692167191888,"results":"31","hashOfConfig":"27"},{"size":33980,"mtime":1692167191888,"results":"32","hashOfConfig":"27"},{"size":1839,"mtime":1692167191888,"results":"33","hashOfConfig":"27"},{"size":1709,"mtime":1692167191888,"results":"34","hashOfConfig":"27"},{"size":3041,"mtime":1692167191888,"results":"35","hashOfConfig":"27"},{"size":445,"mtime":1692167191888,"results":"36","hashOfConfig":"27"},{"size":575,"mtime":1692167191888,"results":"37","hashOfConfig":"27"},{"size":2426,"mtime":1692167191888,"results":"38","hashOfConfig":"27"},{"size":3662,"mtime":1692167191888,"results":"39","hashOfConfig":"27"},{"size":9406,"mtime":1692167191888,"results":"40","hashOfConfig":"27"},{"size":5414,"mtime":1692167191888,"results":"41","hashOfConfig":"27"},{"size":843,"mtime":1692167191888,"results":"42","hashOfConfig":"27"},{"size":152,"mtime":1692167191888,"results":"43","hashOfConfig":"27"},{"size":286,"mtime":1692167191888,"results":"44","hashOfConfig":"27"},{"size":1243,"mtime":1692167191888,"results":"45","hashOfConfig":"27"},{"size":230,"mtime":1692167191888,"results":"46","hashOfConfig":"27"},{"size":2829,"mtime":1692167191888,"results":"47","hashOfConfig":"27"},{"size":2322,"mtime":1692167191888,"results":"48","hashOfConfig":"27"},{"size":1110,"mtime":1692167191888,"results":"49","hashOfConfig":"27"},{"size":2058,"mtime":1692167191888,"results":"50","hashOfConfig":"27"},{"size":1314,"mtime":1692167191888,"results":"51","hashOfConfig":"27"},{"filePath":"52","messages":"53","suppressedMessages":"54","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"115doex",{"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]]
|
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,29 @@
|
|
|
1
1
|
# Change Log - @graphitation/apollo-react-relay-duct-tape
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Wed, 16 Aug 2023 06:30:58 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 1.0.10
|
|
8
|
+
|
|
9
|
+
Wed, 16 Aug 2023 06:30:58 GMT
|
|
10
|
+
|
|
11
|
+
### Patches
|
|
12
|
+
|
|
13
|
+
- Various PeopleApp fixes (eloy.de.enige@gmail.com)
|
|
14
|
+
- Bump @graphitation/apollo-react-relay-duct-tape-compiler to v1.2.3
|
|
15
|
+
|
|
16
|
+
## 1.0.9
|
|
17
|
+
|
|
18
|
+
Tue, 25 Jul 2023 08:18:03 GMT
|
|
19
|
+
|
|
20
|
+
### Patches
|
|
21
|
+
|
|
22
|
+
- Bump @graphitation/apollo-react-relay-duct-tape-compiler to v1.2.2
|
|
23
|
+
|
|
7
24
|
## 1.0.8
|
|
8
25
|
|
|
9
|
-
Sat, 22 Jul 2023 07:35:
|
|
26
|
+
Sat, 22 Jul 2023 07:35:09 GMT
|
|
10
27
|
|
|
11
28
|
### Patches
|
|
12
29
|
|
package/README.md
CHANGED
|
@@ -25,6 +25,11 @@ Use this together with [@graphitation/apollo-react-relay-duct-tape-compiler](../
|
|
|
25
25
|
|
|
26
26
|
### Configuration
|
|
27
27
|
|
|
28
|
+
TODO:
|
|
29
|
+
|
|
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 implemenation.
|
|
32
|
+
|
|
28
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:
|
|
29
34
|
|
|
30
35
|
```ts
|
package/lib/hooks.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ApolloCache } from "@apollo/client";
|
|
1
2
|
import { FetchPolicy, GraphQLTaggedNode, KeyType, KeyTypeData, OperationType } from "./types";
|
|
2
3
|
import { RefetchFn, PaginationFn } from "./storeObservation/compiledHooks";
|
|
3
4
|
/**
|
|
@@ -97,11 +98,17 @@ interface GraphQLSubscriptionConfig<TSubscriptionPayload extends OperationType>
|
|
|
97
98
|
export declare function useSubscription<TSubscriptionPayload extends OperationType>(config: GraphQLSubscriptionConfig<TSubscriptionPayload>): void;
|
|
98
99
|
interface IMutationCommitterOptions<TMutationPayload extends OperationType> {
|
|
99
100
|
variables: TMutationPayload["variables"];
|
|
101
|
+
optimisticResponse?: Partial<TMutationPayload["response"]> | null;
|
|
100
102
|
/**
|
|
101
|
-
*
|
|
103
|
+
* This version yields the ApolloCache instance, instead of the RelayStore,
|
|
104
|
+
* and usage of it will not be portable to Relay directly. However, it is a
|
|
105
|
+
* necessary evil for migration purposes.
|
|
106
|
+
*/
|
|
107
|
+
updater?: (cache: ApolloCache<unknown>, data: TMutationPayload["response"]) => void;
|
|
108
|
+
/**
|
|
109
|
+
* @deprecated Should be avoided when possible as it will not be compatible with Relay APIs.
|
|
102
110
|
*/
|
|
103
111
|
context?: TMutationPayload["context"];
|
|
104
|
-
optimisticResponse?: Partial<TMutationPayload["response"]> | null;
|
|
105
112
|
}
|
|
106
113
|
type MutationCommiter<TMutationPayload extends OperationType> = (options: IMutationCommitterOptions<TMutationPayload>) => Promise<{
|
|
107
114
|
errors?: Error[];
|
package/lib/hooks.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AACA,OAAO,EAOL,WAAW,EACZ,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,OAAO,EACP,WAAW,EACX,aAAa,EACd,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,SAAS,EACT,YAAY,EAKb,MAAM,kCAAkC,CAAC;AAM1C;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,SAAS,aAAa,EAC3D,KAAK,EAAE,iBAAiB,EACxB,SAAS,EAAE,MAAM,CAAC,WAAW,CAAC,EAC9B,OAAO,CAAC,EAAE;IAAE,WAAW,CAAC,EAAE,WAAW,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC,SAAS,CAAC,CAAA;CAAE,GACnE;IAAE,KAAK,CAAC,EAAE,KAAK,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC,CAAA;CAAE,CA2B9C;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,WAAW,CAAC,IAAI,SAAS,OAAO,EAC9C,aAAa,EAAE,iBAAiB,EAChC,WAAW,EAAE,IAAI,GAChB,WAAW,CAAC,IAAI,CAAC,CAAC;AACrB,wB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CAAC,UAAU,CAAC,KAAK,IAAI,CAAC;IAC9D,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,oBAAoB,SAAS,aAAa,EACxE,MAAM,EAAE,yBAAyB,CAAC,oBAAoB,CAAC,GACtD,IAAI,CA0CN;AAED,UAAU,yBAAyB,CAAC,gBAAgB,SAAS,aAAa;IACxE,SAAS,EAAE,gBAAgB,CAAC,WAAW,CAAC,CAAC;IACzC,kBAAkB,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC,GAAG,IAAI,CAAC;IAClE;;;;OAIG;IACH,OAAO,CAAC,EAAE,CACR,KAAK,EAAE,WAAW,CAAC,OAAO,CAAC,EAC3B,IAAI,EAAE,gBAAgB,CAAC,UAAU,CAAC,KAC/B,IAAI,CAAC;IACV;;OAEG;IACH,OAAO,CAAC,EAAE,gBAAgB,CAAC,SAAS,CAAC,CAAC;CACvC;AAED,KAAK,gBAAgB,CAAC,gBAAgB,SAAS,aAAa,IAAI,CAC9D,OAAO,EAAE,yBAAyB,CAAC,gBAAgB,CAAC,KACjD,OAAO,CAAC;IAAE,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC;IAAC,IAAI,CAAC,EAAE,gBAAgB,CAAC,UAAU,CAAC,CAAA;CAAE,CAAC,CAAC;AAExE;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,gBAAgB,SAAS,aAAa,EAChE,QAAQ,EAAE,iBAAiB,GAC1B,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,EAAE,OAAO,CAAC,CAoC/C"}
|
package/lib/hooks.js
CHANGED
|
@@ -81,7 +81,7 @@ var import_useOverridenOrDefaultApolloClient = require("./useOverridenOrDefaultA
|
|
|
81
81
|
function useLazyLoadQuery(query, variables, options) {
|
|
82
82
|
(0, import_invariant.default)(
|
|
83
83
|
(query == null ? void 0 : query.__brand) === void 0,
|
|
84
|
-
"useLazyLoadQuery:
|
|
84
|
+
"useLazyLoadQuery: Document must be a valid runtime type."
|
|
85
85
|
);
|
|
86
86
|
const apolloOptions = options && __spreadProps(__spreadValues({}, options), {
|
|
87
87
|
fetchPolicy: (0, import_convertFetchPolicy.convertFetchPolicy)(options.fetchPolicy)
|
|
@@ -151,10 +151,18 @@ function usePaginationFragment(fragmentInput, fragmentRef) {
|
|
|
151
151
|
);
|
|
152
152
|
}
|
|
153
153
|
function useSubscription(config) {
|
|
154
|
+
const document = config.subscription;
|
|
155
|
+
(0, import_invariant.default)(
|
|
156
|
+
(document == null ? void 0 : document.__brand) === void 0,
|
|
157
|
+
"useSubscription: Document must be a valid runtime type."
|
|
158
|
+
);
|
|
159
|
+
(0, import_invariant.default)(
|
|
160
|
+
!document.watchQueryDocument,
|
|
161
|
+
"useSubscription: Did not expect a watch query document"
|
|
162
|
+
);
|
|
154
163
|
const client = (0, import_useOverridenOrDefaultApolloClient.useOverridenOrDefaultApolloClient)();
|
|
155
164
|
const { error } = (0, import_client.useSubscription)(
|
|
156
|
-
|
|
157
|
-
config.subscription,
|
|
165
|
+
document.executionQueryDocument || document,
|
|
158
166
|
{
|
|
159
167
|
client,
|
|
160
168
|
variables: config.variables,
|
|
@@ -182,10 +190,17 @@ function useSubscription(config) {
|
|
|
182
190
|
}
|
|
183
191
|
}
|
|
184
192
|
function useMutation(mutation) {
|
|
193
|
+
(0, import_invariant.default)(
|
|
194
|
+
(mutation == null ? void 0 : mutation.__brand) === void 0,
|
|
195
|
+
"useMutation: Document must be a valid runtime type."
|
|
196
|
+
);
|
|
197
|
+
(0, import_invariant.default)(
|
|
198
|
+
!mutation.watchQueryDocument,
|
|
199
|
+
"useMutation: Did not expect a watch query document"
|
|
200
|
+
);
|
|
185
201
|
const client = (0, import_useOverridenOrDefaultApolloClient.useOverridenOrDefaultApolloClient)();
|
|
186
202
|
const [apolloUpdater, { loading: mutationLoading }] = (0, import_client.useMutation)(
|
|
187
|
-
|
|
188
|
-
mutation,
|
|
203
|
+
mutation.executionQueryDocument || mutation,
|
|
189
204
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
190
205
|
{ client }
|
|
191
206
|
);
|
|
@@ -194,7 +209,8 @@ function useMutation(mutation) {
|
|
|
194
209
|
const apolloResult = yield apolloUpdater({
|
|
195
210
|
variables: options.variables || {},
|
|
196
211
|
context: options.context,
|
|
197
|
-
optimisticResponse: options.optimisticResponse
|
|
212
|
+
optimisticResponse: options.optimisticResponse,
|
|
213
|
+
update: options.updater
|
|
198
214
|
});
|
|
199
215
|
if (apolloResult.errors) {
|
|
200
216
|
return {
|
package/lib/hooks.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/hooks.ts"],
|
|
4
|
-
"sourcesContent": ["import { DocumentNode } from \"graphql\";\nimport invariant from \"invariant\";\nimport {\n useSubscription as useApolloSubscription,\n useQuery as useApolloQuery,\n useMutation as useApolloMutation,\n SubscriptionHookOptions as ApolloSubscriptionHookOptions,\n ErrorPolicy as ApolloErrorPolicy,\n ApolloClient,\n} from \"@apollo/client\";\n\nimport {\n FetchPolicy,\n GraphQLTaggedNode,\n KeyType,\n KeyTypeData,\n OperationType,\n} from \"./types\";\nimport {\n RefetchFn,\n PaginationFn,\n useCompiledLazyLoadQuery,\n useCompiledFragment,\n useCompiledRefetchableFragment,\n useCompiledPaginationFragment,\n} from \"./storeObservation/compiledHooks\";\nimport { convertFetchPolicy } from \"./convertFetchPolicy\";\nimport { useOverridenOrDefaultApolloClient } from \"./useOverridenOrDefaultApolloClient\";\nimport type { CompiledArtefactModule } from \"@graphitation/apollo-react-relay-duct-tape-compiler\";\nimport { FragmentReference } from \"./storeObservation/compiledHooks/types\";\n\n/**\n * Executes a GraphQL query.\n *\n * This hook is called 'lazy' as it is used to fetch a GraphQL query _during_ render. This hook can trigger multiple\n * round trips, one for loading and one for resolving.\n *\n * @see {@link https://microsoft.github.io/graphitation/docs/apollo-react-relay-duct-tape/use-lazy-load-query}\n *\n * @param query The query operation to perform.\n * @param variables Object containing the variable values to fetch the query. These variables need to match GraphQL\n * variables declared inside the query.\n * @param options Options passed on to the underlying implementation.\n * @param options.context The query context to pass along the apollo link chain. Should be avoided when possible as\n * it will not be compatible with Relay APIs.\n * @returns An object with either an error, the result data, or neither while loading.\n */\nexport function useLazyLoadQuery<TQuery extends OperationType>(\n query: GraphQLTaggedNode,\n variables: TQuery[\"variables\"],\n options?: { fetchPolicy?: FetchPolicy; context?: TQuery[\"context\"] },\n): { error?: Error; data?: TQuery[\"response\"] } {\n invariant(\n query?.__brand === undefined,\n \"useLazyLoadQuery: query must be a valid runtime type.\",\n );\n const apolloOptions = options && {\n ...options,\n fetchPolicy: convertFetchPolicy(options.fetchPolicy),\n };\n if (query.watchQueryDocument) {\n return useCompiledLazyLoadQuery(query as CompiledArtefactModule, {\n variables,\n ...apolloOptions,\n });\n } else {\n const client = useOverridenOrDefaultApolloClient();\n return useApolloQuery(\n // Compiled documents without narrow observables should be treated like\n // normal queries.\n query.executionQueryDocument || query,\n {\n client,\n variables,\n ...apolloOptions,\n },\n );\n }\n}\n\n/**\n * A first-class way for an individual component to express its direct data requirements using GraphQL. The fragment\n * should select all the fields that the component directly uses in its rendering or needs to pass to external\n * functions. It should *not* select data that its children need, unless those children are intended to remain their\n * pure React props as data inputs.\n *\n * For children that *do* have their own data requirements expressed using GraphQL, the fragment should ensure to\n * spread in the child's fragment.\n *\n * @see {@link https://microsoft.github.io/graphitation/docs/apollo-react-relay-duct-tape/use-fragment}\n *\n * @note For migration purposes, this hook supports the notion that the fragment reference can be undefined. This is\n * to support cases where useFragment is used in a tree that is conditionally using fragments.\n *\n * @param fragmentInput The GraphQL fragment document created using the `graphql` tagged template function.\n * @param fragmentRef The opaque fragment reference passed in by a parent component that has spread in this component's\n * fragment.\n * @returns The data corresponding to the field selections.\n */\nexport function useFragment<TKey extends KeyType>(\n fragmentInput: GraphQLTaggedNode,\n fragmentRef: TKey,\n): KeyTypeData<TKey>;\nexport function useFragment(\n fragmentInput: GraphQLTaggedNode,\n fragmentRef: undefined,\n): undefined;\nexport function useFragment<TKey extends KeyType>(\n fragmentInput: GraphQLTaggedNode,\n fragmentRef: TKey | undefined,\n): KeyTypeData<TKey> | undefined;\nexport function useFragment<TKey extends KeyType>(\n fragmentInput: GraphQLTaggedNode | undefined,\n fragmentRef: TKey,\n): KeyTypeData<TKey> {\n invariant(\n fragmentInput?.__brand === undefined,\n \"useFragment: fragmentInput must be a valid runtime type.\",\n );\n // If fragmentInput is undefined, it means the fragment is not compiled and we should just return the fragmentRef.\n // This is an implementation detail that should never surface to the user.\n if (fragmentInput && fragmentInput.watchQueryDocument) {\n return useCompiledFragment(fragmentInput, fragmentRef as FragmentReference);\n } else {\n return fragmentRef as unknown;\n }\n}\n\n/**\n * Equivalent to `useFragment`, but allows refetching of its subtree of the overall query.\n *\n * @see {@link https://microsoft.github.io/graphitation/docs/apollo-react-relay-duct-tape/use-refetchable-fragment}\n *\n * @param fragmentInput The GraphQL fragment document created using the `graphql` tagged template function.\n * @param fragmentRef The opaque fragment reference passed in by a parent component that has spread in this component's\n * fragment.\n * @returns The data corresponding to the field selections and a function to perform the refetch.\n */\nexport function useRefetchableFragment<\n TQuery extends OperationType,\n TKey extends KeyType,\n>(\n fragmentInput: GraphQLTaggedNode,\n fragmentRef: TKey,\n): [data: KeyTypeData<TKey>, refetch: RefetchFn<TQuery[\"variables\"]>] {\n invariant(\n fragmentInput,\n \"useRefetchableFragment: Missing metadata; did you forget to use the @refetchable directive?\",\n );\n invariant(\n fragmentInput.__brand === undefined,\n \"useRefetchableFragment: fragmentInput must be a valid runtime type.\",\n );\n invariant(\n !!fragmentInput.watchQueryDocument,\n \"useRefetchableFragment is only supported at this time when using compilation\",\n );\n return useCompiledRefetchableFragment(\n fragmentInput as CompiledArtefactModule,\n fragmentRef as FragmentReference,\n );\n}\n\n/**\n * Equivalent to `useFragment`, but allows pagination of its subtree of the overall query.\n *\n * @see {@link https://microsoft.github.io/graphitation/docs/apollo-react-relay-duct-tape/use-pagination-fragment}\n *\n * @param fragmentInput The GraphQL fragment document created using the `graphql` tagged template function.\n * @param fragmentRef The opaque fragment reference passed in by a parent component that has spread in this component's\n * fragment.\n * @returns The data corresponding to the field selections and functions to deal with pagination.\n */\nexport function usePaginationFragment<\n TQuery extends OperationType,\n TKey extends KeyType,\n>(\n fragmentInput: GraphQLTaggedNode,\n fragmentRef: TKey,\n): {\n data: KeyTypeData<TKey>;\n loadNext: PaginationFn;\n loadPrevious: PaginationFn;\n hasNext: boolean;\n hasPrevious: boolean;\n isLoadingNext: boolean;\n isLoadingPrevious: boolean;\n refetch: RefetchFn<TQuery[\"variables\"]>;\n} {\n invariant(\n fragmentInput,\n \"usePaginationFragment: Missing metadata; did you forget to use the @refetchable directive?\",\n );\n invariant(\n fragmentInput.__brand === undefined,\n \"usePaginationFragment: fragmentInput must be a valid runtime type.\",\n );\n invariant(\n !!fragmentInput.watchQueryDocument,\n \"usePaginationFragment is only supported at this time when using compilation\",\n );\n return useCompiledPaginationFragment(\n fragmentInput as CompiledArtefactModule,\n fragmentRef as FragmentReference,\n );\n}\n\n// https://github.com/facebook/relay/blob/master/website/docs/api-reference/types/GraphQLSubscriptionConfig.md\ninterface GraphQLSubscriptionConfig<\n TSubscriptionPayload extends OperationType,\n> {\n subscription: GraphQLTaggedNode;\n variables: TSubscriptionPayload[\"variables\"];\n /**\n * Should be avoided when possible as it will not be compatible with Relay APIs.\n */\n context?: TSubscriptionPayload[\"context\"];\n /**\n * Should response be nullable?\n */\n onNext?: (response: TSubscriptionPayload[\"response\"]) => void;\n onError?: (error: Error) => void;\n}\n\n/**\n * @see {@link https://microsoft.github.io/graphitation/docs/apollo-react-relay-duct-tape/use-subscription}\n *\n * @param config\n */\nexport function useSubscription<TSubscriptionPayload extends OperationType>(\n config: GraphQLSubscriptionConfig<TSubscriptionPayload>,\n): void {\n const client = useOverridenOrDefaultApolloClient();\n const { error } = useApolloSubscription(\n // TODO: Right now we don't replace mutation documents with imported artefacts.\n config.subscription as DocumentNode,\n {\n client,\n variables: config.variables,\n context: config.context,\n onSubscriptionData: ({ subscriptionData }) => {\n // Supposedly this never gets triggered for an error by design:\n // https://github.com/apollographql/react-apollo/issues/3177#issuecomment-506758144\n invariant(\n !subscriptionData.error,\n \"Did not expect to receive an error here\",\n );\n if (subscriptionData.data && config.onNext) {\n config.onNext(subscriptionData.data);\n }\n },\n errorPolicy: \"ignore\",\n } as ApolloSubscriptionHookOptions & {\n errorPolicy: ApolloErrorPolicy;\n },\n );\n if (error) {\n if (config.onError) {\n config.onError(error);\n } else {\n console.warn(\n `An unhandled GraphQL subscription error occurred: ${error.message}`,\n );\n }\n }\n}\n\ninterface IMutationCommitterOptions<TMutationPayload extends OperationType> {\n variables: TMutationPayload[\"variables\"];\n /**\n * Should be avoided when possible as it will not be compatible with Relay APIs.\n */\n context?: TMutationPayload[\"context\"];\n optimisticResponse?: Partial<TMutationPayload[\"response\"]> | null;\n}\n\ntype MutationCommiter<TMutationPayload extends OperationType> = (\n options: IMutationCommitterOptions<TMutationPayload>,\n) => Promise<{ errors?: Error[]; data?: TMutationPayload[\"response\"] }>;\n\n/**\n * @see {@link https://microsoft.github.io/graphitation/docs/apollo-react-relay-duct-tape/use-mutation}\n *\n * @param mutation\n * @returns\n */\nexport function useMutation<TMutationPayload extends OperationType>(\n mutation: GraphQLTaggedNode,\n): [MutationCommiter<TMutationPayload>, boolean] {\n const client = useOverridenOrDefaultApolloClient();\n const [apolloUpdater, { loading: mutationLoading }] = useApolloMutation(\n // TODO: Right now we don't replace mutation documents with imported artefacts.\n mutation as DocumentNode,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n { client: client as ApolloClient<any> },\n );\n\n return [\n async (options: IMutationCommitterOptions<TMutationPayload>) => {\n const apolloResult = await apolloUpdater({\n variables: options.variables || {},\n context: options.context,\n optimisticResponse: options.optimisticResponse,\n });\n if (apolloResult.errors) {\n return {\n errors: Array.from(Object.values(apolloResult.errors)),\n data: apolloResult.data,\n };\n }\n return {\n data: apolloResult.data,\n };\n },\n mutationLoading,\n ];\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["import invariant from \"invariant\";\nimport {\n useSubscription as useApolloSubscription,\n useQuery as useApolloQuery,\n useMutation as useApolloMutation,\n SubscriptionHookOptions as ApolloSubscriptionHookOptions,\n ErrorPolicy as ApolloErrorPolicy,\n ApolloClient,\n ApolloCache,\n} from \"@apollo/client\";\n\nimport {\n FetchPolicy,\n GraphQLTaggedNode,\n KeyType,\n KeyTypeData,\n OperationType,\n} from \"./types\";\nimport {\n RefetchFn,\n PaginationFn,\n useCompiledLazyLoadQuery,\n useCompiledFragment,\n useCompiledRefetchableFragment,\n useCompiledPaginationFragment,\n} from \"./storeObservation/compiledHooks\";\nimport { convertFetchPolicy } from \"./convertFetchPolicy\";\nimport { useOverridenOrDefaultApolloClient } from \"./useOverridenOrDefaultApolloClient\";\nimport type { CompiledArtefactModule } from \"@graphitation/apollo-react-relay-duct-tape-compiler\";\nimport { FragmentReference } from \"./storeObservation/compiledHooks/types\";\n\n/**\n * Executes a GraphQL query.\n *\n * This hook is called 'lazy' as it is used to fetch a GraphQL query _during_ render. This hook can trigger multiple\n * round trips, one for loading and one for resolving.\n *\n * @see {@link https://microsoft.github.io/graphitation/docs/apollo-react-relay-duct-tape/use-lazy-load-query}\n *\n * @param query The query operation to perform.\n * @param variables Object containing the variable values to fetch the query. These variables need to match GraphQL\n * variables declared inside the query.\n * @param options Options passed on to the underlying implementation.\n * @param options.context The query context to pass along the apollo link chain. Should be avoided when possible as\n * it will not be compatible with Relay APIs.\n * @returns An object with either an error, the result data, or neither while loading.\n */\nexport function useLazyLoadQuery<TQuery extends OperationType>(\n query: GraphQLTaggedNode,\n variables: TQuery[\"variables\"],\n options?: { fetchPolicy?: FetchPolicy; context?: TQuery[\"context\"] },\n): { error?: Error; data?: TQuery[\"response\"] } {\n invariant(\n query?.__brand === undefined,\n \"useLazyLoadQuery: Document must be a valid runtime type.\",\n );\n const apolloOptions = options && {\n ...options,\n fetchPolicy: convertFetchPolicy(options.fetchPolicy),\n };\n if (query.watchQueryDocument) {\n return useCompiledLazyLoadQuery(query as CompiledArtefactModule, {\n variables,\n ...apolloOptions,\n });\n } else {\n const client = useOverridenOrDefaultApolloClient();\n return useApolloQuery(\n // Compiled documents without narrow observables should be treated like\n // normal queries.\n query.executionQueryDocument || query,\n {\n client,\n variables,\n ...apolloOptions,\n },\n );\n }\n}\n\n/**\n * A first-class way for an individual component to express its direct data requirements using GraphQL. The fragment\n * should select all the fields that the component directly uses in its rendering or needs to pass to external\n * functions. It should *not* select data that its children need, unless those children are intended to remain their\n * pure React props as data inputs.\n *\n * For children that *do* have their own data requirements expressed using GraphQL, the fragment should ensure to\n * spread in the child's fragment.\n *\n * @see {@link https://microsoft.github.io/graphitation/docs/apollo-react-relay-duct-tape/use-fragment}\n *\n * @note For migration purposes, this hook supports the notion that the fragment reference can be undefined. This is\n * to support cases where useFragment is used in a tree that is conditionally using fragments.\n *\n * @param fragmentInput The GraphQL fragment document created using the `graphql` tagged template function.\n * @param fragmentRef The opaque fragment reference passed in by a parent component that has spread in this component's\n * fragment.\n * @returns The data corresponding to the field selections.\n */\nexport function useFragment<TKey extends KeyType>(\n fragmentInput: GraphQLTaggedNode,\n fragmentRef: TKey,\n): KeyTypeData<TKey>;\nexport function useFragment(\n fragmentInput: GraphQLTaggedNode,\n fragmentRef: undefined,\n): undefined;\nexport function useFragment<TKey extends KeyType>(\n fragmentInput: GraphQLTaggedNode,\n fragmentRef: TKey | undefined,\n): KeyTypeData<TKey> | undefined;\nexport function useFragment<TKey extends KeyType>(\n fragmentInput: GraphQLTaggedNode | undefined,\n fragmentRef: TKey,\n): KeyTypeData<TKey> {\n invariant(\n fragmentInput?.__brand === undefined,\n \"useFragment: fragmentInput must be a valid runtime type.\",\n );\n // If fragmentInput is undefined, it means the fragment is not compiled and we should just return the fragmentRef.\n // This is an implementation detail that should never surface to the user.\n if (fragmentInput && fragmentInput.watchQueryDocument) {\n return useCompiledFragment(fragmentInput, fragmentRef as FragmentReference);\n } else {\n return fragmentRef as unknown;\n }\n}\n\n/**\n * Equivalent to `useFragment`, but allows refetching of its subtree of the overall query.\n *\n * @see {@link https://microsoft.github.io/graphitation/docs/apollo-react-relay-duct-tape/use-refetchable-fragment}\n *\n * @param fragmentInput The GraphQL fragment document created using the `graphql` tagged template function.\n * @param fragmentRef The opaque fragment reference passed in by a parent component that has spread in this component's\n * fragment.\n * @returns The data corresponding to the field selections and a function to perform the refetch.\n */\nexport function useRefetchableFragment<\n TQuery extends OperationType,\n TKey extends KeyType,\n>(\n fragmentInput: GraphQLTaggedNode,\n fragmentRef: TKey,\n): [data: KeyTypeData<TKey>, refetch: RefetchFn<TQuery[\"variables\"]>] {\n invariant(\n fragmentInput,\n \"useRefetchableFragment: Missing metadata; did you forget to use the @refetchable directive?\",\n );\n invariant(\n fragmentInput.__brand === undefined,\n \"useRefetchableFragment: fragmentInput must be a valid runtime type.\",\n );\n invariant(\n !!fragmentInput.watchQueryDocument,\n \"useRefetchableFragment is only supported at this time when using compilation\",\n );\n return useCompiledRefetchableFragment(\n fragmentInput as CompiledArtefactModule,\n fragmentRef as FragmentReference,\n );\n}\n\n/**\n * Equivalent to `useFragment`, but allows pagination of its subtree of the overall query.\n *\n * @see {@link https://microsoft.github.io/graphitation/docs/apollo-react-relay-duct-tape/use-pagination-fragment}\n *\n * @param fragmentInput The GraphQL fragment document created using the `graphql` tagged template function.\n * @param fragmentRef The opaque fragment reference passed in by a parent component that has spread in this component's\n * fragment.\n * @returns The data corresponding to the field selections and functions to deal with pagination.\n */\nexport function usePaginationFragment<\n TQuery extends OperationType,\n TKey extends KeyType,\n>(\n fragmentInput: GraphQLTaggedNode,\n fragmentRef: TKey,\n): {\n data: KeyTypeData<TKey>;\n loadNext: PaginationFn;\n loadPrevious: PaginationFn;\n hasNext: boolean;\n hasPrevious: boolean;\n isLoadingNext: boolean;\n isLoadingPrevious: boolean;\n refetch: RefetchFn<TQuery[\"variables\"]>;\n} {\n invariant(\n fragmentInput,\n \"usePaginationFragment: Missing metadata; did you forget to use the @refetchable directive?\",\n );\n invariant(\n fragmentInput.__brand === undefined,\n \"usePaginationFragment: fragmentInput must be a valid runtime type.\",\n );\n invariant(\n !!fragmentInput.watchQueryDocument,\n \"usePaginationFragment is only supported at this time when using compilation\",\n );\n return useCompiledPaginationFragment(\n fragmentInput as CompiledArtefactModule,\n fragmentRef as FragmentReference,\n );\n}\n\n// https://github.com/facebook/relay/blob/master/website/docs/api-reference/types/GraphQLSubscriptionConfig.md\ninterface GraphQLSubscriptionConfig<\n TSubscriptionPayload extends OperationType,\n> {\n subscription: GraphQLTaggedNode;\n variables: TSubscriptionPayload[\"variables\"];\n /**\n * Should be avoided when possible as it will not be compatible with Relay APIs.\n */\n context?: TSubscriptionPayload[\"context\"];\n /**\n * Should response be nullable?\n */\n onNext?: (response: TSubscriptionPayload[\"response\"]) => void;\n onError?: (error: Error) => void;\n}\n\n/**\n * @see {@link https://microsoft.github.io/graphitation/docs/apollo-react-relay-duct-tape/use-subscription}\n *\n * @param config\n */\nexport function useSubscription<TSubscriptionPayload extends OperationType>(\n config: GraphQLSubscriptionConfig<TSubscriptionPayload>,\n): void {\n const document = config.subscription;\n invariant(\n document?.__brand === undefined,\n \"useSubscription: Document must be a valid runtime type.\",\n );\n invariant(\n !document.watchQueryDocument,\n \"useSubscription: Did not expect a watch query document\",\n );\n const client = useOverridenOrDefaultApolloClient();\n const { error } = useApolloSubscription(\n document.executionQueryDocument || document,\n {\n client,\n variables: config.variables,\n context: config.context,\n onSubscriptionData: ({ subscriptionData }) => {\n // Supposedly this never gets triggered for an error by design:\n // https://github.com/apollographql/react-apollo/issues/3177#issuecomment-506758144\n invariant(\n !subscriptionData.error,\n \"Did not expect to receive an error here\",\n );\n if (subscriptionData.data && config.onNext) {\n config.onNext(subscriptionData.data);\n }\n },\n errorPolicy: \"ignore\",\n } as ApolloSubscriptionHookOptions & {\n errorPolicy: ApolloErrorPolicy;\n },\n );\n if (error) {\n if (config.onError) {\n config.onError(error);\n } else {\n console.warn(\n `An unhandled GraphQL subscription error occurred: ${error.message}`,\n );\n }\n }\n}\n\ninterface IMutationCommitterOptions<TMutationPayload extends OperationType> {\n variables: TMutationPayload[\"variables\"];\n optimisticResponse?: Partial<TMutationPayload[\"response\"]> | null;\n /**\n * This version yields the ApolloCache instance, instead of the RelayStore,\n * and usage of it will not be portable to Relay directly. However, it is a\n * necessary evil for migration purposes.\n */\n updater?: (\n cache: ApolloCache<unknown>,\n data: TMutationPayload[\"response\"],\n ) => void;\n /**\n * @deprecated Should be avoided when possible as it will not be compatible with Relay APIs.\n */\n context?: TMutationPayload[\"context\"];\n}\n\ntype MutationCommiter<TMutationPayload extends OperationType> = (\n options: IMutationCommitterOptions<TMutationPayload>,\n) => Promise<{ errors?: Error[]; data?: TMutationPayload[\"response\"] }>;\n\n/**\n * @see {@link https://microsoft.github.io/graphitation/docs/apollo-react-relay-duct-tape/use-mutation}\n *\n * @param mutation\n * @returns\n */\nexport function useMutation<TMutationPayload extends OperationType>(\n mutation: GraphQLTaggedNode,\n): [MutationCommiter<TMutationPayload>, boolean] {\n invariant(\n mutation?.__brand === undefined,\n \"useMutation: Document must be a valid runtime type.\",\n );\n invariant(\n !mutation.watchQueryDocument,\n \"useMutation: Did not expect a watch query document\",\n );\n const client = useOverridenOrDefaultApolloClient();\n const [apolloUpdater, { loading: mutationLoading }] = useApolloMutation(\n mutation.executionQueryDocument || mutation,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n { client: client as ApolloClient<any> },\n );\n\n return [\n async (options: IMutationCommitterOptions<TMutationPayload>) => {\n const apolloResult = await apolloUpdater({\n variables: options.variables || {},\n context: options.context,\n optimisticResponse: options.optimisticResponse,\n update: options.updater,\n });\n if (apolloResult.errors) {\n return {\n errors: Array.from(Object.values(apolloResult.errors)),\n data: apolloResult.data,\n };\n }\n return {\n data: apolloResult.data,\n };\n },\n mutationLoading,\n ];\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAsB;AACtB,oBAQO;AASP,2BAOO;AACP,gCAAmC;AACnC,+CAAkD;AAoB3C,SAAS,iBACd,OACA,WACA,SAC8C;AAC9C,uBAAAA;AAAA,KACE,+BAAO,aAAY;AAAA,IACnB;AAAA,EACF;AACA,QAAM,gBAAgB,WAAW,iCAC5B,UAD4B;AAAA,IAE/B,iBAAa,8CAAmB,QAAQ,WAAW;AAAA,EACrD;AACA,MAAI,MAAM,oBAAoB;AAC5B,eAAO,+CAAyB,OAAiC;AAAA,MAC/D;AAAA,OACG,cACJ;AAAA,EACH,OAAO;AACL,UAAM,aAAS,4EAAkC;AACjD,eAAO,cAAAC;AAAA;AAAA;AAAA,MAGL,MAAM,0BAA0B;AAAA,MAChC;AAAA,QACE;AAAA,QACA;AAAA,SACG;AAAA,IAEP;AAAA,EACF;AACF;AAiCO,SAAS,YACd,eACA,aACmB;AACnB,uBAAAD;AAAA,KACE,+CAAe,aAAY;AAAA,IAC3B;AAAA,EACF;AAGA,MAAI,iBAAiB,cAAc,oBAAoB;AACrD,eAAO,0CAAoB,eAAe,WAAgC;AAAA,EAC5E,OAAO;AACL,WAAO;AAAA,EACT;AACF;AAYO,SAAS,uBAId,eACA,aACoE;AACpE,uBAAAA;AAAA,IACE;AAAA,IACA;AAAA,EACF;AACA,uBAAAA;AAAA,IACE,cAAc,YAAY;AAAA,IAC1B;AAAA,EACF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AA,EACF;AACA,QAAM,aAAS,4EAAkC;AACjD,QAAM,CAAC,eAAe,EAAE,SAAS,gBAAgB,CAAC,QAAI,cAAAG;AAAA,IACpD,SAAS,0BAA0B;AAAA;AAAA,IAEnC,EAAE,OAAoC;AAAA,EACxC;AAEA,SAAO;AAAA,IACL,CAAO,YAAyD;AAC9D,YAAM,eAAe,MAAM,cAAc;AAAA,QACvC,WAAW,QAAQ,aAAa,CAAC;AAAA,QACjC,SAAS,QAAQ;AAAA,QACjB,oBAAoB,QAAQ;AAAA,QAC5B,QAAQ,QAAQ;AAAA,MAClB,CAAC;AACD,UAAI,aAAa,QAAQ;AACvB,eAAO;AAAA,UACL,QAAQ,MAAM,KAAK,OAAO,OAAO,aAAa,MAAM,CAAC;AAAA,UACrD,MAAM,aAAa;AAAA,QACrB;AAAA,MACF;AACA,aAAO;AAAA,QACL,MAAM,aAAa;AAAA,MACrB;AAAA,IACF;AAAA,IACA;AAAA,EACF;AACF;",
|
|
6
6
|
"names": ["invariant", "useApolloQuery", "useApolloSubscription", "useApolloMutation"]
|
|
7
7
|
}
|
package/lib/hooks.mjs
CHANGED
|
@@ -56,7 +56,7 @@ import { useOverridenOrDefaultApolloClient } from "./useOverridenOrDefaultApollo
|
|
|
56
56
|
function useLazyLoadQuery(query, variables, options) {
|
|
57
57
|
invariant(
|
|
58
58
|
(query == null ? void 0 : query.__brand) === void 0,
|
|
59
|
-
"useLazyLoadQuery:
|
|
59
|
+
"useLazyLoadQuery: Document must be a valid runtime type."
|
|
60
60
|
);
|
|
61
61
|
const apolloOptions = options && __spreadProps(__spreadValues({}, options), {
|
|
62
62
|
fetchPolicy: convertFetchPolicy(options.fetchPolicy)
|
|
@@ -126,10 +126,18 @@ function usePaginationFragment(fragmentInput, fragmentRef) {
|
|
|
126
126
|
);
|
|
127
127
|
}
|
|
128
128
|
function useSubscription(config) {
|
|
129
|
+
const document = config.subscription;
|
|
130
|
+
invariant(
|
|
131
|
+
(document == null ? void 0 : document.__brand) === void 0,
|
|
132
|
+
"useSubscription: Document must be a valid runtime type."
|
|
133
|
+
);
|
|
134
|
+
invariant(
|
|
135
|
+
!document.watchQueryDocument,
|
|
136
|
+
"useSubscription: Did not expect a watch query document"
|
|
137
|
+
);
|
|
129
138
|
const client = useOverridenOrDefaultApolloClient();
|
|
130
139
|
const { error } = useApolloSubscription(
|
|
131
|
-
|
|
132
|
-
config.subscription,
|
|
140
|
+
document.executionQueryDocument || document,
|
|
133
141
|
{
|
|
134
142
|
client,
|
|
135
143
|
variables: config.variables,
|
|
@@ -157,10 +165,17 @@ function useSubscription(config) {
|
|
|
157
165
|
}
|
|
158
166
|
}
|
|
159
167
|
function useMutation(mutation) {
|
|
168
|
+
invariant(
|
|
169
|
+
(mutation == null ? void 0 : mutation.__brand) === void 0,
|
|
170
|
+
"useMutation: Document must be a valid runtime type."
|
|
171
|
+
);
|
|
172
|
+
invariant(
|
|
173
|
+
!mutation.watchQueryDocument,
|
|
174
|
+
"useMutation: Did not expect a watch query document"
|
|
175
|
+
);
|
|
160
176
|
const client = useOverridenOrDefaultApolloClient();
|
|
161
177
|
const [apolloUpdater, { loading: mutationLoading }] = useApolloMutation(
|
|
162
|
-
|
|
163
|
-
mutation,
|
|
178
|
+
mutation.executionQueryDocument || mutation,
|
|
164
179
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
165
180
|
{ client }
|
|
166
181
|
);
|
|
@@ -169,7 +184,8 @@ function useMutation(mutation) {
|
|
|
169
184
|
const apolloResult = yield apolloUpdater({
|
|
170
185
|
variables: options.variables || {},
|
|
171
186
|
context: options.context,
|
|
172
|
-
optimisticResponse: options.optimisticResponse
|
|
187
|
+
optimisticResponse: options.optimisticResponse,
|
|
188
|
+
update: options.updater
|
|
173
189
|
});
|
|
174
190
|
if (apolloResult.errors) {
|
|
175
191
|
return {
|
package/lib/hooks.mjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/hooks.ts"],
|
|
4
|
-
"sourcesContent": ["import { DocumentNode } from \"graphql\";\nimport invariant from \"invariant\";\nimport {\n useSubscription as useApolloSubscription,\n useQuery as useApolloQuery,\n useMutation as useApolloMutation,\n SubscriptionHookOptions as ApolloSubscriptionHookOptions,\n ErrorPolicy as ApolloErrorPolicy,\n ApolloClient,\n} from \"@apollo/client\";\n\nimport {\n FetchPolicy,\n GraphQLTaggedNode,\n KeyType,\n KeyTypeData,\n OperationType,\n} from \"./types\";\nimport {\n RefetchFn,\n PaginationFn,\n useCompiledLazyLoadQuery,\n useCompiledFragment,\n useCompiledRefetchableFragment,\n useCompiledPaginationFragment,\n} from \"./storeObservation/compiledHooks\";\nimport { convertFetchPolicy } from \"./convertFetchPolicy\";\nimport { useOverridenOrDefaultApolloClient } from \"./useOverridenOrDefaultApolloClient\";\nimport type { CompiledArtefactModule } from \"@graphitation/apollo-react-relay-duct-tape-compiler\";\nimport { FragmentReference } from \"./storeObservation/compiledHooks/types\";\n\n/**\n * Executes a GraphQL query.\n *\n * This hook is called 'lazy' as it is used to fetch a GraphQL query _during_ render. This hook can trigger multiple\n * round trips, one for loading and one for resolving.\n *\n * @see {@link https://microsoft.github.io/graphitation/docs/apollo-react-relay-duct-tape/use-lazy-load-query}\n *\n * @param query The query operation to perform.\n * @param variables Object containing the variable values to fetch the query. These variables need to match GraphQL\n * variables declared inside the query.\n * @param options Options passed on to the underlying implementation.\n * @param options.context The query context to pass along the apollo link chain. Should be avoided when possible as\n * it will not be compatible with Relay APIs.\n * @returns An object with either an error, the result data, or neither while loading.\n */\nexport function useLazyLoadQuery<TQuery extends OperationType>(\n query: GraphQLTaggedNode,\n variables: TQuery[\"variables\"],\n options?: { fetchPolicy?: FetchPolicy; context?: TQuery[\"context\"] },\n): { error?: Error; data?: TQuery[\"response\"] } {\n invariant(\n query?.__brand === undefined,\n \"useLazyLoadQuery: query must be a valid runtime type.\",\n );\n const apolloOptions = options && {\n ...options,\n fetchPolicy: convertFetchPolicy(options.fetchPolicy),\n };\n if (query.watchQueryDocument) {\n return useCompiledLazyLoadQuery(query as CompiledArtefactModule, {\n variables,\n ...apolloOptions,\n });\n } else {\n const client = useOverridenOrDefaultApolloClient();\n return useApolloQuery(\n // Compiled documents without narrow observables should be treated like\n // normal queries.\n query.executionQueryDocument || query,\n {\n client,\n variables,\n ...apolloOptions,\n },\n );\n }\n}\n\n/**\n * A first-class way for an individual component to express its direct data requirements using GraphQL. The fragment\n * should select all the fields that the component directly uses in its rendering or needs to pass to external\n * functions. It should *not* select data that its children need, unless those children are intended to remain their\n * pure React props as data inputs.\n *\n * For children that *do* have their own data requirements expressed using GraphQL, the fragment should ensure to\n * spread in the child's fragment.\n *\n * @see {@link https://microsoft.github.io/graphitation/docs/apollo-react-relay-duct-tape/use-fragment}\n *\n * @note For migration purposes, this hook supports the notion that the fragment reference can be undefined. This is\n * to support cases where useFragment is used in a tree that is conditionally using fragments.\n *\n * @param fragmentInput The GraphQL fragment document created using the `graphql` tagged template function.\n * @param fragmentRef The opaque fragment reference passed in by a parent component that has spread in this component's\n * fragment.\n * @returns The data corresponding to the field selections.\n */\nexport function useFragment<TKey extends KeyType>(\n fragmentInput: GraphQLTaggedNode,\n fragmentRef: TKey,\n): KeyTypeData<TKey>;\nexport function useFragment(\n fragmentInput: GraphQLTaggedNode,\n fragmentRef: undefined,\n): undefined;\nexport function useFragment<TKey extends KeyType>(\n fragmentInput: GraphQLTaggedNode,\n fragmentRef: TKey | undefined,\n): KeyTypeData<TKey> | undefined;\nexport function useFragment<TKey extends KeyType>(\n fragmentInput: GraphQLTaggedNode | undefined,\n fragmentRef: TKey,\n): KeyTypeData<TKey> {\n invariant(\n fragmentInput?.__brand === undefined,\n \"useFragment: fragmentInput must be a valid runtime type.\",\n );\n // If fragmentInput is undefined, it means the fragment is not compiled and we should just return the fragmentRef.\n // This is an implementation detail that should never surface to the user.\n if (fragmentInput && fragmentInput.watchQueryDocument) {\n return useCompiledFragment(fragmentInput, fragmentRef as FragmentReference);\n } else {\n return fragmentRef as unknown;\n }\n}\n\n/**\n * Equivalent to `useFragment`, but allows refetching of its subtree of the overall query.\n *\n * @see {@link https://microsoft.github.io/graphitation/docs/apollo-react-relay-duct-tape/use-refetchable-fragment}\n *\n * @param fragmentInput The GraphQL fragment document created using the `graphql` tagged template function.\n * @param fragmentRef The opaque fragment reference passed in by a parent component that has spread in this component's\n * fragment.\n * @returns The data corresponding to the field selections and a function to perform the refetch.\n */\nexport function useRefetchableFragment<\n TQuery extends OperationType,\n TKey extends KeyType,\n>(\n fragmentInput: GraphQLTaggedNode,\n fragmentRef: TKey,\n): [data: KeyTypeData<TKey>, refetch: RefetchFn<TQuery[\"variables\"]>] {\n invariant(\n fragmentInput,\n \"useRefetchableFragment: Missing metadata; did you forget to use the @refetchable directive?\",\n );\n invariant(\n fragmentInput.__brand === undefined,\n \"useRefetchableFragment: fragmentInput must be a valid runtime type.\",\n );\n invariant(\n !!fragmentInput.watchQueryDocument,\n \"useRefetchableFragment is only supported at this time when using compilation\",\n );\n return useCompiledRefetchableFragment(\n fragmentInput as CompiledArtefactModule,\n fragmentRef as FragmentReference,\n );\n}\n\n/**\n * Equivalent to `useFragment`, but allows pagination of its subtree of the overall query.\n *\n * @see {@link https://microsoft.github.io/graphitation/docs/apollo-react-relay-duct-tape/use-pagination-fragment}\n *\n * @param fragmentInput The GraphQL fragment document created using the `graphql` tagged template function.\n * @param fragmentRef The opaque fragment reference passed in by a parent component that has spread in this component's\n * fragment.\n * @returns The data corresponding to the field selections and functions to deal with pagination.\n */\nexport function usePaginationFragment<\n TQuery extends OperationType,\n TKey extends KeyType,\n>(\n fragmentInput: GraphQLTaggedNode,\n fragmentRef: TKey,\n): {\n data: KeyTypeData<TKey>;\n loadNext: PaginationFn;\n loadPrevious: PaginationFn;\n hasNext: boolean;\n hasPrevious: boolean;\n isLoadingNext: boolean;\n isLoadingPrevious: boolean;\n refetch: RefetchFn<TQuery[\"variables\"]>;\n} {\n invariant(\n fragmentInput,\n \"usePaginationFragment: Missing metadata; did you forget to use the @refetchable directive?\",\n );\n invariant(\n fragmentInput.__brand === undefined,\n \"usePaginationFragment: fragmentInput must be a valid runtime type.\",\n );\n invariant(\n !!fragmentInput.watchQueryDocument,\n \"usePaginationFragment is only supported at this time when using compilation\",\n );\n return useCompiledPaginationFragment(\n fragmentInput as CompiledArtefactModule,\n fragmentRef as FragmentReference,\n );\n}\n\n// https://github.com/facebook/relay/blob/master/website/docs/api-reference/types/GraphQLSubscriptionConfig.md\ninterface GraphQLSubscriptionConfig<\n TSubscriptionPayload extends OperationType,\n> {\n subscription: GraphQLTaggedNode;\n variables: TSubscriptionPayload[\"variables\"];\n /**\n * Should be avoided when possible as it will not be compatible with Relay APIs.\n */\n context?: TSubscriptionPayload[\"context\"];\n /**\n * Should response be nullable?\n */\n onNext?: (response: TSubscriptionPayload[\"response\"]) => void;\n onError?: (error: Error) => void;\n}\n\n/**\n * @see {@link https://microsoft.github.io/graphitation/docs/apollo-react-relay-duct-tape/use-subscription}\n *\n * @param config\n */\nexport function useSubscription<TSubscriptionPayload extends OperationType>(\n config: GraphQLSubscriptionConfig<TSubscriptionPayload>,\n): void {\n const client = useOverridenOrDefaultApolloClient();\n const { error } = useApolloSubscription(\n // TODO: Right now we don't replace mutation documents with imported artefacts.\n config.subscription as DocumentNode,\n {\n client,\n variables: config.variables,\n context: config.context,\n onSubscriptionData: ({ subscriptionData }) => {\n // Supposedly this never gets triggered for an error by design:\n // https://github.com/apollographql/react-apollo/issues/3177#issuecomment-506758144\n invariant(\n !subscriptionData.error,\n \"Did not expect to receive an error here\",\n );\n if (subscriptionData.data && config.onNext) {\n config.onNext(subscriptionData.data);\n }\n },\n errorPolicy: \"ignore\",\n } as ApolloSubscriptionHookOptions & {\n errorPolicy: ApolloErrorPolicy;\n },\n );\n if (error) {\n if (config.onError) {\n config.onError(error);\n } else {\n console.warn(\n `An unhandled GraphQL subscription error occurred: ${error.message}`,\n );\n }\n }\n}\n\ninterface IMutationCommitterOptions<TMutationPayload extends OperationType> {\n variables: TMutationPayload[\"variables\"];\n /**\n * Should be avoided when possible as it will not be compatible with Relay APIs.\n */\n context?: TMutationPayload[\"context\"];\n optimisticResponse?: Partial<TMutationPayload[\"response\"]> | null;\n}\n\ntype MutationCommiter<TMutationPayload extends OperationType> = (\n options: IMutationCommitterOptions<TMutationPayload>,\n) => Promise<{ errors?: Error[]; data?: TMutationPayload[\"response\"] }>;\n\n/**\n * @see {@link https://microsoft.github.io/graphitation/docs/apollo-react-relay-duct-tape/use-mutation}\n *\n * @param mutation\n * @returns\n */\nexport function useMutation<TMutationPayload extends OperationType>(\n mutation: GraphQLTaggedNode,\n): [MutationCommiter<TMutationPayload>, boolean] {\n const client = useOverridenOrDefaultApolloClient();\n const [apolloUpdater, { loading: mutationLoading }] = useApolloMutation(\n // TODO: Right now we don't replace mutation documents with imported artefacts.\n mutation as DocumentNode,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n { client: client as ApolloClient<any> },\n );\n\n return [\n async (options: IMutationCommitterOptions<TMutationPayload>) => {\n const apolloResult = await apolloUpdater({\n variables: options.variables || {},\n context: options.context,\n optimisticResponse: options.optimisticResponse,\n });\n if (apolloResult.errors) {\n return {\n errors: Array.from(Object.values(apolloResult.errors)),\n data: apolloResult.data,\n };\n }\n return {\n data: apolloResult.data,\n };\n },\n mutationLoading,\n ];\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
4
|
+
"sourcesContent": ["import invariant from \"invariant\";\nimport {\n useSubscription as useApolloSubscription,\n useQuery as useApolloQuery,\n useMutation as useApolloMutation,\n SubscriptionHookOptions as ApolloSubscriptionHookOptions,\n ErrorPolicy as ApolloErrorPolicy,\n ApolloClient,\n ApolloCache,\n} from \"@apollo/client\";\n\nimport {\n FetchPolicy,\n GraphQLTaggedNode,\n KeyType,\n KeyTypeData,\n OperationType,\n} from \"./types\";\nimport {\n RefetchFn,\n PaginationFn,\n useCompiledLazyLoadQuery,\n useCompiledFragment,\n useCompiledRefetchableFragment,\n useCompiledPaginationFragment,\n} from \"./storeObservation/compiledHooks\";\nimport { convertFetchPolicy } from \"./convertFetchPolicy\";\nimport { useOverridenOrDefaultApolloClient } from \"./useOverridenOrDefaultApolloClient\";\nimport type { CompiledArtefactModule } from \"@graphitation/apollo-react-relay-duct-tape-compiler\";\nimport { FragmentReference } from \"./storeObservation/compiledHooks/types\";\n\n/**\n * Executes a GraphQL query.\n *\n * This hook is called 'lazy' as it is used to fetch a GraphQL query _during_ render. This hook can trigger multiple\n * round trips, one for loading and one for resolving.\n *\n * @see {@link https://microsoft.github.io/graphitation/docs/apollo-react-relay-duct-tape/use-lazy-load-query}\n *\n * @param query The query operation to perform.\n * @param variables Object containing the variable values to fetch the query. These variables need to match GraphQL\n * variables declared inside the query.\n * @param options Options passed on to the underlying implementation.\n * @param options.context The query context to pass along the apollo link chain. Should be avoided when possible as\n * it will not be compatible with Relay APIs.\n * @returns An object with either an error, the result data, or neither while loading.\n */\nexport function useLazyLoadQuery<TQuery extends OperationType>(\n query: GraphQLTaggedNode,\n variables: TQuery[\"variables\"],\n options?: { fetchPolicy?: FetchPolicy; context?: TQuery[\"context\"] },\n): { error?: Error; data?: TQuery[\"response\"] } {\n invariant(\n query?.__brand === undefined,\n \"useLazyLoadQuery: Document must be a valid runtime type.\",\n );\n const apolloOptions = options && {\n ...options,\n fetchPolicy: convertFetchPolicy(options.fetchPolicy),\n };\n if (query.watchQueryDocument) {\n return useCompiledLazyLoadQuery(query as CompiledArtefactModule, {\n variables,\n ...apolloOptions,\n });\n } else {\n const client = useOverridenOrDefaultApolloClient();\n return useApolloQuery(\n // Compiled documents without narrow observables should be treated like\n // normal queries.\n query.executionQueryDocument || query,\n {\n client,\n variables,\n ...apolloOptions,\n },\n );\n }\n}\n\n/**\n * A first-class way for an individual component to express its direct data requirements using GraphQL. The fragment\n * should select all the fields that the component directly uses in its rendering or needs to pass to external\n * functions. It should *not* select data that its children need, unless those children are intended to remain their\n * pure React props as data inputs.\n *\n * For children that *do* have their own data requirements expressed using GraphQL, the fragment should ensure to\n * spread in the child's fragment.\n *\n * @see {@link https://microsoft.github.io/graphitation/docs/apollo-react-relay-duct-tape/use-fragment}\n *\n * @note For migration purposes, this hook supports the notion that the fragment reference can be undefined. This is\n * to support cases where useFragment is used in a tree that is conditionally using fragments.\n *\n * @param fragmentInput The GraphQL fragment document created using the `graphql` tagged template function.\n * @param fragmentRef The opaque fragment reference passed in by a parent component that has spread in this component's\n * fragment.\n * @returns The data corresponding to the field selections.\n */\nexport function useFragment<TKey extends KeyType>(\n fragmentInput: GraphQLTaggedNode,\n fragmentRef: TKey,\n): KeyTypeData<TKey>;\nexport function useFragment(\n fragmentInput: GraphQLTaggedNode,\n fragmentRef: undefined,\n): undefined;\nexport function useFragment<TKey extends KeyType>(\n fragmentInput: GraphQLTaggedNode,\n fragmentRef: TKey | undefined,\n): KeyTypeData<TKey> | undefined;\nexport function useFragment<TKey extends KeyType>(\n fragmentInput: GraphQLTaggedNode | undefined,\n fragmentRef: TKey,\n): KeyTypeData<TKey> {\n invariant(\n fragmentInput?.__brand === undefined,\n \"useFragment: fragmentInput must be a valid runtime type.\",\n );\n // If fragmentInput is undefined, it means the fragment is not compiled and we should just return the fragmentRef.\n // This is an implementation detail that should never surface to the user.\n if (fragmentInput && fragmentInput.watchQueryDocument) {\n return useCompiledFragment(fragmentInput, fragmentRef as FragmentReference);\n } else {\n return fragmentRef as unknown;\n }\n}\n\n/**\n * Equivalent to `useFragment`, but allows refetching of its subtree of the overall query.\n *\n * @see {@link https://microsoft.github.io/graphitation/docs/apollo-react-relay-duct-tape/use-refetchable-fragment}\n *\n * @param fragmentInput The GraphQL fragment document created using the `graphql` tagged template function.\n * @param fragmentRef The opaque fragment reference passed in by a parent component that has spread in this component's\n * fragment.\n * @returns The data corresponding to the field selections and a function to perform the refetch.\n */\nexport function useRefetchableFragment<\n TQuery extends OperationType,\n TKey extends KeyType,\n>(\n fragmentInput: GraphQLTaggedNode,\n fragmentRef: TKey,\n): [data: KeyTypeData<TKey>, refetch: RefetchFn<TQuery[\"variables\"]>] {\n invariant(\n fragmentInput,\n \"useRefetchableFragment: Missing metadata; did you forget to use the @refetchable directive?\",\n );\n invariant(\n fragmentInput.__brand === undefined,\n \"useRefetchableFragment: fragmentInput must be a valid runtime type.\",\n );\n invariant(\n !!fragmentInput.watchQueryDocument,\n \"useRefetchableFragment is only supported at this time when using compilation\",\n );\n return useCompiledRefetchableFragment(\n fragmentInput as CompiledArtefactModule,\n fragmentRef as FragmentReference,\n );\n}\n\n/**\n * Equivalent to `useFragment`, but allows pagination of its subtree of the overall query.\n *\n * @see {@link https://microsoft.github.io/graphitation/docs/apollo-react-relay-duct-tape/use-pagination-fragment}\n *\n * @param fragmentInput The GraphQL fragment document created using the `graphql` tagged template function.\n * @param fragmentRef The opaque fragment reference passed in by a parent component that has spread in this component's\n * fragment.\n * @returns The data corresponding to the field selections and functions to deal with pagination.\n */\nexport function usePaginationFragment<\n TQuery extends OperationType,\n TKey extends KeyType,\n>(\n fragmentInput: GraphQLTaggedNode,\n fragmentRef: TKey,\n): {\n data: KeyTypeData<TKey>;\n loadNext: PaginationFn;\n loadPrevious: PaginationFn;\n hasNext: boolean;\n hasPrevious: boolean;\n isLoadingNext: boolean;\n isLoadingPrevious: boolean;\n refetch: RefetchFn<TQuery[\"variables\"]>;\n} {\n invariant(\n fragmentInput,\n \"usePaginationFragment: Missing metadata; did you forget to use the @refetchable directive?\",\n );\n invariant(\n fragmentInput.__brand === undefined,\n \"usePaginationFragment: fragmentInput must be a valid runtime type.\",\n );\n invariant(\n !!fragmentInput.watchQueryDocument,\n \"usePaginationFragment is only supported at this time when using compilation\",\n );\n return useCompiledPaginationFragment(\n fragmentInput as CompiledArtefactModule,\n fragmentRef as FragmentReference,\n );\n}\n\n// https://github.com/facebook/relay/blob/master/website/docs/api-reference/types/GraphQLSubscriptionConfig.md\ninterface GraphQLSubscriptionConfig<\n TSubscriptionPayload extends OperationType,\n> {\n subscription: GraphQLTaggedNode;\n variables: TSubscriptionPayload[\"variables\"];\n /**\n * Should be avoided when possible as it will not be compatible with Relay APIs.\n */\n context?: TSubscriptionPayload[\"context\"];\n /**\n * Should response be nullable?\n */\n onNext?: (response: TSubscriptionPayload[\"response\"]) => void;\n onError?: (error: Error) => void;\n}\n\n/**\n * @see {@link https://microsoft.github.io/graphitation/docs/apollo-react-relay-duct-tape/use-subscription}\n *\n * @param config\n */\nexport function useSubscription<TSubscriptionPayload extends OperationType>(\n config: GraphQLSubscriptionConfig<TSubscriptionPayload>,\n): void {\n const document = config.subscription;\n invariant(\n document?.__brand === undefined,\n \"useSubscription: Document must be a valid runtime type.\",\n );\n invariant(\n !document.watchQueryDocument,\n \"useSubscription: Did not expect a watch query document\",\n );\n const client = useOverridenOrDefaultApolloClient();\n const { error } = useApolloSubscription(\n document.executionQueryDocument || document,\n {\n client,\n variables: config.variables,\n context: config.context,\n onSubscriptionData: ({ subscriptionData }) => {\n // Supposedly this never gets triggered for an error by design:\n // https://github.com/apollographql/react-apollo/issues/3177#issuecomment-506758144\n invariant(\n !subscriptionData.error,\n \"Did not expect to receive an error here\",\n );\n if (subscriptionData.data && config.onNext) {\n config.onNext(subscriptionData.data);\n }\n },\n errorPolicy: \"ignore\",\n } as ApolloSubscriptionHookOptions & {\n errorPolicy: ApolloErrorPolicy;\n },\n );\n if (error) {\n if (config.onError) {\n config.onError(error);\n } else {\n console.warn(\n `An unhandled GraphQL subscription error occurred: ${error.message}`,\n );\n }\n }\n}\n\ninterface IMutationCommitterOptions<TMutationPayload extends OperationType> {\n variables: TMutationPayload[\"variables\"];\n optimisticResponse?: Partial<TMutationPayload[\"response\"]> | null;\n /**\n * This version yields the ApolloCache instance, instead of the RelayStore,\n * and usage of it will not be portable to Relay directly. However, it is a\n * necessary evil for migration purposes.\n */\n updater?: (\n cache: ApolloCache<unknown>,\n data: TMutationPayload[\"response\"],\n ) => void;\n /**\n * @deprecated Should be avoided when possible as it will not be compatible with Relay APIs.\n */\n context?: TMutationPayload[\"context\"];\n}\n\ntype MutationCommiter<TMutationPayload extends OperationType> = (\n options: IMutationCommitterOptions<TMutationPayload>,\n) => Promise<{ errors?: Error[]; data?: TMutationPayload[\"response\"] }>;\n\n/**\n * @see {@link https://microsoft.github.io/graphitation/docs/apollo-react-relay-duct-tape/use-mutation}\n *\n * @param mutation\n * @returns\n */\nexport function useMutation<TMutationPayload extends OperationType>(\n mutation: GraphQLTaggedNode,\n): [MutationCommiter<TMutationPayload>, boolean] {\n invariant(\n mutation?.__brand === undefined,\n \"useMutation: Document must be a valid runtime type.\",\n );\n invariant(\n !mutation.watchQueryDocument,\n \"useMutation: Did not expect a watch query document\",\n );\n const client = useOverridenOrDefaultApolloClient();\n const [apolloUpdater, { loading: mutationLoading }] = useApolloMutation(\n mutation.executionQueryDocument || mutation,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n { client: client as ApolloClient<any> },\n );\n\n return [\n async (options: IMutationCommitterOptions<TMutationPayload>) => {\n const apolloResult = await apolloUpdater({\n variables: options.variables || {},\n context: options.context,\n optimisticResponse: options.optimisticResponse,\n update: options.updater,\n });\n if (apolloResult.errors) {\n return {\n errors: Array.from(Object.values(apolloResult.errors)),\n data: apolloResult.data,\n };\n }\n return {\n data: apolloResult.data,\n };\n },\n mutationLoading,\n ];\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,eAAe;AACtB;AAAA,EACE,mBAAmB;AAAA,EACnB,YAAY;AAAA,EACZ,eAAe;AAAA,OAKV;AASP;AAAA,EAGE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,0BAA0B;AACnC,SAAS,yCAAyC;AAoB3C,SAAS,iBACd,OACA,WACA,SAC8C;AAC9C;AAAA,KACE,+BAAO,aAAY;AAAA,IACnB;AAAA,EACF;AACA,QAAM,g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":"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;AAG7D,MAAM,MAAM,YAAY,GAAG,CACzB,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,cAAc,KACrB,UAAU,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;AAG7D,MAAM,MAAM,YAAY,GAAG,CACzB,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,cAAc,KACrB,UAAU,CAAC;AA4LhB,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,CA2DA"}
|
|
@@ -104,10 +104,12 @@ function useLoadMore({
|
|
|
104
104
|
"usePaginationFragment(): Expected mainFragment metadata"
|
|
105
105
|
);
|
|
106
106
|
const cacheSelector = {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
107
|
+
// TODO: If we're dropping default Apollo Cache keys, we can probably just do the below
|
|
108
|
+
id: fragmentReference.id,
|
|
109
|
+
// id: cache.identify({
|
|
110
|
+
// __typename: mainFragment.typeCondition,
|
|
111
|
+
// id: fragmentReference.id as StoreValue,
|
|
112
|
+
// }),
|
|
111
113
|
variables: previousVariables,
|
|
112
114
|
fragmentName: mainFragment.name,
|
|
113
115
|
// Create new document with operation filtered out.
|
|
@@ -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
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAsC;AAEtC,uBAAsB;AACtB,4CAA+C;AAC/C,+CAAkD;AAiClD,SAAS,YAAY;AAAA,EACnB;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,QAAI,uBAAS,KAAK;AACxD,QAAM,eAAW;AAAA,IACf,CAAC,YAAY,YAAY;AAnD7B;AAoDM,2BAAAA;AAAA,QACE;AAAA,QACA;AAAA,MACF;AACA,2BAAAA;AAAA,QACE;AAAA,QACA;AAAA,MACF;AACA,2BAAAA;AAAA,QACE;AAAA,QACA;AAAA,MACF;AACA,YAAM,oBAAoB,iDACrB,cAAS,eAAT,mBAAqB,yBACrB,kBAAkB,cAFG;AAAA,QAGxB,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;AA5EvD,cAAAC;AA+EU,2BAAiB,KAAK;AAEtB,cAAI,CAAC,OAAO;AACV,iCAAAD;AAAA,cACE;AAAA,cACA;AAAA,YACF;AACA,kBAAM,UAAU,SAAS,gBACrB,KAAK,SAAS,aAAa,IAC3B;AACJ,kBAAM,eAAe,SAAS;AAC9B,iCAAAA;AAAA,cACE;AAAA,cACA;AAAA,YACF;AACA,kBAAM,gBAAqD;AAAA,
|
|
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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AAU;AAAA,IACzB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;",
|
|
6
6
|
"names": ["invariant", "_a"]
|
|
7
7
|
}
|
|
@@ -75,10 +75,12 @@ function useLoadMore({
|
|
|
75
75
|
"usePaginationFragment(): Expected mainFragment metadata"
|
|
76
76
|
);
|
|
77
77
|
const cacheSelector = {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
78
|
+
// TODO: If we're dropping default Apollo Cache keys, we can probably just do the below
|
|
79
|
+
id: fragmentReference.id,
|
|
80
|
+
// id: cache.identify({
|
|
81
|
+
// __typename: mainFragment.typeCondition,
|
|
82
|
+
// id: fragmentReference.id as StoreValue,
|
|
83
|
+
// }),
|
|
82
84
|
variables: previousVariables,
|
|
83
85
|
fragmentName: mainFragment.name,
|
|
84
86
|
// Create new document with operation filtered out.
|
|
@@ -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
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,UAAU,mBAAmB;AAEtC,OAAO,eAAe;AACtB,SAAS,sCAAsC;AAC/C,SAAS,yCAAyC;AAiClD,SAAS,YAAY;AAAA,EACnB;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;AAnD7B;AAoDM;AAAA,QACE;AAAA,QACA;AAAA,MACF;AACA;AAAA,QACE;AAAA,QACA;AAAA,MACF;AACA;AAAA,QACE;AAAA,QACA;AAAA,MACF;AACA,YAAM,oBAAoB,iDACrB,cAAS,eAAT,mBAAqB,yBACrB,kBAAkB,cAFG;AAAA,QAGxB,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;AA5EvD,cAAAA;AA+EU,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,
|
|
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,mBAAmB;AAEtC,OAAO,eAAe;AACtB,SAAS,sCAAsC;AAC/C,SAAS,yCAAyC;AAiClD,SAAS,YAAY;AAAA,EACnB;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;AAnD7B;AAoDM;AAAA,QACE;AAAA,QACA;AAAA,MACF;AACA;AAAA,QACE;AAAA,QACA;AAAA,MACF;AACA;AAAA,QACE;AAAA,QACA;AAAA,MACF;AACA,YAAM,oBAAoB,iDACrB,cAAS,eAAT,mBAAqB,yBACrB,kBAAkB,cAFG;AAAA,QAGxB,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;AA5EvD,cAAAA;AA+EU,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;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AA,IACzB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;",
|
|
6
6
|
"names": ["_a"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { KeyFieldsFunction } from "@apollo/client/cache/inmemory/policies";
|
|
2
|
+
import { GraphQLSchema } from "graphql";
|
|
3
|
+
export declare function getPossibleTypesAndDataIdFromNode(schema: GraphQLSchema): {
|
|
4
|
+
possibleTypes: Record<string, string[]>;
|
|
5
|
+
dataIdFromNode: KeyFieldsFunction;
|
|
6
|
+
};
|
|
7
|
+
//# sourceMappingURL=getPossibleTypesAndDataIdFromNode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getPossibleTypesAndDataIdFromNode.d.ts","sourceRoot":"","sources":["../../src/storeObservation/getPossibleTypesAndDataIdFromNode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAC3E,OAAO,EAAE,aAAa,EAAgC,MAAM,SAAS,CAAC;AAGtE,wBAAgB,iCAAiC,CAAC,MAAM,EAAE,aAAa,GAAG;IACxE,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IACxC,cAAc,EAAE,iBAAiB,CAAC;CACnC,CAiCA"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var getPossibleTypesAndDataIdFromNode_exports = {};
|
|
30
|
+
__export(getPossibleTypesAndDataIdFromNode_exports, {
|
|
31
|
+
getPossibleTypesAndDataIdFromNode: () => getPossibleTypesAndDataIdFromNode
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(getPossibleTypesAndDataIdFromNode_exports);
|
|
34
|
+
var import_graphql = require("graphql");
|
|
35
|
+
var import_invariant = __toESM(require("invariant"));
|
|
36
|
+
function getPossibleTypesAndDataIdFromNode(schema) {
|
|
37
|
+
const possibleTypes = {};
|
|
38
|
+
const typeMap = schema.getTypeMap();
|
|
39
|
+
for (const typeName in typeMap) {
|
|
40
|
+
const type = typeMap[typeName];
|
|
41
|
+
if ((0, import_graphql.isInterfaceType)(type)) {
|
|
42
|
+
const implementations = schema.getImplementations(type);
|
|
43
|
+
possibleTypes[typeName] = [
|
|
44
|
+
...implementations.objects,
|
|
45
|
+
...implementations.interfaces
|
|
46
|
+
].map((x) => x.name);
|
|
47
|
+
} else if ((0, import_graphql.isUnionType)(type)) {
|
|
48
|
+
possibleTypes[typeName] = schema.getPossibleTypes(type).map((x) => x.name);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
(0, import_invariant.default)(
|
|
52
|
+
possibleTypes.Node,
|
|
53
|
+
"Node interface and implementations thereof must be defined"
|
|
54
|
+
);
|
|
55
|
+
return {
|
|
56
|
+
possibleTypes,
|
|
57
|
+
dataIdFromNode: (object) => {
|
|
58
|
+
if (object.id && object.__typename && possibleTypes.Node.includes(object.__typename)) {
|
|
59
|
+
return object.id;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/storeObservation/getPossibleTypesAndDataIdFromNode.ts"],
|
|
4
|
+
"sourcesContent": ["import { KeyFieldsFunction } from \"@apollo/client/cache/inmemory/policies\";\nimport { GraphQLSchema, isInterfaceType, isUnionType } from \"graphql\";\nimport invariant from \"invariant\";\n\nexport function getPossibleTypesAndDataIdFromNode(schema: GraphQLSchema): {\n possibleTypes: Record<string, string[]>;\n dataIdFromNode: KeyFieldsFunction;\n} {\n const possibleTypes: Record<string, string[]> = {};\n const typeMap = schema.getTypeMap();\n for (const typeName in typeMap) {\n const type = typeMap[typeName];\n if (isInterfaceType(type)) {\n const implementations = schema.getImplementations(type);\n possibleTypes[typeName] = [\n ...implementations.objects,\n ...implementations.interfaces,\n ].map((x) => x.name);\n } else if (isUnionType(type)) {\n possibleTypes[typeName] = schema\n .getPossibleTypes(type)\n .map((x) => x.name);\n }\n }\n invariant(\n possibleTypes.Node,\n \"Node interface and implementations thereof must be defined\",\n );\n return {\n possibleTypes,\n dataIdFromNode: (object) => {\n if (\n object.id &&\n object.__typename &&\n possibleTypes.Node.includes(object.__typename)\n ) {\n return object.id as string;\n }\n },\n };\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,qBAA4D;AAC5D,uBAAsB;AAEf,SAAS,kCAAkC,QAGhD;AACA,QAAM,gBAA0C,CAAC;AACjD,QAAM,UAAU,OAAO,WAAW;AAClC,aAAW,YAAY,SAAS;AAC9B,UAAM,OAAO,QAAQ,QAAQ;AAC7B,YAAI,gCAAgB,IAAI,GAAG;AACzB,YAAM,kBAAkB,OAAO,mBAAmB,IAAI;AACtD,oBAAc,QAAQ,IAAI;AAAA,QACxB,GAAG,gBAAgB;AAAA,QACnB,GAAG,gBAAgB;AAAA,MACrB,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI;AAAA,IACrB,eAAW,4BAAY,IAAI,GAAG;AAC5B,oBAAc,QAAQ,IAAI,OACvB,iBAAiB,IAAI,EACrB,IAAI,CAAC,MAAM,EAAE,IAAI;AAAA,IACtB;AAAA,EACF;AACA,uBAAAA;AAAA,IACE,cAAc;AAAA,IACd;AAAA,EACF;AACA,SAAO;AAAA,IACL;AAAA,IACA,gBAAgB,CAAC,WAAW;AAC1B,UACE,OAAO,MACP,OAAO,cACP,cAAc,KAAK,SAAS,OAAO,UAAU,GAC7C;AACA,eAAO,OAAO;AAAA,MAChB;AAAA,IACF;AAAA,EACF;AACF;",
|
|
6
|
+
"names": ["invariant"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// src/storeObservation/getPossibleTypesAndDataIdFromNode.ts
|
|
2
|
+
import { isInterfaceType, isUnionType } from "graphql";
|
|
3
|
+
import invariant from "invariant";
|
|
4
|
+
function getPossibleTypesAndDataIdFromNode(schema) {
|
|
5
|
+
const possibleTypes = {};
|
|
6
|
+
const typeMap = schema.getTypeMap();
|
|
7
|
+
for (const typeName in typeMap) {
|
|
8
|
+
const type = typeMap[typeName];
|
|
9
|
+
if (isInterfaceType(type)) {
|
|
10
|
+
const implementations = schema.getImplementations(type);
|
|
11
|
+
possibleTypes[typeName] = [
|
|
12
|
+
...implementations.objects,
|
|
13
|
+
...implementations.interfaces
|
|
14
|
+
].map((x) => x.name);
|
|
15
|
+
} else if (isUnionType(type)) {
|
|
16
|
+
possibleTypes[typeName] = schema.getPossibleTypes(type).map((x) => x.name);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
invariant(
|
|
20
|
+
possibleTypes.Node,
|
|
21
|
+
"Node interface and implementations thereof must be defined"
|
|
22
|
+
);
|
|
23
|
+
return {
|
|
24
|
+
possibleTypes,
|
|
25
|
+
dataIdFromNode: (object) => {
|
|
26
|
+
if (object.id && object.__typename && possibleTypes.Node.includes(object.__typename)) {
|
|
27
|
+
return object.id;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export {
|
|
33
|
+
getPossibleTypesAndDataIdFromNode
|
|
34
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/storeObservation/getPossibleTypesAndDataIdFromNode.ts"],
|
|
4
|
+
"sourcesContent": ["import { KeyFieldsFunction } from \"@apollo/client/cache/inmemory/policies\";\nimport { GraphQLSchema, isInterfaceType, isUnionType } from \"graphql\";\nimport invariant from \"invariant\";\n\nexport function getPossibleTypesAndDataIdFromNode(schema: GraphQLSchema): {\n possibleTypes: Record<string, string[]>;\n dataIdFromNode: KeyFieldsFunction;\n} {\n const possibleTypes: Record<string, string[]> = {};\n const typeMap = schema.getTypeMap();\n for (const typeName in typeMap) {\n const type = typeMap[typeName];\n if (isInterfaceType(type)) {\n const implementations = schema.getImplementations(type);\n possibleTypes[typeName] = [\n ...implementations.objects,\n ...implementations.interfaces,\n ].map((x) => x.name);\n } else if (isUnionType(type)) {\n possibleTypes[typeName] = schema\n .getPossibleTypes(type)\n .map((x) => x.name);\n }\n }\n invariant(\n possibleTypes.Node,\n \"Node interface and implementations thereof must be defined\",\n );\n return {\n possibleTypes,\n dataIdFromNode: (object) => {\n if (\n object.id &&\n object.__typename &&\n possibleTypes.Node.includes(object.__typename)\n ) {\n return object.id as string;\n }\n },\n };\n}\n"],
|
|
5
|
+
"mappings": ";AACA,SAAwB,iBAAiB,mBAAmB;AAC5D,OAAO,eAAe;AAEf,SAAS,kCAAkC,QAGhD;AACA,QAAM,gBAA0C,CAAC;AACjD,QAAM,UAAU,OAAO,WAAW;AAClC,aAAW,YAAY,SAAS;AAC9B,UAAM,OAAO,QAAQ,QAAQ;AAC7B,QAAI,gBAAgB,IAAI,GAAG;AACzB,YAAM,kBAAkB,OAAO,mBAAmB,IAAI;AACtD,oBAAc,QAAQ,IAAI;AAAA,QACxB,GAAG,gBAAgB;AAAA,QACnB,GAAG,gBAAgB;AAAA,MACrB,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI;AAAA,IACrB,WAAW,YAAY,IAAI,GAAG;AAC5B,oBAAc,QAAQ,IAAI,OACvB,iBAAiB,IAAI,EACrB,IAAI,CAAC,MAAM,EAAE,IAAI;AAAA,IACtB;AAAA,EACF;AACA;AAAA,IACE,cAAc;AAAA,IACd;AAAA,EACF;AACA,SAAO;AAAA,IACL;AAAA,IACA,gBAAgB,CAAC,WAAW;AAC1B,UACE,OAAO,MACP,OAAO,cACP,cAAc,KAAK,SAAS,OAAO,UAAU,GAC7C;AACA,eAAO,OAAO;AAAA,MAChB;AAAA,IACF;AAAA,EACF;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -2,4 +2,5 @@ export * from "./nodeFromCacheFieldPolicy";
|
|
|
2
2
|
export * from "./fragmentReferencesFieldPolicy";
|
|
3
3
|
export * from "./typePolicies";
|
|
4
4
|
export * from "./shallowCompareFragmentReferences";
|
|
5
|
+
export * from "./getPossibleTypesAndDataIdFromNode";
|
|
5
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/storeObservation/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/storeObservation/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,iCAAiC,CAAC;AAChD,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oCAAoC,CAAC;AACnD,cAAc,qCAAqC,CAAC"}
|
|
@@ -19,3 +19,4 @@ __reExport(storeObservation_exports, require("./nodeFromCacheFieldPolicy"), modu
|
|
|
19
19
|
__reExport(storeObservation_exports, require("./fragmentReferencesFieldPolicy"), module.exports);
|
|
20
20
|
__reExport(storeObservation_exports, require("./typePolicies"), module.exports);
|
|
21
21
|
__reExport(storeObservation_exports, require("./shallowCompareFragmentReferences"), module.exports);
|
|
22
|
+
__reExport(storeObservation_exports, require("./getPossibleTypesAndDataIdFromNode"), module.exports);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/storeObservation/index.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["export * from \"./nodeFromCacheFieldPolicy\";\nexport * from \"./fragmentReferencesFieldPolicy\";\nexport * from \"./typePolicies\";\nexport * from \"./shallowCompareFragmentReferences\";\nexport * from \"./getPossibleTypesAndDataIdFromNode\";\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,qCAAc,uCAAd;AACA,qCAAc,4CADd;AAEA,qCAAc,2BAFd;AAGA,qCAAc,+CAHd;AAIA,qCAAc,gDAJd;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/storeObservation/index.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["export * from \"./nodeFromCacheFieldPolicy\";\nexport * from \"./fragmentReferencesFieldPolicy\";\nexport * from \"./typePolicies\";\nexport * from \"./shallowCompareFragmentReferences\";\nexport * from \"./getPossibleTypesAndDataIdFromNode\";\n"],
|
|
5
|
+
"mappings": ";AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;",
|
|
6
6
|
"names": []
|
|
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.10",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "https://github.com/microsoft/graphitation.git",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"graphql": "^15.0.0",
|
|
31
31
|
"monorepo-scripts": "*",
|
|
32
32
|
"react": "^17.0.2",
|
|
33
|
-
"@graphitation/apollo-react-relay-duct-tape-compiler": "^1.2.
|
|
33
|
+
"@graphitation/apollo-react-relay-duct-tape-compiler": "^1.2.3",
|
|
34
34
|
"ts-expect": "^1.3.0"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|