@graphitation/apollo-react-relay-duct-tape 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/.eslintcache +1 -1
  2. package/CHANGELOG.md +10 -2
  3. package/lib/hooks.d.ts.map +1 -1
  4. package/lib/hooks.js +1 -0
  5. package/lib/hooks.js.map +2 -2
  6. package/lib/hooks.mjs +1 -0
  7. package/lib/hooks.mjs.map +2 -2
  8. package/lib/storeObservation/compiledHooks/types.d.ts.map +1 -1
  9. package/lib/storeObservation/compiledHooks/types.js.map +1 -1
  10. package/lib/storeObservation/compiledHooks/useCompiledFragment.d.ts +1 -1
  11. package/lib/storeObservation/compiledHooks/useCompiledFragment.d.ts.map +1 -1
  12. package/lib/storeObservation/compiledHooks/useCompiledFragment.js.map +2 -2
  13. package/lib/storeObservation/compiledHooks/useCompiledFragment.mjs.map +2 -2
  14. package/lib/storeObservation/compiledHooks/useCompiledLazyLoadQuery.d.ts +2 -2
  15. package/lib/storeObservation/compiledHooks/useCompiledLazyLoadQuery.d.ts.map +1 -1
  16. package/lib/storeObservation/compiledHooks/useCompiledLazyLoadQuery.js.map +2 -2
  17. package/lib/storeObservation/compiledHooks/useCompiledLazyLoadQuery.mjs.map +2 -2
  18. package/lib/storeObservation/compiledHooks/useCompiledPaginationFragment.d.ts.map +1 -1
  19. package/lib/storeObservation/compiledHooks/useCompiledPaginationFragment.js +1 -1
  20. package/lib/storeObservation/compiledHooks/useCompiledPaginationFragment.js.map +2 -2
  21. package/lib/storeObservation/compiledHooks/useCompiledPaginationFragment.mjs +1 -1
  22. package/lib/storeObservation/compiledHooks/useCompiledPaginationFragment.mjs.map +2 -2
  23. package/lib/storeObservation/compiledHooks/useCompiledRefetchableFragment.d.ts +2 -2
  24. package/lib/storeObservation/compiledHooks/useCompiledRefetchableFragment.d.ts.map +1 -1
  25. package/lib/storeObservation/compiledHooks/useCompiledRefetchableFragment.js +2 -2
  26. package/lib/storeObservation/compiledHooks/useCompiledRefetchableFragment.js.map +2 -2
  27. package/lib/storeObservation/compiledHooks/useCompiledRefetchableFragment.mjs +2 -2
  28. package/lib/storeObservation/compiledHooks/useCompiledRefetchableFragment.mjs.map +2 -2
  29. package/lib/storeObservation/nodeFromCacheFieldPolicy.js +6 -5
  30. package/lib/storeObservation/nodeFromCacheFieldPolicy.js.map +2 -2
  31. package/lib/storeObservation/nodeFromCacheFieldPolicy.mjs +6 -5
  32. package/lib/storeObservation/nodeFromCacheFieldPolicy.mjs.map +2 -2
  33. package/lib/storeObservation/shallowCompareFragmentReferences.d.ts +5 -1
  34. package/lib/storeObservation/shallowCompareFragmentReferences.d.ts.map +1 -1
  35. package/lib/storeObservation/shallowCompareFragmentReferences.js +1 -1
  36. package/lib/storeObservation/shallowCompareFragmentReferences.js.map +2 -2
  37. package/lib/storeObservation/shallowCompareFragmentReferences.mjs +1 -1
  38. package/lib/storeObservation/shallowCompareFragmentReferences.mjs.map +2 -2
  39. package/lib/types.d.ts.map +1 -1
  40. package/lib/types.js.map +1 -1
  41. package/lib/useOverridenOrDefaultApolloClient.d.ts +1 -1
  42. package/lib/useOverridenOrDefaultApolloClient.d.ts.map +1 -1
  43. package/lib/useOverridenOrDefaultApolloClient.js.map +2 -2
  44. package/lib/useOverridenOrDefaultApolloClient.mjs.map +2 -2
  45. 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":10718,"mtime":1684763689402,"results":"24","hashOfConfig":"25"},{"size":1917,"mtime":1684763689402,"results":"26","hashOfConfig":"25"},{"size":690,"mtime":1684763689402,"results":"27","hashOfConfig":"25"},{"size":9748,"mtime":1684763689402,"results":"28","hashOfConfig":"25"},{"size":174,"mtime":1684763689402,"results":"29","hashOfConfig":"25"},{"size":33738,"mtime":1684763689402,"results":"30","hashOfConfig":"25"},{"size":1839,"mtime":1684763689402,"results":"31","hashOfConfig":"25"},{"size":3041,"mtime":1684763689402,"results":"32","hashOfConfig":"25"},{"size":445,"mtime":1684763689402,"results":"33","hashOfConfig":"25"},{"size":518,"mtime":1684763689406,"results":"34","hashOfConfig":"25"},{"size":2422,"mtime":1684763689406,"results":"35","hashOfConfig":"25"},{"size":3569,"mtime":1684763689406,"results":"36","hashOfConfig":"25"},{"size":8911,"mtime":1684763689406,"results":"37","hashOfConfig":"25"},{"size":5335,"mtime":1684763689406,"results":"38","hashOfConfig":"25"},{"size":843,"mtime":1684763689406,"results":"39","hashOfConfig":"25"},{"size":152,"mtime":1684763689406,"results":"40","hashOfConfig":"25"},{"size":286,"mtime":1684763689406,"results":"41","hashOfConfig":"25"},{"size":342,"mtime":1684763689406,"results":"42","hashOfConfig":"25"},{"size":2829,"mtime":1684763689406,"results":"43","hashOfConfig":"25"},{"size":2093,"mtime":1684763689406,"results":"44","hashOfConfig":"25"},{"size":1110,"mtime":1684763689406,"results":"45","hashOfConfig":"25"},{"size":1759,"mtime":1684763689406,"results":"46","hashOfConfig":"25"},{"size":1239,"mtime":1684763689406,"results":"47","hashOfConfig":"25"},{"filePath":"48","messages":"49","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"lvruzq",{"filePath":"50","messages":"51","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"52","messages":"53","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"54","messages":"55","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"56","messages":"57","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"58","messages":"59","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"60","messages":"61","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"62","messages":"63","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"64","messages":"65","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"66","messages":"67","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"68","messages":"69","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"70","messages":"71","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"72","messages":"73","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"74","messages":"75","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"76","messages":"77","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"78","messages":"79","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"80","messages":"81","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"82","messages":"83","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"84","messages":"85","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"86","messages":"87","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"88","messages":"89","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"90","messages":"91","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"92","messages":"93","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",[],"/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",[],"/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",[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/compiledHooks/useCompiledPaginationFragment.ts",[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/compiledHooks/useCompiledRefetchableFragment.ts",[],"/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",[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/useOverridenOrDefaultApolloClient.ts",[]]
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":10715,"mtime":1686573991100,"results":"24","hashOfConfig":"25"},{"size":1917,"mtime":1686573991100,"results":"26","hashOfConfig":"25"},{"size":690,"mtime":1686573991100,"results":"27","hashOfConfig":"25"},{"size":10134,"mtime":1686573991100,"results":"28","hashOfConfig":"25"},{"size":174,"mtime":1686573991100,"results":"29","hashOfConfig":"25"},{"size":33757,"mtime":1686573991100,"results":"30","hashOfConfig":"25"},{"size":1839,"mtime":1686573991100,"results":"31","hashOfConfig":"25"},{"size":3041,"mtime":1686573991100,"results":"32","hashOfConfig":"25"},{"size":445,"mtime":1686573991100,"results":"33","hashOfConfig":"25"},{"size":575,"mtime":1686573991100,"results":"34","hashOfConfig":"25"},{"size":2426,"mtime":1686573991100,"results":"35","hashOfConfig":"25"},{"size":3662,"mtime":1686573991100,"results":"36","hashOfConfig":"25"},{"size":9254,"mtime":1686573991100,"results":"37","hashOfConfig":"25"},{"size":5414,"mtime":1686573991100,"results":"38","hashOfConfig":"25"},{"size":843,"mtime":1686573991100,"results":"39","hashOfConfig":"25"},{"size":152,"mtime":1686573991100,"results":"40","hashOfConfig":"25"},{"size":286,"mtime":1686573991100,"results":"41","hashOfConfig":"25"},{"size":342,"mtime":1686573991100,"results":"42","hashOfConfig":"25"},{"size":2829,"mtime":1686573991100,"results":"43","hashOfConfig":"25"},{"size":2163,"mtime":1686573991100,"results":"44","hashOfConfig":"25"},{"size":1110,"mtime":1686573991100,"results":"45","hashOfConfig":"25"},{"size":1889,"mtime":1686573991100,"results":"46","hashOfConfig":"25"},{"size":1314,"mtime":1686573991100,"results":"47","hashOfConfig":"25"},{"filePath":"48","messages":"49","suppressedMessages":"50","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"mptc0p",{"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":249,"column":38,"nodeType":"131","messageId":"132","endLine":249,"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"},[9584,9587],"unknown","never",[567,570],[2626,2629],[5394,5397],[5495,5498],[5595,5598],[5884,5887],[6948,6951],[1283,1286],[158,161],[276,279],[455,458]]
package/CHANGELOG.md CHANGED
@@ -1,12 +1,20 @@
1
1
  # Change Log - @graphitation/apollo-react-relay-duct-tape
2
2
 
3
- This log was last generated on Mon, 22 May 2023 13:58:45 GMT and should not be manually modified.
3
+ This log was last generated on Mon, 12 Jun 2023 12:50:42 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## 1.0.2
8
+
9
+ Mon, 12 Jun 2023 12:50:42 GMT
10
+
11
+ ### Patches
12
+
13
+ - Bump @graphitation/apollo-react-relay-duct-tape-compiler to v1.0.0
14
+
7
15
  ## 1.0.1
8
16
 
9
- Mon, 22 May 2023 13:58:45 GMT
17
+ Mon, 22 May 2023 13:58:50 GMT
10
18
 
11
19
  ### Patches
12
20
 
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAUA,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;AAI1C;;;;;;;;;;;;;;;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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,oBAAoB,CAAC,WAAW,CAAC,CAAC;IAC7C;;OAEG;IACH,OAAO,CAAC,EAAE,oBAAoB,CAAC,SAAS,CAAC,CAAC;IAC1C;;OAEG;IACH,MAAM,CAAC,EAAE,CAAC,QAAQ,EAAE,oBAAoB,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,CAkCN;AAED,UAAU,yBAAyB,CAAC,gBAAgB,SAAS,aAAa;IACxE,SAAS,EAAE,gBAAgB,CAAC,WAAW,CAAC,CAAC;IACzC;;OAEG;IACH,OAAO,CAAC,EAAE,gBAAgB,CAAC,SAAS,CAAC,CAAC;IACtC,kBAAkB,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC,GAAG,IAAI,CAAC;CACnE;AAED,aAAK,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,CA4B/C"}
package/lib/hooks.js CHANGED
@@ -154,6 +154,7 @@ function useMutation(mutation) {
154
154
  const [apolloUpdater, { loading: mutationLoading }] = (0, import_client.useMutation)(
155
155
  // TODO: Right now we don't replace mutation documents with imported artefacts.
156
156
  mutation,
157
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
157
158
  { client }
158
159
  );
159
160
  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} 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\";\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 const apolloOptions = options && {\n ...options,\n fetchPolicy: convertFetchPolicy(options.fetchPolicy),\n };\n if (query.watchQueryDocument) {\n return useCompiledLazyLoadQuery(query as any, {\n variables,\n ...apolloOptions,\n });\n } else {\n const client = useOverridenOrDefaultApolloClient();\n return useApolloQuery(query, { client, variables, ...apolloOptions });\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 now, the fragment objects should be exported such that parent's can interpolate them into their own\n * GraphQL documents. This may change in the future when/if we entirely switch to static compilation and will\n * allow us to also move the usage of the graphql tagged template function inline at the `useFragment` call-site.\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> {\n if (fragmentInput.watchQueryDocument) {\n return useCompiledFragment(fragmentInput, fragmentRef as any);\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.watchQueryDocument,\n \"useRefetchableFragment is only supported at this time when using compilation\",\n );\n return useCompiledRefetchableFragment(\n fragmentInput as any,\n fragmentRef as any,\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.watchQueryDocument,\n \"usePaginationFragment is only supported at this time when using compilation\",\n );\n return useCompiledPaginationFragment(\n fragmentInput as any,\n fragmentRef as any,\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 { client },\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 },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AAAD;AAAA,UACE,CAAC,iBAAiB;AAAA,UAClB;AAAA,QACF;AACA,YAAI,iBAAiB,QAAQ,OAAO,QAAQ;AAC1C,iBAAO,OAAO,iBAAiB,IAAI;AAAA,QACrC;AAAA,MACF;AAAA,MACA,aAAa;AAAA,IACf;AAAA,EAGF;AACA,MAAI,OAAO;AACT,QAAI,OAAO,SAAS;AAClB,aAAO,QAAQ,KAAK;AAAA,IACtB,OAAO;AACL,cAAQ;AAAA,QACN,qDAAqD,MAAM;AAAA,MAC7D;AAAA,IACF;AAAA,EACF;AACF;AAqBO,SAAS,YACd,UAC+C;AAC/C,QAAM,aAAS,4EAAkC;AACjD,QAAM,CAAC,eAAe,EAAE,SAAS,gBAAgB,CAAC,QAAI,cAAAE;AAAA;AAAA,IAEpD;AAAA,IACA,EAAE,OAAO;AAAA,EACX;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,MAC9B,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;",
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 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(query, { client, variables, ...apolloOptions });\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 now, the fragment objects should be exported such that parent's can interpolate them into their own\n * GraphQL documents. This may change in the future when/if we entirely switch to static compilation and will\n * allow us to also move the usage of the graphql tagged template function inline at the `useFragment` call-site.\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> {\n if (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.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.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;AACA,uBAAsB;AACtB,oBAOO;AASP,2BAOO;AACP,gCAAmC;AACnC,+CAAkD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AAO,QAAQ,KAAK;AAAA,IACtB,OAAO;AACL,cAAQ;AAAA,QACN,qDAAqD,MAAM;AAAA,MAC7D;AAAA,IACF;AAAA,EACF;AACF;AAqBO,SAAS,YACd,UAC+C;AAC/C,QAAM,aAAS,4EAAkC;AACjD,QAAM,CAAC,eAAe,EAAE,SAAS,gBAAgB,CAAC,QAAI,cAAAE;AAAA;AAAA,IAEpD;AAAA;AAAA,IAEA,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,MAC9B,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": ["useApolloQuery", "invariant", "useApolloSubscription", "useApolloMutation"]
7
7
  }
package/lib/hooks.mjs CHANGED
@@ -129,6 +129,7 @@ function useMutation(mutation) {
129
129
  const [apolloUpdater, { loading: mutationLoading }] = useApolloMutation(
130
130
  // TODO: Right now we don't replace mutation documents with imported artefacts.
131
131
  mutation,
132
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
132
133
  { client }
133
134
  );
134
135
  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} 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\";\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 const apolloOptions = options && {\n ...options,\n fetchPolicy: convertFetchPolicy(options.fetchPolicy),\n };\n if (query.watchQueryDocument) {\n return useCompiledLazyLoadQuery(query as any, {\n variables,\n ...apolloOptions,\n });\n } else {\n const client = useOverridenOrDefaultApolloClient();\n return useApolloQuery(query, { client, variables, ...apolloOptions });\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 now, the fragment objects should be exported such that parent's can interpolate them into their own\n * GraphQL documents. This may change in the future when/if we entirely switch to static compilation and will\n * allow us to also move the usage of the graphql tagged template function inline at the `useFragment` call-site.\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> {\n if (fragmentInput.watchQueryDocument) {\n return useCompiledFragment(fragmentInput, fragmentRef as any);\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.watchQueryDocument,\n \"useRefetchableFragment is only supported at this time when using compilation\",\n );\n return useCompiledRefetchableFragment(\n fragmentInput as any,\n fragmentRef as any,\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.watchQueryDocument,\n \"usePaginationFragment is only supported at this time when using compilation\",\n );\n return useCompiledPaginationFragment(\n fragmentInput as any,\n fragmentRef as any,\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 { client },\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": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,OAAO,eAAe;AACtB;AAAA,EACE,mBAAmB;AAAA,EACnB,YAAY;AAAA,EACZ,eAAe;AAAA,OAGV;AASP;AAAA,EAGE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,0BAA0B;AACnC,SAAS,yCAAyC;AAkB3C,SAAS,iBACd,OACA,W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AM;AAAA,MAC7D;AAAA,IACF;AAAA,EACF;AACF;AAqBO,SAAS,YACd,UAC+C;AAC/C,QAAM,SAAS,kCAAkC;AACjD,QAAM,CAAC,eAAe,EAAE,SAAS,gBAAgB,CAAC,IAAI;AAAA;AAAA,IAEpD;AAAA,IACA,EAAE,OAAO;AAAA,EACX;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,MAC9B,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;",
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 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(query, { client, variables, ...apolloOptions });\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 now, the fragment objects should be exported such that parent's can interpolate them into their own\n * GraphQL documents. This may change in the future when/if we entirely switch to static compilation and will\n * allow us to also move the usage of the graphql tagged template function inline at the `useFragment` call-site.\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> {\n if (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.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.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": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,OAAO,eAAe;AACtB;AAAA,EACE,mBAAmB;AAAA,EACnB,YAAY;AAAA,EACZ,eAAe;AAAA,OAIV;AASP;AAAA,EAGE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,0BAA0B;AACnC,SAAS,yCAAyC;AAoB3C,SAAS,iBACd,OACA,WACA,SAC8C;AAC9C,QAAM,gBAAgB,WAAW,iCAC5B,UAD4B;AAAA,IAE/B,aAAa,mBAAmB,QAAQ,WAAW;AAAA,EACrD;AACA,MAAI,MAAM,oBAAoB;AAC5B,WAAO,yBAAyB,OAAiC;AAAA,MAC/D;AAAA,OACG,cACJ;AAAA,EACH,OAAO;AACL,UAAM,SAAS,kCAAkC;AACjD,WAAO,eAAe,O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AAC9D,YAAM,eAAe,MAAM,cAAc;AAAA,QACvC,WAAW,QAAQ,aAAa,CAAC;AAAA,QACjC,SAAS,QAAQ;AAAA,QACjB,oBAAoB,QAAQ;AAAA,MAC9B,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": []
7
7
  }
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/storeObservation/compiledHooks/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAChC;;;OAGG;IACH,EAAE,CAAC,EAAE,OAAO,CAAC;IAEb;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACnC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/storeObservation/compiledHooks/types.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,iBAAiB;IAChC;;;OAGG;IACH,EAAE,CAAC,EAAE,OAAO,CAAC;IAEb;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACnC"}
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/storeObservation/compiledHooks/types.ts"],
4
- "sourcesContent": ["export interface FragmentReference {\n /**\n * In case of a watch query on a Node type, the `id` needs to be provided.\n * In case of a watch query on the Query type, this should be omitted.\n */\n id?: unknown;\n\n /**\n * These are the request variables, which is named awkwardly `__fragments`\n * because that's the name of the property Relay uses to pass context data so\n * not introducing a different property name felt right, from a migration\n * perspective.\n */\n __fragments?: Record<string, any>;\n}\n"],
4
+ "sourcesContent": ["/* eslint-disable @typescript-eslint/no-explicit-any */\n\nexport interface FragmentReference {\n /**\n * In case of a watch query on a Node type, the `id` needs to be provided.\n * In case of a watch query on the Query type, this should be omitted.\n */\n id?: unknown;\n\n /**\n * These are the request variables, which is named awkwardly `__fragments`\n * because that's the name of the property Relay uses to pass context data so\n * not introducing a different property name felt right, from a migration\n * perspective.\n */\n __fragments?: Record<string, any>;\n}\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
6
6
  "names": []
7
7
  }
@@ -5,5 +5,5 @@ import type { CompiledArtefactModule } from "@graphitation/apollo-react-relay-du
5
5
  * observable for just the data selected by the original fragment.
6
6
  * @param fragmentReference A Node object that has a globally unique `id` field.
7
7
  */
8
- export declare function useCompiledFragment(documents: CompiledArtefactModule, fragmentReference: FragmentReference): {};
8
+ export declare function useCompiledFragment(documents: CompiledArtefactModule, fragmentReference: FragmentReference): object;
9
9
  //# sourceMappingURL=useCompiledFragment.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useCompiledFragment.d.ts","sourceRoot":"","sources":["../../../src/storeObservation/compiledHooks/useCompiledFragment.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qDAAqD,CAAC;AAElG;;;;GAIG;AAEH,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,sBAAsB,EACjC,iBAAiB,EAAE,iBAAiB,GACnC,EAAE,CA2DJ"}
1
+ {"version":3,"file":"useCompiledFragment.d.ts","sourceRoot":"","sources":["../../../src/storeObservation/compiledHooks/useCompiledFragment.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qDAAqD,CAAC;AAElG;;;;GAIG;AAEH,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,sBAAsB,EACjC,iBAAiB,EAAE,iBAAiB,GACnC,MAAM,CA2DR"}
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/storeObservation/compiledHooks/useCompiledFragment.ts"],
4
- "sourcesContent": ["import { useEffect, useMemo } from \"react\";\nimport invariant from \"invariant\";\nimport { useForceUpdate } from \"./useForceUpdate\";\nimport { useOverridenOrDefaultApolloClient } from \"../../useOverridenOrDefaultApolloClient\";\n\nimport type { FragmentReference } from \"./types\";\nimport type { CompiledArtefactModule } from \"@graphitation/apollo-react-relay-duct-tape-compiler\";\n\n/**\n * @param documents Compiled watch query document that is used to setup a narrow\n * observable for just the data selected by the original fragment.\n * @param fragmentReference A Node object that has a globally unique `id` field.\n */\n\nexport function useCompiledFragment(\n documents: CompiledArtefactModule,\n fragmentReference: FragmentReference,\n): {} {\n invariant(\n fragmentReference,\n \"useFragment(): Expected metadata to have been extracted from \" +\n \"the fragment. Did you forget to invoke the compiler?\",\n );\n const { watchQueryDocument, metadata } = documents;\n invariant(\n watchQueryDocument,\n \"useFragment(): Expected a `watchQueryDocument` to have been \" +\n \"extracted. Did you forget to invoke the compiler?\",\n );\n\n const client = useOverridenOrDefaultApolloClient();\n const forceUpdate = useForceUpdate();\n\n const observableQuery = useMemo(\n () =>\n client.watchQuery({\n fetchPolicy: \"cache-only\",\n query: watchQueryDocument,\n returnPartialData: false,\n variables: {\n id: fragmentReference.id,\n __fragments: fragmentReference.__fragments,\n ...fragmentReference.__fragments,\n },\n }),\n [client, fragmentReference.id, fragmentReference.__fragments],\n );\n\n useEffect(() => {\n let skipFirst = true;\n const subscription = observableQuery.subscribe(\n () => {\n // Unclear why, but this yields twice with the same results, so skip one.\n if (skipFirst) {\n skipFirst = false;\n } else {\n forceUpdate();\n }\n },\n (error) => {\n console.log(error);\n },\n );\n return () => subscription.unsubscribe();\n }, [observableQuery]);\n\n const result = observableQuery.getCurrentResult();\n let data = result.data;\n if (metadata?.rootSelection) {\n data = data[metadata.rootSelection];\n }\n invariant(\n data,\n \"useFragment(): Expected Apollo to respond with previously seeded data of the execution query document\",\n );\n return data;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAmC;AACnC,uBAAsB;AACtB,4BAA+B;AAC/B,+CAAkD;AAW3C,SAAS,oBACd,WACA,mBACI;AACJ,uBAAAA;AAAA,IACE;AAAA,IACA;AAAA,EAEF;AACA,QAAM,EAAE,oBAAoB,SAAS,IAAI;AACzC,uBAAAA;AAAA,IACE;AAAA,IACA;AAAA,EAEF;AAEA,QAAM,aAAS,4EAAkC;AACjD,QAAM,kBAAc,sCAAe;AAEnC,QAAM,sBAAkB;AAAA,IACtB,MACE,OAAO,WAAW;AAAA,MAChB,aAAa;AAAA,MACb,OAAO;AAAA,MACP,mBAAmB;AAAA,MACnB,WAAW;AAAA,QACT,IAAI,kBAAkB;AAAA,QACtB,aAAa,kBAAkB;AAAA,SAC5B,kBAAkB;AAAA,IAEzB,CAAC;AAAA,IACH,CAAC,QAAQ,kBAAkB,IAAI,kBAAkB,WAAW;AAAA,EAC9D;AAEA,8BAAU,MAAM;AACd,QAAI,YAAY;AAChB,UAAM,eAAe,gBAAgB;AAAA,MACnC,MAAM;AAEJ,YAAI,WAAW;AACb,sBAAY;AAAA,QACd,OAAO;AACL,sBAAY;AAAA,QACd;AAAA,MACF;AAAA,MACA,CAAC,UAAU;AACT,gBAAQ,IAAI,KAAK;AAAA,MACnB;AAAA,IACF;AACA,WAAO,MAAM,aAAa,YAAY;AAAA,EACxC,GAAG,CAAC,eAAe,CAAC;AAEpB,QAAM,SAAS,gBAAgB,iBAAiB;AAChD,MAAI,OAAO,OAAO;AAClB,MAAI,qCAAU,eAAe;AAC3B,WAAO,KAAK,SAAS,aAAa;AAAA,EACpC;AACA,uBAAAA;AAAA,IACE;AAAA,IACA;AAAA,EACF;AACA,SAAO;AACT;",
4
+ "sourcesContent": ["import { useEffect, useMemo } from \"react\";\nimport invariant from \"invariant\";\nimport { useForceUpdate } from \"./useForceUpdate\";\nimport { useOverridenOrDefaultApolloClient } from \"../../useOverridenOrDefaultApolloClient\";\n\nimport type { FragmentReference } from \"./types\";\nimport type { CompiledArtefactModule } from \"@graphitation/apollo-react-relay-duct-tape-compiler\";\n\n/**\n * @param documents Compiled watch query document that is used to setup a narrow\n * observable for just the data selected by the original fragment.\n * @param fragmentReference A Node object that has a globally unique `id` field.\n */\n\nexport function useCompiledFragment(\n documents: CompiledArtefactModule,\n fragmentReference: FragmentReference,\n): object {\n invariant(\n fragmentReference,\n \"useFragment(): Expected metadata to have been extracted from \" +\n \"the fragment. Did you forget to invoke the compiler?\",\n );\n const { watchQueryDocument, metadata } = documents;\n invariant(\n watchQueryDocument,\n \"useFragment(): Expected a `watchQueryDocument` to have been \" +\n \"extracted. Did you forget to invoke the compiler?\",\n );\n\n const client = useOverridenOrDefaultApolloClient();\n const forceUpdate = useForceUpdate();\n\n const observableQuery = useMemo(\n () =>\n client.watchQuery({\n fetchPolicy: \"cache-only\",\n query: watchQueryDocument,\n returnPartialData: false,\n variables: {\n id: fragmentReference.id,\n __fragments: fragmentReference.__fragments,\n ...fragmentReference.__fragments,\n },\n }),\n [client, fragmentReference.id, fragmentReference.__fragments],\n );\n\n useEffect(() => {\n let skipFirst = true;\n const subscription = observableQuery.subscribe(\n () => {\n // Unclear why, but this yields twice with the same results, so skip one.\n if (skipFirst) {\n skipFirst = false;\n } else {\n forceUpdate();\n }\n },\n (error) => {\n console.log(error);\n },\n );\n return () => subscription.unsubscribe();\n }, [observableQuery]);\n\n const result = observableQuery.getCurrentResult();\n let data = result.data;\n if (metadata?.rootSelection) {\n data = data[metadata.rootSelection];\n }\n invariant(\n data,\n \"useFragment(): Expected Apollo to respond with previously seeded data of the execution query document\",\n );\n return data;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAmC;AACnC,uBAAsB;AACtB,4BAA+B;AAC/B,+CAAkD;AAW3C,SAAS,oBACd,WACA,mBACQ;AACR,uBAAAA;AAAA,IACE;AAAA,IACA;AAAA,EAEF;AACA,QAAM,EAAE,oBAAoB,SAAS,IAAI;AACzC,uBAAAA;AAAA,IACE;AAAA,IACA;AAAA,EAEF;AAEA,QAAM,aAAS,4EAAkC;AACjD,QAAM,kBAAc,sCAAe;AAEnC,QAAM,sBAAkB;AAAA,IACtB,MACE,OAAO,WAAW;AAAA,MAChB,aAAa;AAAA,MACb,OAAO;AAAA,MACP,mBAAmB;AAAA,MACnB,WAAW;AAAA,QACT,IAAI,kBAAkB;AAAA,QACtB,aAAa,kBAAkB;AAAA,SAC5B,kBAAkB;AAAA,IAEzB,CAAC;AAAA,IACH,CAAC,QAAQ,kBAAkB,IAAI,kBAAkB,WAAW;AAAA,EAC9D;AAEA,8BAAU,MAAM;AACd,QAAI,YAAY;AAChB,UAAM,eAAe,gBAAgB;AAAA,MACnC,MAAM;AAEJ,YAAI,WAAW;AACb,sBAAY;AAAA,QACd,OAAO;AACL,sBAAY;AAAA,QACd;AAAA,MACF;AAAA,MACA,CAAC,UAAU;AACT,gBAAQ,IAAI,KAAK;AAAA,MACnB;AAAA,IACF;AACA,WAAO,MAAM,aAAa,YAAY;AAAA,EACxC,GAAG,CAAC,eAAe,CAAC;AAEpB,QAAM,SAAS,gBAAgB,iBAAiB;AAChD,MAAI,OAAO,OAAO;AAClB,MAAI,qCAAU,eAAe;AAC3B,WAAO,KAAK,SAAS,aAAa;AAAA,EACpC;AACA,uBAAAA;AAAA,IACE;AAAA,IACA;AAAA,EACF;AACA,SAAO;AACT;",
6
6
  "names": ["invariant"]
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/storeObservation/compiledHooks/useCompiledFragment.ts"],
4
- "sourcesContent": ["import { useEffect, useMemo } from \"react\";\nimport invariant from \"invariant\";\nimport { useForceUpdate } from \"./useForceUpdate\";\nimport { useOverridenOrDefaultApolloClient } from \"../../useOverridenOrDefaultApolloClient\";\n\nimport type { FragmentReference } from \"./types\";\nimport type { CompiledArtefactModule } from \"@graphitation/apollo-react-relay-duct-tape-compiler\";\n\n/**\n * @param documents Compiled watch query document that is used to setup a narrow\n * observable for just the data selected by the original fragment.\n * @param fragmentReference A Node object that has a globally unique `id` field.\n */\n\nexport function useCompiledFragment(\n documents: CompiledArtefactModule,\n fragmentReference: FragmentReference,\n): {} {\n invariant(\n fragmentReference,\n \"useFragment(): Expected metadata to have been extracted from \" +\n \"the fragment. Did you forget to invoke the compiler?\",\n );\n const { watchQueryDocument, metadata } = documents;\n invariant(\n watchQueryDocument,\n \"useFragment(): Expected a `watchQueryDocument` to have been \" +\n \"extracted. Did you forget to invoke the compiler?\",\n );\n\n const client = useOverridenOrDefaultApolloClient();\n const forceUpdate = useForceUpdate();\n\n const observableQuery = useMemo(\n () =>\n client.watchQuery({\n fetchPolicy: \"cache-only\",\n query: watchQueryDocument,\n returnPartialData: false,\n variables: {\n id: fragmentReference.id,\n __fragments: fragmentReference.__fragments,\n ...fragmentReference.__fragments,\n },\n }),\n [client, fragmentReference.id, fragmentReference.__fragments],\n );\n\n useEffect(() => {\n let skipFirst = true;\n const subscription = observableQuery.subscribe(\n () => {\n // Unclear why, but this yields twice with the same results, so skip one.\n if (skipFirst) {\n skipFirst = false;\n } else {\n forceUpdate();\n }\n },\n (error) => {\n console.log(error);\n },\n );\n return () => subscription.unsubscribe();\n }, [observableQuery]);\n\n const result = observableQuery.getCurrentResult();\n let data = result.data;\n if (metadata?.rootSelection) {\n data = data[metadata.rootSelection];\n }\n invariant(\n data,\n \"useFragment(): Expected Apollo to respond with previously seeded data of the execution query document\",\n );\n return data;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA,SAAS,WAAW,eAAe;AACnC,OAAO,eAAe;AACtB,SAAS,sBAAsB;AAC/B,SAAS,yCAAyC;AAW3C,SAAS,oBACd,WACA,mBACI;AACJ;AAAA,IACE;AAAA,IACA;AAAA,EAEF;AACA,QAAM,EAAE,oBAAoB,SAAS,IAAI;AACzC;AAAA,IACE;AAAA,IACA;AAAA,EAEF;AAEA,QAAM,SAAS,kCAAkC;AACjD,QAAM,cAAc,eAAe;AAEnC,QAAM,kBAAkB;AAAA,IACtB,MACE,OAAO,WAAW;AAAA,MAChB,aAAa;AAAA,MACb,OAAO;AAAA,MACP,mBAAmB;AAAA,MACnB,WAAW;AAAA,QACT,IAAI,kBAAkB;AAAA,QACtB,aAAa,kBAAkB;AAAA,SAC5B,kBAAkB;AAAA,IAEzB,CAAC;AAAA,IACH,CAAC,QAAQ,kBAAkB,IAAI,kBAAkB,WAAW;AAAA,EAC9D;AAEA,YAAU,MAAM;AACd,QAAI,YAAY;AAChB,UAAM,eAAe,gBAAgB;AAAA,MACnC,MAAM;AAEJ,YAAI,WAAW;AACb,sBAAY;AAAA,QACd,OAAO;AACL,sBAAY;AAAA,QACd;AAAA,MACF;AAAA,MACA,CAAC,UAAU;AACT,gBAAQ,IAAI,KAAK;AAAA,MACnB;AAAA,IACF;AACA,WAAO,MAAM,aAAa,YAAY;AAAA,EACxC,GAAG,CAAC,eAAe,CAAC;AAEpB,QAAM,SAAS,gBAAgB,iBAAiB;AAChD,MAAI,OAAO,OAAO;AAClB,MAAI,qCAAU,eAAe;AAC3B,WAAO,KAAK,SAAS,aAAa;AAAA,EACpC;AACA;AAAA,IACE;AAAA,IACA;AAAA,EACF;AACA,SAAO;AACT;",
4
+ "sourcesContent": ["import { useEffect, useMemo } from \"react\";\nimport invariant from \"invariant\";\nimport { useForceUpdate } from \"./useForceUpdate\";\nimport { useOverridenOrDefaultApolloClient } from \"../../useOverridenOrDefaultApolloClient\";\n\nimport type { FragmentReference } from \"./types\";\nimport type { CompiledArtefactModule } from \"@graphitation/apollo-react-relay-duct-tape-compiler\";\n\n/**\n * @param documents Compiled watch query document that is used to setup a narrow\n * observable for just the data selected by the original fragment.\n * @param fragmentReference A Node object that has a globally unique `id` field.\n */\n\nexport function useCompiledFragment(\n documents: CompiledArtefactModule,\n fragmentReference: FragmentReference,\n): object {\n invariant(\n fragmentReference,\n \"useFragment(): Expected metadata to have been extracted from \" +\n \"the fragment. Did you forget to invoke the compiler?\",\n );\n const { watchQueryDocument, metadata } = documents;\n invariant(\n watchQueryDocument,\n \"useFragment(): Expected a `watchQueryDocument` to have been \" +\n \"extracted. Did you forget to invoke the compiler?\",\n );\n\n const client = useOverridenOrDefaultApolloClient();\n const forceUpdate = useForceUpdate();\n\n const observableQuery = useMemo(\n () =>\n client.watchQuery({\n fetchPolicy: \"cache-only\",\n query: watchQueryDocument,\n returnPartialData: false,\n variables: {\n id: fragmentReference.id,\n __fragments: fragmentReference.__fragments,\n ...fragmentReference.__fragments,\n },\n }),\n [client, fragmentReference.id, fragmentReference.__fragments],\n );\n\n useEffect(() => {\n let skipFirst = true;\n const subscription = observableQuery.subscribe(\n () => {\n // Unclear why, but this yields twice with the same results, so skip one.\n if (skipFirst) {\n skipFirst = false;\n } else {\n forceUpdate();\n }\n },\n (error) => {\n console.log(error);\n },\n );\n return () => subscription.unsubscribe();\n }, [observableQuery]);\n\n const result = observableQuery.getCurrentResult();\n let data = result.data;\n if (metadata?.rootSelection) {\n data = data[metadata.rootSelection];\n }\n invariant(\n data,\n \"useFragment(): Expected Apollo to respond with previously seeded data of the execution query document\",\n );\n return data;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA,SAAS,WAAW,eAAe;AACnC,OAAO,eAAe;AACtB,SAAS,sBAAsB;AAC/B,SAAS,yCAAyC;AAW3C,SAAS,oBACd,WACA,mBACQ;AACR;AAAA,IACE;AAAA,IACA;AAAA,EAEF;AACA,QAAM,EAAE,oBAAoB,SAAS,IAAI;AACzC;AAAA,IACE;AAAA,IACA;AAAA,EAEF;AAEA,QAAM,SAAS,kCAAkC;AACjD,QAAM,cAAc,eAAe;AAEnC,QAAM,kBAAkB;AAAA,IACtB,MACE,OAAO,WAAW;AAAA,MAChB,aAAa;AAAA,MACb,OAAO;AAAA,MACP,mBAAmB;AAAA,MACnB,WAAW;AAAA,QACT,IAAI,kBAAkB;AAAA,QACtB,aAAa,kBAAkB;AAAA,SAC5B,kBAAkB;AAAA,IAEzB,CAAC;AAAA,IACH,CAAC,QAAQ,kBAAkB,IAAI,kBAAkB,WAAW;AAAA,EAC9D;AAEA,YAAU,MAAM;AACd,QAAI,YAAY;AAChB,UAAM,eAAe,gBAAgB;AAAA,MACnC,MAAM;AAEJ,YAAI,WAAW;AACb,sBAAY;AAAA,QACd,OAAO;AACL,sBAAY;AAAA,QACd;AAAA,MACF;AAAA,MACA,CAAC,UAAU;AACT,gBAAQ,IAAI,KAAK;AAAA,MACnB;AAAA,IACF;AACA,WAAO,MAAM,aAAa,YAAY;AAAA,EACxC,GAAG,CAAC,eAAe,CAAC;AAEpB,QAAM,SAAS,gBAAgB,iBAAiB;AAChD,MAAI,OAAO,OAAO;AAClB,MAAI,qCAAU,eAAe;AAC3B,WAAO,KAAK,SAAS,aAAa;AAAA,EACpC;AACA;AAAA,IACE;AAAA,IACA;AAAA,EACF;AACA,SAAO;AACT;",
6
6
  "names": []
7
7
  }
@@ -8,9 +8,9 @@ import type { CompiledArtefactModule } from "@graphitation/apollo-react-relay-du
8
8
  * @param options An object containing a variables field.
9
9
  */
10
10
  export declare function useCompiledLazyLoadQuery(documents: CompiledArtefactModule, options: {
11
- variables: Record<string, any>;
11
+ variables: Record<string, unknown>;
12
12
  }): {
13
- data?: any;
13
+ data?: Record<string, any>;
14
14
  error?: Error;
15
15
  };
16
16
  //# sourceMappingURL=useCompiledLazyLoadQuery.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useCompiledLazyLoadQuery.d.ts","sourceRoot":"","sources":["../../../src/storeObservation/compiledHooks/useCompiledLazyLoadQuery.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qDAAqD,CAAC;AAiElG;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CACtC,SAAS,EAAE,sBAAsB,EACjC,OAAO,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;CAAE,GAC1C;IAAE,IAAI,CAAC,EAAE,GAAG,CAAC;IAAC,KAAK,CAAC,EAAE,KAAK,CAAA;CAAE,CA8B/B"}
1
+ {"version":3,"file":"useCompiledLazyLoadQuery.d.ts","sourceRoot":"","sources":["../../../src/storeObservation/compiledHooks/useCompiledLazyLoadQuery.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qDAAqD,CAAC;AAiElG;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CACtC,SAAS,EAAE,sBAAsB,EACjC,OAAO,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,GAE9C;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAAC,KAAK,CAAC,EAAE,KAAK,CAAA;CAAE,CA8B/C"}
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/storeObservation/compiledHooks/useCompiledLazyLoadQuery.ts"],
4
- "sourcesContent": ["import { useRef, useEffect } from \"react\";\nimport { useQuery as useApolloQuery } from \"@apollo/client\";\nimport invariant from \"invariant\";\nimport { useDeepCompareMemoize } from \"./useDeepCompareMemoize\";\nimport { useForceUpdate } from \"./useForceUpdate\";\nimport { useOverridenOrDefaultApolloClient } from \"../../useOverridenOrDefaultApolloClient\";\n\nimport type { ObservableQuery, ApolloClient } from \"@apollo/client\";\nimport type { DocumentNode } from \"graphql\";\nimport type { CompiledArtefactModule } from \"@graphitation/apollo-react-relay-duct-tape-compiler\";\n\nclass ExecutionQueryHandler {\n public status: [loading: boolean, error?: Error];\n private querySubscription?: ZenObservable.Subscription;\n\n constructor(private onComplete: () => void) {\n this.status = [true, undefined];\n }\n\n public isIdle() {\n return this.status[0] && this.querySubscription === undefined;\n }\n\n public dispose() {\n this.querySubscription?.unsubscribe();\n this.querySubscription = undefined;\n }\n\n public reset() {\n this.dispose();\n this.status = [true, undefined];\n }\n\n private handleResult(error?: Error) {\n this.status = [false, error];\n this.dispose();\n this.onComplete();\n }\n\n public subscribe(observable: ObservableQuery) {\n this.querySubscription = observable.subscribe(\n ({ error: err }) => {\n this.handleResult(err);\n },\n (err) => {\n this.handleResult(err);\n },\n );\n }\n}\n\nfunction useExecutionQuery(\n client: ApolloClient<any>,\n executionQueryDocument: DocumentNode,\n variables: Record<string, any>,\n): [loading: boolean, error?: Error] {\n const forceUpdate = useForceUpdate();\n const execution = useRef(new ExecutionQueryHandler(() => forceUpdate()));\n useEffect(() => {\n if (execution.current.isIdle()) {\n execution.current.subscribe(\n client.watchQuery({\n query: executionQueryDocument,\n variables,\n }),\n );\n }\n return () => {\n execution.current.reset();\n };\n }, [executionQueryDocument, variables]);\n return execution.current.status;\n}\n\n/**\n * @todo Rewrite this to mimic Relay's preload APIs\n *\n * @param documents Compiled execute and watch query documents that are used to\n * setup a narrow observable for just the data selected by the\n * original fragment.\n * @param options An object containing a variables field.\n */\nexport function useCompiledLazyLoadQuery(\n documents: CompiledArtefactModule,\n options: { variables: Record<string, any> },\n): { data?: any; error?: Error } {\n const { watchQueryDocument } = documents;\n invariant(\n watchQueryDocument,\n \"useLazyLoadQuery(): Expected a `watchQueryDocument` to have been \" +\n \"extracted. Did you forget to invoke the compiler?\",\n );\n const { executionQueryDocument } = documents;\n invariant(\n executionQueryDocument,\n \"useLazyLoadQuery(): Expected a `executionQueryDocument` to have been \" +\n \"extracted. Did you forget to invoke the compiler?\",\n );\n const client = useOverridenOrDefaultApolloClient();\n const variables = useDeepCompareMemoize(options.variables);\n // First fetch all data needed for the entire tree...\n const [loading, error] = useExecutionQuery(\n client,\n executionQueryDocument,\n variables,\n );\n // ...then fetch/watch data for only the calling component...\n const { data } = useApolloQuery(watchQueryDocument, {\n client,\n variables,\n fetchPolicy: \"cache-only\",\n // ...but only once finished loading.\n skip: loading || !!error,\n });\n return { data, error };\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkC;AAClC,oBAA2C;AAC3C,uBAAsB;AACtB,mCAAsC;AACtC,4BAA+B;AAC/B,+CAAkD;AAMlD,MAAM,sBAAsB;AAAA,EAI1B,YAAoB,YAAwB;AAAxB;AAClB,SAAK,SAAS,CAAC,MAAM,MAAS;AAAA,EAChC;AAAA,EAEO,SAAS;AACd,WAAO,KAAK,OAAO,CAAC,KAAK,KAAK,sBAAsB;AAAA,EACtD;AAAA,EAEO,UAAU;AAvBnB;AAwBI,eAAK,sBAAL,mBAAwB;AACxB,SAAK,oBAAoB;AAAA,EAC3B;AAAA,EAEO,QAAQ;AACb,SAAK,QAAQ;AACb,SAAK,SAAS,CAAC,MAAM,MAAS;AAAA,EAChC;AAAA,EAEQ,aAAa,OAAe;AAClC,SAAK,SAAS,CAAC,OAAO,KAAK;AAC3B,SAAK,QAAQ;AACb,SAAK,WAAW;AAAA,EAClB;AAAA,EAEO,UAAU,YAA6B;AAC5C,SAAK,oBAAoB,WAAW;AAAA,MAClC,CAAC,EAAE,OAAO,IAAI,MAAM;AAClB,aAAK,aAAa,GAAG;AAAA,MACvB;AAAA,MACA,CAAC,QAAQ;AACP,aAAK,aAAa,GAAG;AAAA,MACvB;AAAA,IACF;AAAA,EACF;AACF;AAEA,SAAS,kBACP,QACA,wBACA,WACmC;AACnC,QAAM,kBAAc,sCAAe;AACnC,QAAM,gBAAY,qBAAO,IAAI,sBAAsB,MAAM,YAAY,CAAC,CAAC;AACvE,8BAAU,MAAM;AACd,QAAI,UAAU,QAAQ,OAAO,GAAG;AAC9B,gBAAU,QAAQ;AAAA,QAChB,OAAO,WAAW;AAAA,UAChB,OAAO;AAAA,UACP;AAAA,QACF,CAAC;AAAA,MACH;AAAA,IACF;AACA,WAAO,MAAM;AACX,gBAAU,QAAQ,MAAM;AAAA,IAC1B;AAAA,EACF,GAAG,CAAC,wBAAwB,SAAS,CAAC;AACtC,SAAO,UAAU,QAAQ;AAC3B;AAUO,SAAS,yBACd,WACA,SAC+B;AAC/B,QAAM,EAAE,mBAAmB,IAAI;AAC/B,uBAAAA;AAAA,IACE;AAAA,IACA;AAAA,EAEF;AACA,QAAM,EAAE,uBAAuB,IAAI;AACnC,uBAAAA;AAAA,IACE;AAAA,IACA;AAAA,EAEF;AACA,QAAM,aAAS,4EAAkC;AACjD,QAAM,gBAAY,oDAAsB,QAAQ,SAAS;AAEzD,QAAM,CAAC,SAAS,KAAK,IAAI;AAAA,IACvB;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,QAAM,EAAE,KAAK,QAAI,cAAAC,UAAe,oBAAoB;AAAA,IAClD;AAAA,IACA;AAAA,IACA,aAAa;AAAA;AAAA,IAEb,MAAM,WAAW,CAAC,CAAC;AAAA,EACrB,CAAC;AACD,SAAO,EAAE,MAAM,MAAM;AACvB;",
4
+ "sourcesContent": ["import { useRef, useEffect } from \"react\";\nimport { useQuery as useApolloQuery } from \"@apollo/client\";\nimport invariant from \"invariant\";\nimport { useDeepCompareMemoize } from \"./useDeepCompareMemoize\";\nimport { useForceUpdate } from \"./useForceUpdate\";\nimport { useOverridenOrDefaultApolloClient } from \"../../useOverridenOrDefaultApolloClient\";\n\nimport type { ObservableQuery, ApolloClient } from \"@apollo/client\";\nimport type { DocumentNode } from \"graphql\";\nimport type { CompiledArtefactModule } from \"@graphitation/apollo-react-relay-duct-tape-compiler\";\n\nclass ExecutionQueryHandler {\n public status: [loading: boolean, error?: Error];\n private querySubscription?: ZenObservable.Subscription;\n\n constructor(private onComplete: () => void) {\n this.status = [true, undefined];\n }\n\n public isIdle() {\n return this.status[0] && this.querySubscription === undefined;\n }\n\n public dispose() {\n this.querySubscription?.unsubscribe();\n this.querySubscription = undefined;\n }\n\n public reset() {\n this.dispose();\n this.status = [true, undefined];\n }\n\n private handleResult(error?: Error) {\n this.status = [false, error];\n this.dispose();\n this.onComplete();\n }\n\n public subscribe(observable: ObservableQuery) {\n this.querySubscription = observable.subscribe(\n ({ error: err }) => {\n this.handleResult(err);\n },\n (err) => {\n this.handleResult(err);\n },\n );\n }\n}\n\nfunction useExecutionQuery(\n client: ApolloClient<unknown>,\n executionQueryDocument: DocumentNode,\n variables: Record<string, unknown>,\n): [loading: boolean, error?: Error] {\n const forceUpdate = useForceUpdate();\n const execution = useRef(new ExecutionQueryHandler(() => forceUpdate()));\n useEffect(() => {\n if (execution.current.isIdle()) {\n execution.current.subscribe(\n client.watchQuery({\n query: executionQueryDocument,\n variables,\n }),\n );\n }\n return () => {\n execution.current.reset();\n };\n }, [executionQueryDocument, variables]);\n return execution.current.status;\n}\n\n/**\n * @todo Rewrite this to mimic Relay's preload APIs\n *\n * @param documents Compiled execute and watch query documents that are used to\n * setup a narrow observable for just the data selected by the\n * original fragment.\n * @param options An object containing a variables field.\n */\nexport function useCompiledLazyLoadQuery(\n documents: CompiledArtefactModule,\n options: { variables: Record<string, unknown> },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): { data?: Record<string, any>; error?: Error } {\n const { watchQueryDocument } = documents;\n invariant(\n watchQueryDocument,\n \"useLazyLoadQuery(): Expected a `watchQueryDocument` to have been \" +\n \"extracted. Did you forget to invoke the compiler?\",\n );\n const { executionQueryDocument } = documents;\n invariant(\n executionQueryDocument,\n \"useLazyLoadQuery(): Expected a `executionQueryDocument` to have been \" +\n \"extracted. Did you forget to invoke the compiler?\",\n );\n const client = useOverridenOrDefaultApolloClient();\n const variables = useDeepCompareMemoize(options.variables);\n // First fetch all data needed for the entire tree...\n const [loading, error] = useExecutionQuery(\n client,\n executionQueryDocument,\n variables,\n );\n // ...then fetch/watch data for only the calling component...\n const { data } = useApolloQuery(watchQueryDocument, {\n client,\n variables,\n fetchPolicy: \"cache-only\",\n // ...but only once finished loading.\n skip: loading || !!error,\n });\n return { data, error };\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkC;AAClC,oBAA2C;AAC3C,uBAAsB;AACtB,mCAAsC;AACtC,4BAA+B;AAC/B,+CAAkD;AAMlD,MAAM,sBAAsB;AAAA,EAI1B,YAAoB,YAAwB;AAAxB;AAClB,SAAK,SAAS,CAAC,MAAM,MAAS;AAAA,EAChC;AAAA,EAEO,SAAS;AACd,WAAO,KAAK,OAAO,CAAC,KAAK,KAAK,sBAAsB;AAAA,EACtD;AAAA,EAEO,UAAU;AAvBnB;AAwBI,eAAK,sBAAL,mBAAwB;AACxB,SAAK,oBAAoB;AAAA,EAC3B;AAAA,EAEO,QAAQ;AACb,SAAK,QAAQ;AACb,SAAK,SAAS,CAAC,MAAM,MAAS;AAAA,EAChC;AAAA,EAEQ,aAAa,OAAe;AAClC,SAAK,SAAS,CAAC,OAAO,KAAK;AAC3B,SAAK,QAAQ;AACb,SAAK,WAAW;AAAA,EAClB;AAAA,EAEO,UAAU,YAA6B;AAC5C,SAAK,oBAAoB,WAAW;AAAA,MAClC,CAAC,EAAE,OAAO,IAAI,MAAM;AAClB,aAAK,aAAa,GAAG;AAAA,MACvB;AAAA,MACA,CAAC,QAAQ;AACP,aAAK,aAAa,GAAG;AAAA,MACvB;AAAA,IACF;AAAA,EACF;AACF;AAEA,SAAS,kBACP,QACA,wBACA,WACmC;AACnC,QAAM,kBAAc,sCAAe;AACnC,QAAM,gBAAY,qBAAO,IAAI,sBAAsB,MAAM,YAAY,CAAC,CAAC;AACvE,8BAAU,MAAM;AACd,QAAI,UAAU,QAAQ,OAAO,GAAG;AAC9B,gBAAU,QAAQ;AAAA,QAChB,OAAO,WAAW;AAAA,UAChB,OAAO;AAAA,UACP;AAAA,QACF,CAAC;AAAA,MACH;AAAA,IACF;AACA,WAAO,MAAM;AACX,gBAAU,QAAQ,MAAM;AAAA,IAC1B;AAAA,EACF,GAAG,CAAC,wBAAwB,SAAS,CAAC;AACtC,SAAO,UAAU,QAAQ;AAC3B;AAUO,SAAS,yBACd,WACA,SAE+C;AAC/C,QAAM,EAAE,mBAAmB,IAAI;AAC/B,uBAAAA;AAAA,IACE;AAAA,IACA;AAAA,EAEF;AACA,QAAM,EAAE,uBAAuB,IAAI;AACnC,uBAAAA;AAAA,IACE;AAAA,IACA;AAAA,EAEF;AACA,QAAM,aAAS,4EAAkC;AACjD,QAAM,gBAAY,oDAAsB,QAAQ,SAAS;AAEzD,QAAM,CAAC,SAAS,KAAK,IAAI;AAAA,IACvB;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,QAAM,EAAE,KAAK,QAAI,cAAAC,UAAe,oBAAoB;AAAA,IAClD;AAAA,IACA;AAAA,IACA,aAAa;AAAA;AAAA,IAEb,MAAM,WAAW,CAAC,CAAC;AAAA,EACrB,CAAC;AACD,SAAO,EAAE,MAAM,MAAM;AACvB;",
6
6
  "names": ["invariant", "useApolloQuery"]
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/storeObservation/compiledHooks/useCompiledLazyLoadQuery.ts"],
4
- "sourcesContent": ["import { useRef, useEffect } from \"react\";\nimport { useQuery as useApolloQuery } from \"@apollo/client\";\nimport invariant from \"invariant\";\nimport { useDeepCompareMemoize } from \"./useDeepCompareMemoize\";\nimport { useForceUpdate } from \"./useForceUpdate\";\nimport { useOverridenOrDefaultApolloClient } from \"../../useOverridenOrDefaultApolloClient\";\n\nimport type { ObservableQuery, ApolloClient } from \"@apollo/client\";\nimport type { DocumentNode } from \"graphql\";\nimport type { CompiledArtefactModule } from \"@graphitation/apollo-react-relay-duct-tape-compiler\";\n\nclass ExecutionQueryHandler {\n public status: [loading: boolean, error?: Error];\n private querySubscription?: ZenObservable.Subscription;\n\n constructor(private onComplete: () => void) {\n this.status = [true, undefined];\n }\n\n public isIdle() {\n return this.status[0] && this.querySubscription === undefined;\n }\n\n public dispose() {\n this.querySubscription?.unsubscribe();\n this.querySubscription = undefined;\n }\n\n public reset() {\n this.dispose();\n this.status = [true, undefined];\n }\n\n private handleResult(error?: Error) {\n this.status = [false, error];\n this.dispose();\n this.onComplete();\n }\n\n public subscribe(observable: ObservableQuery) {\n this.querySubscription = observable.subscribe(\n ({ error: err }) => {\n this.handleResult(err);\n },\n (err) => {\n this.handleResult(err);\n },\n );\n }\n}\n\nfunction useExecutionQuery(\n client: ApolloClient<any>,\n executionQueryDocument: DocumentNode,\n variables: Record<string, any>,\n): [loading: boolean, error?: Error] {\n const forceUpdate = useForceUpdate();\n const execution = useRef(new ExecutionQueryHandler(() => forceUpdate()));\n useEffect(() => {\n if (execution.current.isIdle()) {\n execution.current.subscribe(\n client.watchQuery({\n query: executionQueryDocument,\n variables,\n }),\n );\n }\n return () => {\n execution.current.reset();\n };\n }, [executionQueryDocument, variables]);\n return execution.current.status;\n}\n\n/**\n * @todo Rewrite this to mimic Relay's preload APIs\n *\n * @param documents Compiled execute and watch query documents that are used to\n * setup a narrow observable for just the data selected by the\n * original fragment.\n * @param options An object containing a variables field.\n */\nexport function useCompiledLazyLoadQuery(\n documents: CompiledArtefactModule,\n options: { variables: Record<string, any> },\n): { data?: any; error?: Error } {\n const { watchQueryDocument } = documents;\n invariant(\n watchQueryDocument,\n \"useLazyLoadQuery(): Expected a `watchQueryDocument` to have been \" +\n \"extracted. Did you forget to invoke the compiler?\",\n );\n const { executionQueryDocument } = documents;\n invariant(\n executionQueryDocument,\n \"useLazyLoadQuery(): Expected a `executionQueryDocument` to have been \" +\n \"extracted. Did you forget to invoke the compiler?\",\n );\n const client = useOverridenOrDefaultApolloClient();\n const variables = useDeepCompareMemoize(options.variables);\n // First fetch all data needed for the entire tree...\n const [loading, error] = useExecutionQuery(\n client,\n executionQueryDocument,\n variables,\n );\n // ...then fetch/watch data for only the calling component...\n const { data } = useApolloQuery(watchQueryDocument, {\n client,\n variables,\n fetchPolicy: \"cache-only\",\n // ...but only once finished loading.\n skip: loading || !!error,\n });\n return { data, error };\n}\n"],
5
- "mappings": ";AAAA,SAAS,QAAQ,iBAAiB;AAClC,SAAS,YAAY,sBAAsB;AAC3C,OAAO,eAAe;AACtB,SAAS,6BAA6B;AACtC,SAAS,sBAAsB;AAC/B,SAAS,yCAAyC;AAMlD,IAAM,wBAAN,MAA4B;AAAA,EAI1B,YAAoB,YAAwB;AAAxB;AAClB,SAAK,SAAS,CAAC,MAAM,MAAS;AAAA,EAChC;AAAA,EAEO,SAAS;AACd,WAAO,KAAK,OAAO,CAAC,KAAK,KAAK,sBAAsB;AAAA,EACtD;AAAA,EAEO,UAAU;AAvBnB;AAwBI,eAAK,sBAAL,mBAAwB;AACxB,SAAK,oBAAoB;AAAA,EAC3B;AAAA,EAEO,QAAQ;AACb,SAAK,QAAQ;AACb,SAAK,SAAS,CAAC,MAAM,MAAS;AAAA,EAChC;AAAA,EAEQ,aAAa,OAAe;AAClC,SAAK,SAAS,CAAC,OAAO,KAAK;AAC3B,SAAK,QAAQ;AACb,SAAK,WAAW;AAAA,EAClB;AAAA,EAEO,UAAU,YAA6B;AAC5C,SAAK,oBAAoB,WAAW;AAAA,MAClC,CAAC,EAAE,OAAO,IAAI,MAAM;AAClB,aAAK,aAAa,GAAG;AAAA,MACvB;AAAA,MACA,CAAC,QAAQ;AACP,aAAK,aAAa,GAAG;AAAA,MACvB;AAAA,IACF;AAAA,EACF;AACF;AAEA,SAAS,kBACP,QACA,wBACA,WACmC;AACnC,QAAM,cAAc,eAAe;AACnC,QAAM,YAAY,OAAO,IAAI,sBAAsB,MAAM,YAAY,CAAC,CAAC;AACvE,YAAU,MAAM;AACd,QAAI,UAAU,QAAQ,OAAO,GAAG;AAC9B,gBAAU,QAAQ;AAAA,QAChB,OAAO,WAAW;AAAA,UAChB,OAAO;AAAA,UACP;AAAA,QACF,CAAC;AAAA,MACH;AAAA,IACF;AACA,WAAO,MAAM;AACX,gBAAU,QAAQ,MAAM;AAAA,IAC1B;AAAA,EACF,GAAG,CAAC,wBAAwB,SAAS,CAAC;AACtC,SAAO,UAAU,QAAQ;AAC3B;AAUO,SAAS,yBACd,WACA,SAC+B;AAC/B,QAAM,EAAE,mBAAmB,IAAI;AAC/B;AAAA,IACE;AAAA,IACA;AAAA,EAEF;AACA,QAAM,EAAE,uBAAuB,IAAI;AACnC;AAAA,IACE;AAAA,IACA;AAAA,EAEF;AACA,QAAM,SAAS,kCAAkC;AACjD,QAAM,YAAY,sBAAsB,QAAQ,SAAS;AAEzD,QAAM,CAAC,SAAS,KAAK,IAAI;AAAA,IACvB;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,QAAM,EAAE,KAAK,IAAI,eAAe,oBAAoB;AAAA,IAClD;AAAA,IACA;AAAA,IACA,aAAa;AAAA;AAAA,IAEb,MAAM,WAAW,CAAC,CAAC;AAAA,EACrB,CAAC;AACD,SAAO,EAAE,MAAM,MAAM;AACvB;",
4
+ "sourcesContent": ["import { useRef, useEffect } from \"react\";\nimport { useQuery as useApolloQuery } from \"@apollo/client\";\nimport invariant from \"invariant\";\nimport { useDeepCompareMemoize } from \"./useDeepCompareMemoize\";\nimport { useForceUpdate } from \"./useForceUpdate\";\nimport { useOverridenOrDefaultApolloClient } from \"../../useOverridenOrDefaultApolloClient\";\n\nimport type { ObservableQuery, ApolloClient } from \"@apollo/client\";\nimport type { DocumentNode } from \"graphql\";\nimport type { CompiledArtefactModule } from \"@graphitation/apollo-react-relay-duct-tape-compiler\";\n\nclass ExecutionQueryHandler {\n public status: [loading: boolean, error?: Error];\n private querySubscription?: ZenObservable.Subscription;\n\n constructor(private onComplete: () => void) {\n this.status = [true, undefined];\n }\n\n public isIdle() {\n return this.status[0] && this.querySubscription === undefined;\n }\n\n public dispose() {\n this.querySubscription?.unsubscribe();\n this.querySubscription = undefined;\n }\n\n public reset() {\n this.dispose();\n this.status = [true, undefined];\n }\n\n private handleResult(error?: Error) {\n this.status = [false, error];\n this.dispose();\n this.onComplete();\n }\n\n public subscribe(observable: ObservableQuery) {\n this.querySubscription = observable.subscribe(\n ({ error: err }) => {\n this.handleResult(err);\n },\n (err) => {\n this.handleResult(err);\n },\n );\n }\n}\n\nfunction useExecutionQuery(\n client: ApolloClient<unknown>,\n executionQueryDocument: DocumentNode,\n variables: Record<string, unknown>,\n): [loading: boolean, error?: Error] {\n const forceUpdate = useForceUpdate();\n const execution = useRef(new ExecutionQueryHandler(() => forceUpdate()));\n useEffect(() => {\n if (execution.current.isIdle()) {\n execution.current.subscribe(\n client.watchQuery({\n query: executionQueryDocument,\n variables,\n }),\n );\n }\n return () => {\n execution.current.reset();\n };\n }, [executionQueryDocument, variables]);\n return execution.current.status;\n}\n\n/**\n * @todo Rewrite this to mimic Relay's preload APIs\n *\n * @param documents Compiled execute and watch query documents that are used to\n * setup a narrow observable for just the data selected by the\n * original fragment.\n * @param options An object containing a variables field.\n */\nexport function useCompiledLazyLoadQuery(\n documents: CompiledArtefactModule,\n options: { variables: Record<string, unknown> },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): { data?: Record<string, any>; error?: Error } {\n const { watchQueryDocument } = documents;\n invariant(\n watchQueryDocument,\n \"useLazyLoadQuery(): Expected a `watchQueryDocument` to have been \" +\n \"extracted. Did you forget to invoke the compiler?\",\n );\n const { executionQueryDocument } = documents;\n invariant(\n executionQueryDocument,\n \"useLazyLoadQuery(): Expected a `executionQueryDocument` to have been \" +\n \"extracted. Did you forget to invoke the compiler?\",\n );\n const client = useOverridenOrDefaultApolloClient();\n const variables = useDeepCompareMemoize(options.variables);\n // First fetch all data needed for the entire tree...\n const [loading, error] = useExecutionQuery(\n client,\n executionQueryDocument,\n variables,\n );\n // ...then fetch/watch data for only the calling component...\n const { data } = useApolloQuery(watchQueryDocument, {\n client,\n variables,\n fetchPolicy: \"cache-only\",\n // ...but only once finished loading.\n skip: loading || !!error,\n });\n return { data, error };\n}\n"],
5
+ "mappings": ";AAAA,SA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AC3B;AAUO,SAAS,yBACd,WACA,SAE+C;AAC/C,QAAM,EAAE,mBAAmB,IAAI;AAC/B;AAAA,IACE;AAAA,IACA;AAAA,EAEF;AACA,QAAM,EAAE,uBAAuB,IAAI;AACnC;AAAA,IACE;AAAA,IACA;AAAA,EAEF;AACA,QAAM,SAAS,kCAAkC;AACjD,QAAM,YAAY,sBAAsB,QAAQ,SAAS;AAEzD,QAAM,CAAC,SAAS,KAAK,IAAI;AAAA,IACvB;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,QAAM,EAAE,KAAK,IAAI,eAAe,oBAAoB;AAAA,IAClD;AAAA,IACA;AAAA,IACA,aAAa;AAAA;AAAA,IAEb,MAAM,WAAW,CAAC,CAAC;AAAA,EACrB,CAAC;AACD,SAAO,EAAE,MAAM,MAAM;AACvB;",
6
6
  "names": []
7
7
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useCompiledPaginationFragment.d.ts","sourceRoot":"","sources":["../../../src/storeObservation/compiledHooks/useCompiledPaginationFragment.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,KAAK,EACV,SAAS,EACT,UAAU,EAEV,cAAc,EACf,MAAM,kCAAkC,CAAC;AAC1C,OAAO,KAAK,EACV,sBAAsB,EAEvB,MAAM,qDAAqD,CAAC;AAG7D,oBAAY,YAAY,GAAG,CACzB,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,cAAc,KACrB,UAAU,CAAC;AAsLhB,wBAAgB,6BAA6B,CAC3C,SAAS,EAAE,sBAAsB,EACjC,iBAAiB,EAAE,iBAAiB,GACnC;IACD,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"}
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,oBAAY,YAAY,GAAG,CACzB,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,cAAc,KACrB,UAAU,CAAC;AA0LhB,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"}
@@ -64,7 +64,6 @@ function useLoadMore({
64
64
  cursorValue,
65
65
  updater
66
66
  }) {
67
- const apolloClient = (0, import_useOverridenOrDefaultApolloClient.useOverridenOrDefaultApolloClient)();
68
67
  const [isLoadingMore, setIsLoadingMore] = (0, import_react.useState)(false);
69
68
  const loadPage = (0, import_react.useCallback)(
70
69
  (countValue, options) => {
@@ -120,6 +119,7 @@ function useLoadMore({
120
119
  }
121
120
  };
122
121
  const existingData = cache.readFragment(cacheSelector);
122
+ (0, import_invariant.default)(existingData, "Expected existing data");
123
123
  const newCacheData = mergeEdges(
124
124
  connectionSelectionPath,
125
125
  newData,
@@ -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, StoreValue } 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 apolloClient = useOverridenOrDefaultApolloClient();\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<any, any> = {\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 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 data: Record<string, any>,\n selectionPath: string[],\n): 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 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: {},\n source: {},\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 data: any;\n loadNext: PaginationFn;\n loadPrevious: PaginationFn;\n hasNext: boolean;\n hasPrevious: boolean;\n isLoadingNext: boolean;\n isLoadingPrevious: boolean;\n refetch: RefetchFn;\n} {\n const { executionQueryDocument, metadata } = documents;\n invariant(\n metadata && metadata.mainFragment,\n \"usePaginationFragment(): Expected metadata to have been extracted from \" +\n \"the fragment. Did you forget to invoke the compiler?\",\n );\n invariant(\n executionQueryDocument,\n \"usePaginationFragment(): Expected fragment `%s` to be refetchable when \" +\n \"using `usePaginationFragment`. Did you forget to add a @refetchable \" +\n \"directive to the fragment?\",\n metadata.mainFragment.name,\n );\n const connectionMetadata = metadata.connection;\n invariant(\n connectionMetadata,\n \"usePaginationFragment: Expected fragment `%s` to include a \" +\n \"connection when using `usePaginationFragment`. Did you forget to add a @connection \" +\n \"directive to the connection field in the fragment?\",\n metadata.mainFragment.name,\n );\n const [data, refetch] = useCompiledRefetchableFragment(\n documents,\n fragmentReference,\n );\n const commonPaginationParams = {\n fragmentReference,\n refetch,\n metadata,\n executionQueryDocument,\n cache: useOverridenOrDefaultApolloClient().cache,\n connectionSelectionPath: connectionMetadata.selectionPath,\n };\n const pageInfo = getPageInfo(data, connectionMetadata.selectionPath);\n const [loadNext, isLoadingNext] = useLoadMore({\n ...commonPaginationParams,\n countVariable: connectionMetadata.forwardCountVariable,\n cursorVariable: connectionMetadata.forwardCursorVariable,\n cursorValue: pageInfo?.endCursor,\n updater: (existing, incoming) => [...existing, ...incoming],\n });\n const [loadPrevious, isLoadingPrevious] = useLoadMore({\n ...commonPaginationParams,\n countVariable: connectionMetadata.backwardCountVariable,\n cursorVariable: connectionMetadata.backwardCursorVariable,\n cursorValue: pageInfo?.startCursor,\n updater: (existing, incoming) => [...incoming, ...existing],\n });\n return {\n data,\n refetch,\n hasNext: !!pageInfo?.hasNextPage,\n hasPrevious: !!pageInfo?.hasPreviousPage,\n isLoadingNext,\n isLoadingPrevious,\n loadNext,\n loadPrevious,\n };\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,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,mBAAe,4EAAkC;AACvD,QAAM,CAAC,eAAe,gBAAgB,QAAI,uBAAS,KAAK;AACxD,QAAM,eAAW;AAAA,IACf,CAAC,YAAY,YAAY;AApD7B;AAqDM,2BAAAA;AAAA,QACE;AAAA,QACA;AAAA,MACF;AACA,2BAAAA;AAAA,QACE;AAAA,QACA;AAAA,MACF;AACA,2BAAAA;AAAA,QACE;AA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AA,IACA,WAAO,4EAAkC,EAAE;AAAA,IAC3C,yBAAyB,mBAAmB;AAAA,EAC9C;AACA,QAAM,WAAW,YAAY,MAAM,mBAAmB,aAAa;AACnE,QAAM,CAAC,UAAU,aAAa,IAAI,YAAY,iCACzC,yBADyC;AAAA,IAE5C,eAAe,mBAAmB;AAAA,IAClC,gBAAgB,mBAAmB;AAAA,IACnC,aAAa,qCAAU;AAAA,IACvB,SAAS,CAAC,UAAU,aAAa,CAAC,GAAG,UAAU,GAAG,QAAQ;AAAA,EAC5D,EAAC;AACD,QAAM,CAAC,cAAc,iBAAiB,IAAI,YAAY,iCACjD,yBADiD;AAAA,IAEpD,eAAe,mBAAmB;AAAA,IAClC,gBAAgB,mBAAmB;AAAA,IACnC,aAAa,qCAAU;AAAA,IACvB,SAAS,CAAC,UAAU,aAAa,CAAC,GAAG,UAAU,GAAG,QAAQ;AAAA,EAC5D,EAAC;AACD,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,SAAS,CAAC,EAAC,qCAAU;AAAA,IACrB,aAAa,CAAC,EAAC,qCAAU;AAAA,IACzB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;",
4
+ "sourcesContent": ["import { useState, useCallback } from \"react\";\nimport { ApolloCache, DataProxy, StoreValue } 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 id: cache.identify({\n __typename: mainFragment.typeCondition,\n id: fragmentReference.id as StoreValue,\n }),\n variables: previousVariables,\n fragmentName: mainFragment.name,\n // Create new document with operation filtered out.\n fragment: {\n kind: \"Document\",\n definitions: executionQueryDocument.definitions.filter(\n (def) => def.kind === \"FragmentDefinition\",\n ),\n },\n };\n /**\n * Note: Even though we already have the latest data from the\n * useCompiledFragment hook, we can't really use that as it may contain\n * __fragments fields and we don't want to write those to the cache. If\n * we figure out a way from a field-policy's merge function to not write\n * to the cache, then that would be preferable.\n */\n const existingData = cache.readFragment(cacheSelector);\n invariant(existingData, \"Expected existing data\");\n const newCacheData = mergeEdges(\n connectionSelectionPath,\n newData,\n existingData,\n updater,\n );\n cache.writeFragment({\n ...cacheSelector,\n variables: newVariables,\n data: newCacheData,\n });\n }\n\n options?.onCompleted?.(error);\n },\n };\n // TODO: Measure if invoking `refetch` leads to React updates and if it\n // makes sense to wrap it and the following setIsLoadingMore(true)\n // call in a batchedUpdates callback.\n const disposable = refetch(\n newVariables,\n refetchOptions as RefetchOptions,\n );\n setIsLoadingMore(true);\n return disposable;\n },\n [\n fragmentReference.id,\n fragmentReference.__fragments,\n refetch,\n metadata,\n executionQueryDocument,\n cache,\n countVariable,\n cursorVariable,\n connectionSelectionPath,\n cursorValue,\n ],\n );\n return [loadPage, isLoadingMore];\n}\n\nfunction getValueAtSelectionPath(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n data: Record<string, any>,\n selectionPath: string[],\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): any {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let object: Record<string, any> = data;\n selectionPath.forEach((field) => {\n object = object[field];\n invariant(object, \"Expected path to connection in response to exist\");\n });\n return object;\n}\n\nfunction getPageInfo(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n data: Record<string, any>,\n selectionPath: string[],\n): {\n startCursor?: string;\n endCursor?: string;\n hasPreviousPage?: boolean;\n hasNextPage?: boolean;\n} {\n const object = getValueAtSelectionPath(data, selectionPath);\n const pageInfo = object.pageInfo;\n invariant(pageInfo, \"Expected to find the connection's page info object\");\n return pageInfo;\n}\n\nfunction mergeEdges(\n connectionPath: string[],\n destination: object,\n source: object,\n updater: <T>(existing: T[], incoming: T[]) => T[],\n) {\n const edgesPath = [...connectionPath, \"edges\"];\n const existingEdges = getValueAtSelectionPath(source, edgesPath);\n const newEdges = getValueAtSelectionPath(destination, edgesPath);\n const allEdges = updater(existingEdges, newEdges);\n\n const connection = getValueAtSelectionPath(destination, connectionPath);\n connection[\"edges\"] = allEdges;\n\n return destination;\n}\n\nexport function useCompiledPaginationFragment(\n documents: CompiledArtefactModule,\n fragmentReference: FragmentReference,\n): {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n data: any;\n loadNext: PaginationFn;\n loadPrevious: PaginationFn;\n hasNext: boolean;\n hasPrevious: boolean;\n isLoadingNext: boolean;\n isLoadingPrevious: boolean;\n refetch: RefetchFn;\n} {\n const { executionQueryDocument, metadata } = documents;\n invariant(\n metadata && metadata.mainFragment,\n \"usePaginationFragment(): Expected metadata to have been extracted from \" +\n \"the fragment. Did you forget to invoke the compiler?\",\n );\n invariant(\n executionQueryDocument,\n \"usePaginationFragment(): Expected fragment `%s` to be refetchable when \" +\n \"using `usePaginationFragment`. Did you forget to add a @refetchable \" +\n \"directive to the fragment?\",\n metadata.mainFragment.name,\n );\n const connectionMetadata = metadata.connection;\n invariant(\n connectionMetadata,\n \"usePaginationFragment: Expected fragment `%s` to include a \" +\n \"connection when using `usePaginationFragment`. Did you forget to add a @connection \" +\n \"directive to the connection field in the fragment?\",\n metadata.mainFragment.name,\n );\n const [data, refetch] = useCompiledRefetchableFragment(\n documents,\n fragmentReference,\n );\n const commonPaginationParams = {\n fragmentReference,\n refetch,\n metadata,\n executionQueryDocument,\n cache: useOverridenOrDefaultApolloClient().cache,\n connectionSelectionPath: connectionMetadata.selectionPath,\n };\n const pageInfo = getPageInfo(data, connectionMetadata.selectionPath);\n const [loadNext, isLoadingNext] = useLoadMore({\n ...commonPaginationParams,\n countVariable: connectionMetadata.forwardCountVariable,\n cursorVariable: connectionMetadata.forwardCursorVariable,\n cursorValue: pageInfo?.endCursor,\n updater: (existing, incoming) => [...existing, ...incoming],\n });\n const [loadPrevious, isLoadingPrevious] = useLoadMore({\n ...commonPaginationParams,\n countVariable: connectionMetadata.backwardCountVariable,\n cursorVariable: connectionMetadata.backwardCursorVariable,\n cursorValue: pageInfo?.startCursor,\n updater: (existing, incoming) => [...incoming, ...existing],\n });\n return {\n data,\n refetch,\n hasNext: !!pageInfo?.hasNextPage,\n hasPrevious: !!pageInfo?.hasPreviousPage,\n isLoadingNext,\n isLoadingPrevious,\n loadNext,\n loadPrevious,\n };\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,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;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,YAAY,iCACjD,yBADiD;AAAA,IAEpD,eAAe,mBAAmB;AAAA,IAClC,gBAAgB,mBAAmB;AAAA,IACnC,aAAa,qCAAU;AAAA,IACvB,SAAS,CAAC,UAAU,aAAa,CAAC,GAAG,UAAU,GAAG,QAAQ;AAAA,EAC5D,EAAC;AACD,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,SAAS,CAAC,EAAC,qCAAU;AAAA,IACrB,aAAa,CAAC,EAAC,qCAAU;AAAA,IACzB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;",
6
6
  "names": ["invariant", "_a"]
7
7
  }
@@ -35,7 +35,6 @@ function useLoadMore({
35
35
  cursorValue,
36
36
  updater
37
37
  }) {
38
- const apolloClient = useOverridenOrDefaultApolloClient();
39
38
  const [isLoadingMore, setIsLoadingMore] = useState(false);
40
39
  const loadPage = useCallback(
41
40
  (countValue, options) => {
@@ -91,6 +90,7 @@ function useLoadMore({
91
90
  }
92
91
  };
93
92
  const existingData = cache.readFragment(cacheSelector);
93
+ invariant(existingData, "Expected existing data");
94
94
  const newCacheData = mergeEdges(
95
95
  connectionSelectionPath,
96
96
  newData,