@graphitation/apollo-react-relay-duct-tape 1.0.1-alpha.5 → 1.0.1-alpha.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintcache +1 -1
- package/CHANGELOG.md +10 -2
- package/lib/storeObservation/compiledHooks/useCompiledLazyLoadQuery.d.ts.map +1 -1
- package/lib/storeObservation/compiledHooks/useCompiledLazyLoadQuery.js +4 -3
- package/lib/storeObservation/compiledHooks/useCompiledLazyLoadQuery.js.map +2 -2
- package/lib/storeObservation/compiledHooks/useCompiledLazyLoadQuery.mjs +7 -4
- package/lib/storeObservation/compiledHooks/useCompiledLazyLoadQuery.mjs.map +2 -2
- package/lib/storeObservation/compiledHooks.test.js +5 -4
- package/lib/storeObservation/compiledHooks.test.js.map +2 -2
- package/lib/storeObservation/compiledHooks.test.mjs +6 -8
- package/lib/storeObservation/compiledHooks.test.mjs.map +2 -2
- package/lib/useOverridenOrDefaultApolloClient.d.ts.map +1 -1
- package/lib/useOverridenOrDefaultApolloClient.js +2 -0
- package/lib/useOverridenOrDefaultApolloClient.js.map +2 -2
- package/lib/useOverridenOrDefaultApolloClient.mjs +2 -0
- package/lib/useOverridenOrDefaultApolloClient.mjs.map +2 -2
- package/package.json +1 -1
package/.eslintcache
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
[{"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/__tests__/__generated__/hooksTestFragment.graphql.ts":"1","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/__tests__/__generated__/hooksTestMutation.graphql.ts":"2","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/__tests__/__generated__/hooksTestQuery.graphql.ts":"3","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/__tests__/__generated__/hooksTestSubscription.graphql.ts":"4","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/__tests__/__generated__/hooksTestWatchNodeQuery.graphql.ts":"5","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/__tests__/hooks.test.tsx":"6","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/__tests__/useOverridenOrDefaultApolloClient.test.tsx":"7","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/convertFetchPolicy.ts":"8","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/hooks.ts":"9","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/index.ts":"10","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/__generated__/compiledHooks_BackwardPaginationFragment.graphql.ts":"11","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/__generated__/compiledHooks_BackwardPaginationFragment_PaginationQuery.graphql.ts":"12","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/__generated__/compiledHooks_ChildFragment.graphql.ts":"13","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/__generated__/compiledHooks_ChildWatchNodeQuery.graphql.ts":"14","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/__generated__/compiledHooks_ForwardPaginationFragment.graphql.ts":"15","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/__generated__/compiledHooks_ForwardPaginationFragment_PaginationQuery.graphql.ts":"16","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/__generated__/compiledHooks_QueryTypeFragment.graphql.ts":"17","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/__generated__/compiledHooks_QueryTypeWatchNodeQuery.graphql.ts":"18","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/__generated__/compiledHooks_RefetchableFragment.graphql.ts":"19","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/__generated__/compiledHooks_RefetchableFragment_RefetchQuery.graphql.ts":"20","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/__generated__/compiledHooks_Root_executionQuery.graphql.ts":"21","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/compiledHooks/index.ts":"22","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/compiledHooks/types.ts":"23","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/compiledHooks/useCompiledFragment.ts":"24","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/compiledHooks/useCompiledLazyLoadQuery.ts":"25","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/compiledHooks/useCompiledPaginationFragment.ts":"26","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/compiledHooks/useCompiledRefetchableFragment.ts":"27","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/compiledHooks/useDeepCompareMemoize.ts":"28","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/compiledHooks/useForceUpdate.ts":"29","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/compiledHooks.test.tsx":"30","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/createImportDocumentsTransform.test.ts":"31","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/createImportDocumentsTransform.ts":"32","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/fragmentReferencesFieldPolicy.test.ts":"33","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/fragmentReferencesFieldPolicy.ts":"34","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/index.ts":"35","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/nodeFromCacheFieldPolicy.test.ts":"36","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/nodeFromCacheFieldPolicy.ts":"37","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/shallowCompareFragmentReferences.ts":"38","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/typePolicies.ts":"39","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/types.ts":"40","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/useOverridenOrDefaultApolloClient.ts":"41"},{"size":527,"mtime":1653946283301,"results":"42","hashOfConfig":"43"},{"size":8845,"mtime":1653946283301,"results":"44","hashOfConfig":"43"},{"size":6838,"mtime":1653946283301,"results":"45","hashOfConfig":"43"},{"size":6980,"mtime":1653946283301,"results":"46","hashOfConfig":"43"},{"size":4869,"mtime":1653946283301,"results":"47","hashOfConfig":"43"},{"size":9970,"mtime":1653946283301,"results":"48","hashOfConfig":"43"},{"size":1915,"mtime":1653946283301,"results":"49","hashOfConfig":"43"},{"size":689,"mtime":1653946283301,"results":"50","hashOfConfig":"43"},{"size":8969,"mtime":1653946283301,"results":"51","hashOfConfig":"43"},{"size":174,"mtime":1653946283301,"results":"52","hashOfConfig":"43"},{"size":795,"mtime":1653946283301,"results":"53","hashOfConfig":"43"},{"size":21245,"mtime":1653946283301,"results":"54","hashOfConfig":"43"},{"size":542,"mtime":1653946283301,"results":"55","hashOfConfig":"43"},{"size":4762,"mtime":1653946283301,"results":"56","hashOfConfig":"43"},{"size":957,"mtime":1653946283301,"results":"57","hashOfConfig":"43"},{"size":34594,"mtime":1653946283305,"results":"58","hashOfConfig":"43"},{"size":607,"mtime":1653946283305,"results":"59","hashOfConfig":"43"},{"size":2420,"mtime":1653946283305,"results":"60","hashOfConfig":"43"},{"size":641,"mtime":1653946283305,"results":"61","hashOfConfig":"43"},{"size":11175,"mtime":1653946283305,"results":"62","hashOfConfig":"43"},{"size":27253,"mtime":1653946283305,"results":"63","hashOfConfig":"43"},{"size":445,"mtime":1653946283305,"results":"64","hashOfConfig":"43"},{"size":518,"mtime":1653946283305,"results":"65","hashOfConfig":"43"},{"size":2390,"mtime":1653946283305,"results":"66","hashOfConfig":"43"},{"size":3419,"mtime":1653946283305,"results":"67","hashOfConfig":"43"},{"size":8866,"mtime":1653946283305,"results":"68","hashOfConfig":"43"},{"size":5210,"mtime":1653946283305,"results":"69","hashOfConfig":"43"},{"size":843,"mtime":1653946283305,"results":"70","hashOfConfig":"43"},{"size":152,"mtime":1653946283305,"results":"71","hashOfConfig":"43"},{"size":33457,"mtime":1653946283305,"results":"72","hashOfConfig":"43"},{"size":2108,"mtime":1653946283305,"results":"73","hashOfConfig":"43"},{"size":5887,"mtime":1653946283305,"results":"74","hashOfConfig":"43"},{"size":1838,"mtime":1653946283305,"results":"75","hashOfConfig":"43"},{"size":285,"mtime":1653946283305,"results":"76","hashOfConfig":"43"},{"size":342,"mtime":1653946283305,"results":"77","hashOfConfig":"43"},{"size":3040,"mtime":1653946283305,"results":"78","hashOfConfig":"43"},{"size":2765,"mtime":1653946283305,"results":"79","hashOfConfig":"43"},{"size":2092,"mtime":1653946283305,"results":"80","hashOfConfig":"43"},{"size":1102,"mtime":1653946283305,"results":"81","hashOfConfig":"43"},{"size":1674,"mtime":1653946283305,"results":"82","hashOfConfig":"43"},{"size":1107,"mtime":1653946283305,"results":"83","hashOfConfig":"43"},{"filePath":"84","messages":"85","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"1vsqegx",{"filePath":"86","messages":"87","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"88","messages":"89","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"90","messages":"91","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"92","messages":"93","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"94","messages":"95","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"96","messages":"97","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"98","messages":"99","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"100","messages":"101","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"102","messages":"103","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"104","messages":"105","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"106","messages":"107","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"108","messages":"109","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"110","messages":"111","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"112","messages":"113","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"114","messages":"115","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"116","messages":"117","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"118","messages":"119","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"120","messages":"121","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"122","messages":"123","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"124","messages":"125","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"126","messages":"127","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"128","messages":"129","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"130","messages":"131","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"132","messages":"133","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"134","messages":"135","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"136","messages":"137","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"138","messages":"139","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"140","messages":"141","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"142","messages":"143","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"144","messages":"145","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"146","messages":"147","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"148","messages":"149","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"150","messages":"151","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"152","messages":"153","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"154","messages":"155","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"156","messages":"157","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"158","messages":"159","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"160","messages":"161","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"162","messages":"163","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"164","messages":"165","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/__tests__/__generated__/hooksTestFragment.graphql.ts",[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/__tests__/__generated__/hooksTestMutation.graphql.ts",[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/__tests__/__generated__/hooksTestQuery.graphql.ts",[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/__tests__/__generated__/hooksTestSubscription.graphql.ts",[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/__tests__/__generated__/hooksTestWatchNodeQuery.graphql.ts",[],"/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/__generated__/compiledHooks_BackwardPaginationFragment.graphql.ts",[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/__generated__/compiledHooks_BackwardPaginationFragment_PaginationQuery.graphql.ts",[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/__generated__/compiledHooks_ChildFragment.graphql.ts",[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/__generated__/compiledHooks_ChildWatchNodeQuery.graphql.ts",[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/__generated__/compiledHooks_ForwardPaginationFragment.graphql.ts",[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/__generated__/compiledHooks_ForwardPaginationFragment_PaginationQuery.graphql.ts",[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/__generated__/compiledHooks_QueryTypeFragment.graphql.ts",[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/__generated__/compiledHooks_QueryTypeWatchNodeQuery.graphql.ts",[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/__generated__/compiledHooks_RefetchableFragment.graphql.ts",[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/__generated__/compiledHooks_RefetchableFragment_RefetchQuery.graphql.ts",[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/__generated__/compiledHooks_Root_executionQuery.graphql.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/compiledHooks.test.tsx",[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/createImportDocumentsTransform.test.ts",[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/createImportDocumentsTransform.ts",[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/fragmentReferencesFieldPolicy.test.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.test.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__/__generated__/hooksTestFragment.graphql.ts":"1","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/__tests__/__generated__/hooksTestMutation.graphql.ts":"2","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/__tests__/__generated__/hooksTestQuery.graphql.ts":"3","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/__tests__/__generated__/hooksTestSubscription.graphql.ts":"4","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/__tests__/__generated__/hooksTestWatchNodeQuery.graphql.ts":"5","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/__tests__/hooks.test.tsx":"6","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/__tests__/useOverridenOrDefaultApolloClient.test.tsx":"7","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/convertFetchPolicy.ts":"8","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/hooks.ts":"9","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/index.ts":"10","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/__generated__/compiledHooks_BackwardPaginationFragment.graphql.ts":"11","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/__generated__/compiledHooks_BackwardPaginationFragment_PaginationQuery.graphql.ts":"12","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/__generated__/compiledHooks_ChildFragment.graphql.ts":"13","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/__generated__/compiledHooks_ChildWatchNodeQuery.graphql.ts":"14","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/__generated__/compiledHooks_ForwardPaginationFragment.graphql.ts":"15","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/__generated__/compiledHooks_ForwardPaginationFragment_PaginationQuery.graphql.ts":"16","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/__generated__/compiledHooks_QueryTypeFragment.graphql.ts":"17","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/__generated__/compiledHooks_QueryTypeWatchNodeQuery.graphql.ts":"18","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/__generated__/compiledHooks_RefetchableFragment.graphql.ts":"19","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/__generated__/compiledHooks_RefetchableFragment_RefetchQuery.graphql.ts":"20","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/__generated__/compiledHooks_Root_executionQuery.graphql.ts":"21","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/compiledHooks/index.ts":"22","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/compiledHooks/types.ts":"23","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/compiledHooks/useCompiledFragment.ts":"24","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/compiledHooks/useCompiledLazyLoadQuery.ts":"25","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/compiledHooks/useCompiledPaginationFragment.ts":"26","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/compiledHooks/useCompiledRefetchableFragment.ts":"27","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/compiledHooks/useDeepCompareMemoize.ts":"28","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/compiledHooks/useForceUpdate.ts":"29","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/compiledHooks.test.tsx":"30","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/createImportDocumentsTransform.test.ts":"31","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/createImportDocumentsTransform.ts":"32","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/fragmentReferencesFieldPolicy.test.ts":"33","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/fragmentReferencesFieldPolicy.ts":"34","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/index.ts":"35","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/nodeFromCacheFieldPolicy.test.ts":"36","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/nodeFromCacheFieldPolicy.ts":"37","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/shallowCompareFragmentReferences.ts":"38","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/typePolicies.ts":"39","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/types.ts":"40","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/useOverridenOrDefaultApolloClient.ts":"41"},{"size":527,"mtime":1654092386949,"results":"42","hashOfConfig":"43"},{"size":8845,"mtime":1654092386949,"results":"44","hashOfConfig":"43"},{"size":6838,"mtime":1654092386949,"results":"45","hashOfConfig":"43"},{"size":6980,"mtime":1654092386949,"results":"46","hashOfConfig":"43"},{"size":4869,"mtime":1654092386949,"results":"47","hashOfConfig":"43"},{"size":9970,"mtime":1654092386949,"results":"48","hashOfConfig":"43"},{"size":1915,"mtime":1654092386949,"results":"49","hashOfConfig":"43"},{"size":689,"mtime":1654092386949,"results":"50","hashOfConfig":"43"},{"size":8969,"mtime":1654092386949,"results":"51","hashOfConfig":"43"},{"size":174,"mtime":1654092386949,"results":"52","hashOfConfig":"43"},{"size":795,"mtime":1654092386949,"results":"53","hashOfConfig":"43"},{"size":21245,"mtime":1654092386949,"results":"54","hashOfConfig":"43"},{"size":542,"mtime":1654092386949,"results":"55","hashOfConfig":"43"},{"size":4762,"mtime":1654092386949,"results":"56","hashOfConfig":"43"},{"size":957,"mtime":1654092386949,"results":"57","hashOfConfig":"43"},{"size":34594,"mtime":1654092386949,"results":"58","hashOfConfig":"43"},{"size":607,"mtime":1654092386949,"results":"59","hashOfConfig":"43"},{"size":2420,"mtime":1654092386949,"results":"60","hashOfConfig":"43"},{"size":641,"mtime":1654092386949,"results":"61","hashOfConfig":"43"},{"size":11175,"mtime":1654092386949,"results":"62","hashOfConfig":"43"},{"size":27253,"mtime":1654092386949,"results":"63","hashOfConfig":"43"},{"size":445,"mtime":1654092386949,"results":"64","hashOfConfig":"43"},{"size":518,"mtime":1654092386949,"results":"65","hashOfConfig":"43"},{"size":2390,"mtime":1654092386949,"results":"66","hashOfConfig":"43"},{"size":3505,"mtime":1654092386949,"results":"67","hashOfConfig":"43"},{"size":8866,"mtime":1654092386949,"results":"68","hashOfConfig":"43"},{"size":5210,"mtime":1654092386949,"results":"69","hashOfConfig":"43"},{"size":843,"mtime":1654092386949,"results":"70","hashOfConfig":"43"},{"size":152,"mtime":1654092386949,"results":"71","hashOfConfig":"43"},{"size":33667,"mtime":1654092386949,"results":"72","hashOfConfig":"43"},{"size":2108,"mtime":1654092386949,"results":"73","hashOfConfig":"43"},{"size":5887,"mtime":1654092386949,"results":"74","hashOfConfig":"43"},{"size":1838,"mtime":1654092386949,"results":"75","hashOfConfig":"43"},{"size":285,"mtime":1654092386949,"results":"76","hashOfConfig":"43"},{"size":342,"mtime":1654092386949,"results":"77","hashOfConfig":"43"},{"size":3040,"mtime":1654092386953,"results":"78","hashOfConfig":"43"},{"size":2765,"mtime":1654092386953,"results":"79","hashOfConfig":"43"},{"size":2092,"mtime":1654092386953,"results":"80","hashOfConfig":"43"},{"size":1102,"mtime":1654092386953,"results":"81","hashOfConfig":"43"},{"size":1674,"mtime":1654092386953,"results":"82","hashOfConfig":"43"},{"size":1237,"mtime":1654092386953,"results":"83","hashOfConfig":"43"},{"filePath":"84","messages":"85","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"1vsqegx",{"filePath":"86","messages":"87","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"88","messages":"89","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"90","messages":"91","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"92","messages":"93","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"94","messages":"95","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"96","messages":"97","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"98","messages":"99","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"100","messages":"101","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"102","messages":"103","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"104","messages":"105","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"106","messages":"107","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"108","messages":"109","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"110","messages":"111","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"112","messages":"113","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"114","messages":"115","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"116","messages":"117","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"118","messages":"119","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"120","messages":"121","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"122","messages":"123","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"124","messages":"125","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"126","messages":"127","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"128","messages":"129","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"130","messages":"131","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"132","messages":"133","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"134","messages":"135","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"136","messages":"137","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"138","messages":"139","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"140","messages":"141","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"142","messages":"143","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"144","messages":"145","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"146","messages":"147","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"148","messages":"149","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"150","messages":"151","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"152","messages":"153","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"154","messages":"155","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"156","messages":"157","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"158","messages":"159","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"160","messages":"161","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"162","messages":"163","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"164","messages":"165","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/__tests__/__generated__/hooksTestFragment.graphql.ts",[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/__tests__/__generated__/hooksTestMutation.graphql.ts",[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/__tests__/__generated__/hooksTestQuery.graphql.ts",[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/__tests__/__generated__/hooksTestSubscription.graphql.ts",[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/__tests__/__generated__/hooksTestWatchNodeQuery.graphql.ts",[],"/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/__generated__/compiledHooks_BackwardPaginationFragment.graphql.ts",[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/__generated__/compiledHooks_BackwardPaginationFragment_PaginationQuery.graphql.ts",[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/__generated__/compiledHooks_ChildFragment.graphql.ts",[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/__generated__/compiledHooks_ChildWatchNodeQuery.graphql.ts",[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/__generated__/compiledHooks_ForwardPaginationFragment.graphql.ts",[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/__generated__/compiledHooks_ForwardPaginationFragment_PaginationQuery.graphql.ts",[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/__generated__/compiledHooks_QueryTypeFragment.graphql.ts",[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/__generated__/compiledHooks_QueryTypeWatchNodeQuery.graphql.ts",[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/__generated__/compiledHooks_RefetchableFragment.graphql.ts",[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/__generated__/compiledHooks_RefetchableFragment_RefetchQuery.graphql.ts",[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/__generated__/compiledHooks_Root_executionQuery.graphql.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/compiledHooks.test.tsx",[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/createImportDocumentsTransform.test.ts",[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/createImportDocumentsTransform.ts",[],"/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/fragmentReferencesFieldPolicy.test.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.test.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",[]]
|
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
|
|
3
|
+
This log was last generated on Wed, 01 Jun 2022 14:11:59 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 1.0.1-alpha.6
|
|
8
|
+
|
|
9
|
+
Wed, 01 Jun 2022 14:11:59 GMT
|
|
10
|
+
|
|
11
|
+
### Changes
|
|
12
|
+
|
|
13
|
+
- [duct-tape] Use custom apollo provider in our tests (eloy.de.enige@gmail.com)
|
|
14
|
+
|
|
7
15
|
## 1.0.1-alpha.5
|
|
8
16
|
|
|
9
|
-
Mon, 30 May 2022 21:36:
|
|
17
|
+
Mon, 30 May 2022 21:36:46 GMT
|
|
10
18
|
|
|
11
19
|
### Changes
|
|
12
20
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCompiledLazyLoadQuery.d.ts","sourceRoot":"","sources":["../../../src/storeObservation/compiledHooks/useCompiledLazyLoadQuery.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useCompiledLazyLoadQuery.d.ts","sourceRoot":"","sources":["../../../src/storeObservation/compiledHooks/useCompiledLazyLoadQuery.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAoE9E;;;;;;;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"}
|
|
@@ -60,8 +60,7 @@ class ExecutionQueryHandler {
|
|
|
60
60
|
});
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
-
function useExecutionQuery(executionQueryDocument, variables) {
|
|
64
|
-
const client = (0, import_useOverridenOrDefaultApolloClient.useOverridenOrDefaultApolloClient)();
|
|
63
|
+
function useExecutionQuery(client, executionQueryDocument, variables) {
|
|
65
64
|
const forceUpdate = (0, import_useForceUpdate.useForceUpdate)();
|
|
66
65
|
const execution = (0, import_react.useRef)(new ExecutionQueryHandler(() => forceUpdate()));
|
|
67
66
|
(0, import_react.useEffect)(() => {
|
|
@@ -82,9 +81,11 @@ function useCompiledLazyLoadQuery(documents, options) {
|
|
|
82
81
|
(0, import_invariant.default)(watchQueryDocument, "useLazyLoadQuery(): Expected a `watchQueryDocument` to have been extracted. Did you forget to invoke the compiler?");
|
|
83
82
|
const {executionQueryDocument} = documents;
|
|
84
83
|
(0, import_invariant.default)(executionQueryDocument, "useLazyLoadQuery(): Expected a `executionQueryDocument` to have been extracted. Did you forget to invoke the compiler?");
|
|
84
|
+
const client = (0, import_useOverridenOrDefaultApolloClient.useOverridenOrDefaultApolloClient)();
|
|
85
85
|
const variables = (0, import_useDeepCompareMemoize.useDeepCompareMemoize)(options.variables);
|
|
86
|
-
const [loading, error] = useExecutionQuery(executionQueryDocument, variables);
|
|
86
|
+
const [loading, error] = useExecutionQuery(client, executionQueryDocument, variables);
|
|
87
87
|
const {data} = (0, import_client.useQuery)(watchQueryDocument, {
|
|
88
|
+
client,
|
|
88
89
|
variables,
|
|
89
90
|
fetchPolicy: "cache-only",
|
|
90
91
|
skip: loading || !!error
|
|
@@ -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 {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkC;AAClC,
|
|
4
|
+
"sourcesContent": ["import { useRef, useEffect } from \"react\";\nimport {\n useQuery as useApolloQuery,\n ObservableQuery,\n ApolloClient,\n} from \"@apollo/client\";\nimport invariant from \"invariant\";\nimport { useDeepCompareMemoize } from \"./useDeepCompareMemoize\";\nimport { CompiledArtefactModule } from \"relay-compiler-language-graphitation\";\nimport { DocumentNode } from \"graphql\";\nimport { useForceUpdate } from \"./useForceUpdate\";\nimport { useOverridenOrDefaultApolloClient } from \"../../useOverridenOrDefaultApolloClient\";\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,mBAAkC;AAClC,oBAIO;AACP,uBAAsB;AACtB,mCAAsC;AAGtC,4BAA+B;AAC/B,+CAAkD;AAElD,4BAA4B;AAAA,EAI1B,YAAoB,YAAwB;AAAxB;AAClB,SAAK,SAAS,CAAC,MAAM;AAAA;AAAA,EAGhB,SAAS;AACd,WAAO,KAAK,OAAO,MAAM,KAAK,sBAAsB;AAAA;AAAA,EAG/C,UAAU;AAzBnB;AA0BI,eAAK,sBAAL,mBAAwB;AACxB,SAAK,oBAAoB;AAAA;AAAA,EAGpB,QAAQ;AACb,SAAK;AACL,SAAK,SAAS,CAAC,MAAM;AAAA;AAAA,EAGf,aAAa,OAAe;AAClC,SAAK,SAAS,CAAC,OAAO;AACtB,SAAK;AACL,SAAK;AAAA;AAAA,EAGA,UAAU,YAA6B;AAC5C,SAAK,oBAAoB,WAAW,UAClC,CAAC,CAAE,OAAO,SAAU;AAClB,WAAK,aAAa;AAAA,OAEpB,CAAC,QAAQ;AACP,WAAK,aAAa;AAAA;AAAA;AAAA;AAM1B,2BACE,QACA,wBACA,WACmC;AACnC,QAAM,cAAc;AACpB,QAAM,YAAY,yBAAO,IAAI,sBAAsB,MAAM;AACzD,8BAAU,MAAM;AACd,QAAI,UAAU,QAAQ,UAAU;AAC9B,gBAAU,QAAQ,UAChB,OAAO,WAAW;AAAA,QAChB,OAAO;AAAA,QACP;AAAA;AAAA;AAIN,WAAO,MAAM;AACX,gBAAU,QAAQ;AAAA;AAAA,KAEnB,CAAC,wBAAwB;AAC5B,SAAO,UAAU,QAAQ;AAAA;AAWpB,kCACL,WACA,SAC+B;AAC/B,QAAM,CAAE,sBAAuB;AAC/B,gCACE,oBACA;AAGF,QAAM,CAAE,0BAA2B;AACnC,gCACE,wBACA;AAGF,QAAM,SAAS;AACf,QAAM,YAAY,wDAAsB,QAAQ;AAEhD,QAAM,CAAC,SAAS,SAAS,kBACvB,QACA,wBACA;AAGF,QAAM,CAAE,QAAS,4BAAe,oBAAoB;AAAA,IAClD;AAAA,IACA;AAAA,IACA,aAAa;AAAA,IAEb,MAAM,WAAW,CAAC,CAAC;AAAA;AAErB,SAAO,CAAE,MAAM;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
// src/storeObservation/compiledHooks/useCompiledLazyLoadQuery.ts
|
|
2
2
|
import {useRef, useEffect} from "react";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
useQuery as useApolloQuery
|
|
5
|
+
} from "@apollo/client";
|
|
4
6
|
import invariant from "invariant";
|
|
5
7
|
import {useDeepCompareMemoize} from "./useDeepCompareMemoize.mjs";
|
|
6
8
|
import {useForceUpdate} from "./useForceUpdate.mjs";
|
|
@@ -35,8 +37,7 @@ var ExecutionQueryHandler = class {
|
|
|
35
37
|
});
|
|
36
38
|
}
|
|
37
39
|
};
|
|
38
|
-
function useExecutionQuery(executionQueryDocument, variables) {
|
|
39
|
-
const client = useOverridenOrDefaultApolloClient();
|
|
40
|
+
function useExecutionQuery(client, executionQueryDocument, variables) {
|
|
40
41
|
const forceUpdate = useForceUpdate();
|
|
41
42
|
const execution = useRef(new ExecutionQueryHandler(() => forceUpdate()));
|
|
42
43
|
useEffect(() => {
|
|
@@ -57,9 +58,11 @@ function useCompiledLazyLoadQuery(documents, options) {
|
|
|
57
58
|
invariant(watchQueryDocument, "useLazyLoadQuery(): Expected a `watchQueryDocument` to have been extracted. Did you forget to invoke the compiler?");
|
|
58
59
|
const {executionQueryDocument} = documents;
|
|
59
60
|
invariant(executionQueryDocument, "useLazyLoadQuery(): Expected a `executionQueryDocument` to have been extracted. Did you forget to invoke the compiler?");
|
|
61
|
+
const client = useOverridenOrDefaultApolloClient();
|
|
60
62
|
const variables = useDeepCompareMemoize(options.variables);
|
|
61
|
-
const [loading, error] = useExecutionQuery(executionQueryDocument, variables);
|
|
63
|
+
const [loading, error] = useExecutionQuery(client, executionQueryDocument, variables);
|
|
62
64
|
const {data} = useApolloQuery(watchQueryDocument, {
|
|
65
|
+
client,
|
|
63
66
|
variables,
|
|
64
67
|
fetchPolicy: "cache-only",
|
|
65
68
|
skip: loading || !!error
|
|
@@ -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 {
|
|
5
|
-
"mappings": ";AAAA;AACA;
|
|
4
|
+
"sourcesContent": ["import { useRef, useEffect } from \"react\";\nimport {\n useQuery as useApolloQuery,\n ObservableQuery,\n ApolloClient,\n} from \"@apollo/client\";\nimport invariant from \"invariant\";\nimport { useDeepCompareMemoize } from \"./useDeepCompareMemoize\";\nimport { CompiledArtefactModule } from \"relay-compiler-language-graphitation\";\nimport { DocumentNode } from \"graphql\";\nimport { useForceUpdate } from \"./useForceUpdate\";\nimport { useOverridenOrDefaultApolloClient } from \"../../useOverridenOrDefaultApolloClient\";\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;AACA;AAAA;AAAA;AAKA;AACA;AAGA;AACA;AAEA,kCAA4B;AAAA,EAI1B,YAAoB,YAAwB;AAAxB;AAClB,SAAK,SAAS,CAAC,MAAM;AAAA;AAAA,EAGhB,SAAS;AACd,WAAO,KAAK,OAAO,MAAM,KAAK,sBAAsB;AAAA;AAAA,EAG/C,UAAU;AAzBnB;AA0BI,eAAK,sBAAL,mBAAwB;AACxB,SAAK,oBAAoB;AAAA;AAAA,EAGpB,QAAQ;AACb,SAAK;AACL,SAAK,SAAS,CAAC,MAAM;AAAA;AAAA,EAGf,aAAa,OAAe;AAClC,SAAK,SAAS,CAAC,OAAO;AACtB,SAAK;AACL,SAAK;AAAA;AAAA,EAGA,UAAU,YAA6B;AAC5C,SAAK,oBAAoB,WAAW,UAClC,CAAC,CAAE,OAAO,SAAU;AAClB,WAAK,aAAa;AAAA,OAEpB,CAAC,QAAQ;AACP,WAAK,aAAa;AAAA;AAAA;AAAA;AAM1B,2BACE,QACA,wBACA,WACmC;AACnC,QAAM,cAAc;AACpB,QAAM,YAAY,OAAO,IAAI,sBAAsB,MAAM;AACzD,YAAU,MAAM;AACd,QAAI,UAAU,QAAQ,UAAU;AAC9B,gBAAU,QAAQ,UAChB,OAAO,WAAW;AAAA,QAChB,OAAO;AAAA,QACP;AAAA;AAAA;AAIN,WAAO,MAAM;AACX,gBAAU,QAAQ;AAAA;AAAA,KAEnB,CAAC,wBAAwB;AAC5B,SAAO,UAAU,QAAQ;AAAA;AAWpB,kCACL,WACA,SAC+B;AAC/B,QAAM,CAAE,sBAAuB;AAC/B,YACE,oBACA;AAGF,QAAM,CAAE,0BAA2B;AACnC,YACE,wBACA;AAGF,QAAM,SAAS;AACf,QAAM,YAAY,sBAAsB,QAAQ;AAEhD,QAAM,CAAC,SAAS,SAAS,kBACvB,QACA,wBACA;AAGF,QAAM,CAAE,QAAS,eAAe,oBAAoB;AAAA,IAClD;AAAA,IACA;AAAA,IACA,aAAa;AAAA,IAEb,MAAM,WAAW,CAAC,CAAC;AAAA;AAErB,SAAO,CAAE,MAAM;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -61,6 +61,7 @@ var fs = __toModule(require("fs"));
|
|
|
61
61
|
var path = __toModule(require("path"));
|
|
62
62
|
var import_compiledHooks = __toModule(require("./compiledHooks"));
|
|
63
63
|
var import_typePolicies = __toModule(require("./typePolicies"));
|
|
64
|
+
var import_useOverridenOrDefaultApolloClient = __toModule(require("../useOverridenOrDefaultApolloClient"));
|
|
64
65
|
var import_compiledHooks_Root_executionQuery = __toModule(require("./__generated__/compiledHooks_Root_executionQuery.graphql"));
|
|
65
66
|
var import_compiledHooks_ChildWatchNodeQuery = __toModule(require("./__generated__/compiledHooks_ChildWatchNodeQuery.graphql"));
|
|
66
67
|
var import_compiledHooks_RefetchableFragment_RefetchQuery = __toModule(require("./__generated__/compiledHooks_RefetchableFragment_RefetchQuery.graphql"));
|
|
@@ -224,7 +225,7 @@ describe.each([
|
|
|
224
225
|
})
|
|
225
226
|
});
|
|
226
227
|
(0, import_react_test_renderer.act)(() => {
|
|
227
|
-
testRenderer = (0, import_react_test_renderer.create)(/* @__PURE__ */ import_react.default.createElement(
|
|
228
|
+
testRenderer = (0, import_react_test_renderer.create)(/* @__PURE__ */ import_react.default.createElement(import_useOverridenOrDefaultApolloClient.ApolloReactRelayDuctTapeProvider, {
|
|
228
229
|
client
|
|
229
230
|
}, /* @__PURE__ */ import_react.default.createElement(ErrorBoundary, null, /* @__PURE__ */ import_react.default.createElement(RootComponent, {
|
|
230
231
|
variables: {
|
|
@@ -313,7 +314,7 @@ describe.each([
|
|
|
313
314
|
}));
|
|
314
315
|
it("fetches new data when variables change", () => __async(void 0, null, function* () {
|
|
315
316
|
(0, import_react_test_renderer.act)(() => {
|
|
316
|
-
testRenderer.update(/* @__PURE__ */ import_react.default.createElement(
|
|
317
|
+
testRenderer.update(/* @__PURE__ */ import_react.default.createElement(import_useOverridenOrDefaultApolloClient.ApolloReactRelayDuctTapeProvider, {
|
|
317
318
|
client
|
|
318
319
|
}, /* @__PURE__ */ import_react.default.createElement(ErrorBoundary, null, /* @__PURE__ */ import_react.default.createElement(RootComponent, {
|
|
319
320
|
variables: {
|
|
@@ -331,7 +332,7 @@ describe.each([
|
|
|
331
332
|
it("does not try to kick-off a new query when the variables object deep equals the previous one", () => __async(void 0, null, function* () {
|
|
332
333
|
const spy = jest.spyOn(client, "query");
|
|
333
334
|
yield (0, import_react_test_renderer.act)(() => __async(void 0, null, function* () {
|
|
334
|
-
testRenderer.update(/* @__PURE__ */ import_react.default.createElement(
|
|
335
|
+
testRenderer.update(/* @__PURE__ */ import_react.default.createElement(import_useOverridenOrDefaultApolloClient.ApolloReactRelayDuctTapeProvider, {
|
|
335
336
|
client
|
|
336
337
|
}, /* @__PURE__ */ import_react.default.createElement(ErrorBoundary, null, /* @__PURE__ */ import_react.default.createElement(RootComponent, {
|
|
337
338
|
variables: {
|
|
@@ -422,7 +423,7 @@ describe.each([
|
|
|
422
423
|
});
|
|
423
424
|
it("fetches new data when variables change", () => __async(this, null, function* () {
|
|
424
425
|
(0, import_react_test_renderer.act)(() => {
|
|
425
|
-
testRenderer.update(/* @__PURE__ */ import_react.default.createElement(
|
|
426
|
+
testRenderer.update(/* @__PURE__ */ import_react.default.createElement(import_useOverridenOrDefaultApolloClient.ApolloReactRelayDuctTapeProvider, {
|
|
426
427
|
client
|
|
427
428
|
}, /* @__PURE__ */ import_react.default.createElement(ErrorBoundary, null, /* @__PURE__ */ import_react.default.createElement(RootComponent, {
|
|
428
429
|
variables: {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/storeObservation/compiledHooks.test.tsx"],
|
|
4
|
-
"sourcesContent": ["import React from \"react\";\nimport {\n ApolloClient,\n ApolloProvider,\n defaultDataIdFromObject,\n} from \"@apollo/client\";\nimport {\n act,\n create as createTestRenderer,\n ReactTestRenderer,\n} from \"react-test-renderer\";\nimport { buildSchema } from \"graphql\";\nimport { graphql } from \"@graphitation/graphql-js-tag\";\nimport {\n ApolloMockClient,\n createMockClient,\n} from \"@graphitation/apollo-mock-client\";\nimport * as MockPayloadGenerator from \"@graphitation/graphql-js-operation-payload-generator\";\nimport * as fs from \"fs\";\nimport * as path from \"path\";\n\nimport {\n Disposable,\n RefetchFn,\n useCompiledFragment,\n useCompiledLazyLoadQuery,\n useCompiledPaginationFragment,\n useCompiledRefetchableFragment,\n} from \"./compiledHooks\";\nimport {\n typePoliciesWithDefaultApolloClientStoreKeys,\n typePoliciesWithGlobalObjectIdStoreKeys,\n} from \"./typePolicies\";\n\n/**\n * NOTE: These compiler artefacts are normally imported using the transform from the createImportDocumentsTransform.ts module\n */\nimport { documents as compiledHooks_Root_executionQuery_documents } from \"./__generated__/compiledHooks_Root_executionQuery.graphql\";\nimport { documents as compiledHooks_ChildFragment_documents } from \"./__generated__/compiledHooks_ChildWatchNodeQuery.graphql\";\nimport { documents as compiledHooks_RefetchableFragment_documents } from \"./__generated__/compiledHooks_RefetchableFragment_RefetchQuery.graphql\";\nimport { documents as compiledHooks_QueryTypeFragment_documents } from \"./__generated__/compiledHooks_QueryTypeWatchNodeQuery.graphql\";\nimport { documents as compiledHooks_ForwardPaginationFragment_documents } from \"./__generated__/compiledHooks_ForwardPaginationFragment_PaginationQuery.graphql\";\nimport { documents as compiledHooks_BackwardPaginationFragment_documents } from \"./__generated__/compiledHooks_BackwardPaginationFragment_PaginationQuery.graphql\";\nimport { compiledHooks_Root_executionQueryVariables } from \"./__generated__/compiledHooks_Root_executionQuery.graphql\";\n\nconst schema = buildSchema(\n fs.readFileSync(\n path.resolve(__dirname, \"../__tests__/schema.graphql\"),\n \"utf8\"\n )\n);\n\nconst Child_fragment = graphql`\n fragment compiledHooks_ChildFragment on User {\n petName\n }\n`;\n\nconst Refetchable_fragment = graphql`\n fragment compiledHooks_RefetchableFragment on User\n @refetchable(queryName: \"compiledHooks_RefetchableFragment_RefetchQuery\") {\n petName\n avatarUrl(size: $avatarSize)\n }\n`;\n\nconst QueryType_fragment = graphql`\n fragment compiledHooks_QueryTypeFragment on Query {\n nonNode {\n id\n }\n }\n`;\n\nconst ForwardPagination_fragment = graphql`\n fragment compiledHooks_ForwardPaginationFragment on User\n @refetchable(\n queryName: \"compiledHooks_ForwardPaginationFragment_PaginationQuery\"\n )\n @argumentDefinitions(\n conversationsForwardCount: { type: \"Int!\", defaultValue: 1 }\n conversationsAfterCursor: { type: \"String!\", defaultValue: \"\" }\n ) {\n petName\n avatarUrl(size: $avatarSize)\n conversations(\n first: $conversationsForwardCount\n after: $conversationsAfterCursor\n ) @connection(key: \"compiledHooks_user_conversations\") {\n edges {\n node {\n title\n ...compiledHooks_BackwardPaginationFragment\n }\n }\n }\n }\n`;\n\nconst BackwardPagination_fragment = graphql`\n fragment compiledHooks_BackwardPaginationFragment on Conversation\n @refetchable(\n queryName: \"compiledHooks_BackwardPaginationFragment_PaginationQuery\"\n ) {\n messages(last: $messagesBackwardCount, before: $messagesBeforeCursor)\n @connection(key: \"compiledHooks_conversation_messages\") {\n edges {\n node {\n text\n }\n }\n }\n }\n`;\n\nconst Root_executionQueryDocument = graphql`\n query compiledHooks_Root_executionQuery(\n $userId: Int!\n $avatarSize: Int = 21\n $messagesBackwardCount: Int!\n $messagesBeforeCursor: String!\n ) {\n user(id: $userId) {\n name\n ...compiledHooks_ChildFragment\n ...compiledHooks_RefetchableFragment\n ...compiledHooks_ForwardPaginationFragment\n }\n ...compiledHooks_QueryTypeFragment\n }\n`;\n\ndescribe.each([\n [\n \"with default Apollo Client type-policies\",\n typePoliciesWithDefaultApolloClientStoreKeys,\n ],\n [\n \"with strict Global Object Id spec type-policies\",\n typePoliciesWithGlobalObjectIdStoreKeys,\n ],\n])(\"compiledHooks %s\", (_, typePolicies) => {\n let client: ApolloMockClient;\n let testRenderer: ReactTestRenderer;\n\n let useFragmentResult: { id: number }[];\n let useRefetchableFragmentResult: ReturnType<\n typeof useCompiledRefetchableFragment\n >[];\n let forwardUsePaginationFragmentResult: ReturnType<\n typeof useCompiledPaginationFragment\n >[];\n let backwardUsePaginationFragmentResult: ReturnType<\n typeof useCompiledPaginationFragment\n >[];\n let useLazyLoadQueryResult: { data?: any; error?: Error } | null = null;\n let componentOnQueryTypeResult: {}[];\n\n const ChildComponent: React.FC<{ user: { id: any } }> = (props) => {\n const result = useCompiledFragment(\n compiledHooks_ChildFragment_documents,\n props.user\n );\n useFragmentResult.push(result as { id: number });\n return null;\n };\n\n const ChildRefetchableComponent: React.FC<{ user: { id: any } }> = (\n props\n ) => {\n const result = useCompiledRefetchableFragment(\n compiledHooks_RefetchableFragment_documents,\n props.user\n );\n useRefetchableFragmentResult.push(result);\n return null;\n };\n\n const ComponentOnQueryType: React.FC<{ query: {} }> = (props) => {\n const result = useCompiledFragment(\n compiledHooks_QueryTypeFragment_documents,\n props.query\n );\n componentOnQueryTypeResult.push(result);\n return null;\n };\n\n const ChildForwardPaginationComponent: React.FC<{ user: { id: any } }> = (\n props\n ) => {\n const result = useCompiledPaginationFragment(\n compiledHooks_ForwardPaginationFragment_documents as any,\n props.user\n );\n forwardUsePaginationFragmentResult.push(result);\n\n return result.data.conversations.edges.map((edge: any, index: number) => {\n return (\n <ChildBackwardPaginationComponent\n conversation={edge.node}\n key={index}\n />\n );\n });\n };\n\n const ChildBackwardPaginationComponent: React.FC<{\n conversation: { id: any };\n }> = (props) => {\n const result = useCompiledPaginationFragment(\n compiledHooks_BackwardPaginationFragment_documents as any,\n props.conversation\n );\n backwardUsePaginationFragmentResult.push(result);\n return null;\n };\n\n const RootComponent: React.FC<{\n variables: compiledHooks_Root_executionQueryVariables;\n }> = (props) => {\n const result = useCompiledLazyLoadQuery(\n compiledHooks_Root_executionQuery_documents,\n { variables: props.variables }\n );\n useLazyLoadQueryResult = result;\n return result.data ? (\n <>\n <ChildComponent user={result.data.user} />\n <ChildRefetchableComponent user={result.data.user} />\n <ChildForwardPaginationComponent user={result.data.user} />\n <ComponentOnQueryType query={result.data} />\n </>\n ) : null;\n };\n\n beforeEach(() => {\n useLazyLoadQueryResult = null;\n useFragmentResult = [];\n useRefetchableFragmentResult = [];\n forwardUsePaginationFragmentResult = [];\n backwardUsePaginationFragmentResult = [];\n componentOnQueryTypeResult = [];\n client = createMockClient(schema, {\n cache: {\n possibleTypes: {\n Node: [\"User\"],\n },\n typePolicies,\n ...(typePolicies === typePoliciesWithDefaultApolloClientStoreKeys\n ? {}\n : {\n dataIdFromObject(responseObject) {\n return (\n responseObject.id?.toString() ||\n defaultDataIdFromObject(responseObject)\n );\n },\n }),\n },\n });\n act(() => {\n testRenderer = createTestRenderer(\n <ApolloProvider client={client}>\n <ErrorBoundary>\n <RootComponent\n variables={{\n userId: 42,\n messagesBackwardCount: 1,\n messagesBeforeCursor: \"\",\n }}\n />\n </ErrorBoundary>\n </ApolloProvider>\n );\n });\n });\n\n describe(useCompiledLazyLoadQuery, () => {\n it(\"correctly returns loading state\", async () => {\n expect(useLazyLoadQueryResult).toEqual({\n data: undefined,\n error: undefined,\n });\n await act(() =>\n client.mock.resolveMostRecentOperation((operation) =>\n MockPayloadGenerator.generate(operation)\n )\n );\n expect(useLazyLoadQueryResult).toEqual({\n data: expect.objectContaining({}),\n error: undefined,\n });\n });\n\n it(\"cancels the execution query while in-flight on unmount\", async () => {\n expect(activeQueries(client).map((query) => query.queryName)).toEqual([\n \"compiledHooks_Root_executionQuery\",\n ]);\n\n await act(async () => {\n testRenderer.unmount();\n return new Promise((resolve) => setTimeout(resolve, 0));\n });\n expect(client.getObservableQueries().size).toBe(0);\n });\n\n describe(\"once loaded\", () => {\n let executionQueryId: string;\n\n beforeEach(async () => {\n executionQueryId = last(activeQueries(client)).queryId;\n await act(() =>\n client.mock.resolveMostRecentOperation((operation) =>\n MockPayloadGenerator.generate(operation, {\n User: (options, generateId) => {\n return {\n id:\n options.parentType === \"Query\"\n ? operation.request.variables.userId\n : generateId(),\n };\n },\n Conversation: () => ({\n id: \"first-paged-conversation\",\n }),\n Message: () => ({\n id: \"first-paged-message\",\n }),\n })\n )\n );\n });\n\n it(\"unsubscribes from the execution query\", async () => {\n expect(\n activeQueries(client).map((query) => query.queryId)\n ).not.toContain(executionQueryId);\n });\n\n it(\"loads all data of the execution query into the store\", () => {\n expect(client.cache.extract()).toMatchSnapshot();\n });\n\n it(\"only returns the fields selected in the watch query to the component\", () => {\n expect(useLazyLoadQueryResult!.data).toMatchSnapshot();\n });\n\n it(\"does not re-render when a field that was not selected in the watch query is updated in the store\", async () => {\n const before = useLazyLoadQueryResult!.data;\n await act(async () => {\n client.cache.modify({\n id: \"User:42\",\n fields: {\n petName: () => \"Phoenix\",\n },\n });\n return new Promise((resolve) => setTimeout(resolve, 0));\n });\n expect(useLazyLoadQueryResult!.data).toBe(before);\n });\n\n it(\"does re-render when a field that was selected in the watch query is updated in the store\", async () => {\n const before = useLazyLoadQueryResult!.data;\n await act(async () => {\n client.cache.modify({\n id:\n typePolicies === typePoliciesWithDefaultApolloClientStoreKeys\n ? \"User:42\"\n : \"42\",\n fields: {\n name: () => \"Satya\",\n },\n });\n return new Promise((resolve) => setTimeout(resolve, 0));\n });\n expect(useLazyLoadQueryResult!.data).not.toBe(before);\n expect(useLazyLoadQueryResult!.data).toMatchSnapshot();\n });\n\n it(\"fetches new data when variables change\", async () => {\n act(() => {\n testRenderer.update(\n <ApolloProvider client={client}>\n <ErrorBoundary>\n <RootComponent\n variables={{\n userId: 21,\n messagesBackwardCount: 1,\n messagesBeforeCursor: \"\",\n }}\n />\n </ErrorBoundary>\n </ApolloProvider>\n );\n });\n await act(() =>\n client.mock.resolveMostRecentOperation((operation) =>\n MockPayloadGenerator.generate(operation, {\n User: () => ({ id: operation.request.variables.userId }),\n })\n )\n );\n expect(\n client.cache.extract()[\n typePolicies === typePoliciesWithDefaultApolloClientStoreKeys\n ? \"User:21\"\n : \"21\"\n ]\n ).toMatchSnapshot();\n });\n\n it(\"does not try to kick-off a new query when the variables object deep equals the previous one\", async () => {\n const spy = jest.spyOn(client, \"query\");\n await act(async () => {\n testRenderer.update(\n <ApolloProvider client={client}>\n <ErrorBoundary>\n <RootComponent\n variables={{\n userId: 42,\n messagesBackwardCount: 1,\n messagesBeforeCursor: \"\",\n }}\n />\n </ErrorBoundary>\n </ApolloProvider>\n );\n return new Promise((resolve) => setTimeout(resolve, 100));\n });\n expect(spy).not.toHaveBeenCalled();\n });\n\n it(\"removes all watch queries on unmount\", async () => {\n await act(async () => {\n testRenderer.unmount();\n return new Promise((resolve) => setTimeout(resolve, 0));\n });\n expect(client.getObservableQueries().size).toBe(0);\n });\n });\n });\n\n function itBehavesLikeFragment(\n returnedResults: () => { id: number }[],\n fragmentSpecificFieldSelections?: {}\n ) {\n // TODO: This should be scoped so it doesn't leak to other tests in the same parent describe\n // describe(\"behaves like useFragment\", () => {\n beforeEach(async () => {\n await act(() =>\n client.mock.resolveMostRecentOperation((operation) => {\n const result = MockPayloadGenerator.generate(operation, {\n User: () => ({\n id: 42,\n }),\n Conversation: () => ({\n id: \"first-paged-conversation\",\n }),\n Message: () => ({\n id: \"first-paged-message\",\n }),\n PageInfo: () => ({\n startCursor: \"first-page-start-cursor\",\n endCursor: \"first-page-end-cursor\",\n hasNextPage: true,\n hasPreviousPage: true,\n }),\n });\n return result;\n })\n );\n });\n\n it(\"only returns the fields selected in the watch query to the component\", () => {\n expect(last(returnedResults())).toEqual({\n __fragments: {\n avatarSize: 21,\n messagesBackwardCount: 1,\n messagesBeforeCursor: \"\",\n userId: 42,\n },\n __typename: \"User\",\n id: 42,\n petName: '<mock-value-for-field-\"petName\">',\n ...fragmentSpecificFieldSelections,\n });\n });\n\n it(\"returns the same object when a field that was not selected in the watch query is updated in the store\", async () => {\n const before = last(returnedResults());\n await act(async () => {\n client.cache.modify({\n id: \"User:42\",\n fields: {\n name: () => \"Satya\",\n },\n });\n return new Promise((resolve) => setTimeout(resolve, 0));\n });\n expect(last(returnedResults())).toBe(before);\n });\n\n it(\"returns a new object when a field that was selected in the watch query is updated in the store\", async () => {\n await act(async () => {\n client.cache.modify({\n id:\n typePolicies === typePoliciesWithDefaultApolloClientStoreKeys\n ? \"User:42\"\n : \"42\",\n fields: {\n petName: () => \"some new value\",\n },\n });\n return new Promise((resolve) => setTimeout(resolve, 0));\n });\n expect(returnedResults().length).toBe(2);\n expect(last(returnedResults())).toMatchObject({\n petName: \"some new value\",\n });\n });\n\n it(\"returns data synchronously\", () => {\n expect(returnedResults().length).toBe(1);\n });\n\n it(\"fetches new data when variables change\", async () => {\n act(() => {\n testRenderer.update(\n <ApolloProvider client={client}>\n <ErrorBoundary>\n <RootComponent\n variables={{\n userId: 21,\n messagesBackwardCount: 1,\n messagesBeforeCursor: \"\",\n }}\n />\n </ErrorBoundary>\n </ApolloProvider>\n );\n });\n await act(() =>\n client.mock.resolveMostRecentOperation((operation) =>\n MockPayloadGenerator.generate(operation, {\n User: () => ({ id: operation.request.variables.userId }),\n })\n )\n );\n expect(last(returnedResults()).id).toBe(21);\n });\n // });\n }\n\n describe(useCompiledFragment, () => {\n itBehavesLikeFragment(() => useFragmentResult, {\n petName: '<mock-value-for-field-\"petName\">',\n });\n\n it(\"also works with fragments on the Query type\", () => {\n expect(last(componentOnQueryTypeResult)).toMatchInlineSnapshot(`\n Object {\n \"__fragments\": Object {\n \"avatarSize\": 21,\n \"messagesBackwardCount\": 1,\n \"messagesBeforeCursor\": \"\",\n \"userId\": 42,\n },\n \"nonNode\": Object {\n \"__typename\": \"NonNode\",\n \"id\": \"<mock-value-for-field-\\\\\"id\\\\\">\",\n },\n }\n `);\n });\n });\n\n function itBehavesLikeRefetchableFragment(\n returnedResults: () => [data: { id: number }, refetch: RefetchFn][]\n ) {\n it.todo(\n \"supports variables with default values on either operations or with @argumentDefinitions\"\n );\n\n describe(\"when refetching\", () => {\n let onCompleted: jest.Mock;\n let disposable: Disposable;\n\n beforeEach(() => {\n const [_data, refetch] = last(returnedResults());\n onCompleted = jest.fn();\n disposable = refetch({ avatarSize: 42 }, { onCompleted });\n });\n\n it(\"can be cancelled\", () => {\n const query = last(activeQueries(client));\n disposable.dispose();\n expect(client.getObservableQueries().has(query.queryId)).toBeFalsy();\n });\n\n it(\"cancels when unmounting\", async () => {\n await act(async () => {\n const query = last(activeQueries(client));\n testRenderer.unmount();\n await new Promise((resolve) => setTimeout(resolve, 0));\n expect(client.getObservableQueries().has(query.queryId)).toBeFalsy();\n });\n });\n\n describe(\"successfully\", () => {\n beforeEach(async () => {\n await act(() => {\n client.mock.resolveMostRecentOperation((operation) =>\n MockPayloadGenerator.generate(operation, {\n Node: () => ({\n id: 42,\n avatarUrl: `avatarUrl-with-size-${operation.request.variables.avatarSize}`,\n }),\n })\n );\n return new Promise((resolve) => setTimeout(resolve, 0));\n });\n });\n\n it(\"returns a new object from the hook\", () => {\n expect(last(returnedResults())[0]).toMatchObject({\n __typename: \"User\",\n avatarUrl: \"avatarUrl-with-size-42\",\n id: 42,\n });\n });\n\n it(\"updates the fragment reference request variables for future requests\", () => {\n expect(last(returnedResults())[0]).toMatchObject({\n __fragments: {\n avatarSize: 42,\n userId: 42,\n },\n });\n });\n\n it(\"invokes the onComplete callback without error\", () => {\n expect(onCompleted).toHaveBeenCalledWith(null);\n });\n });\n\n describe(\"and an error occurs\", () => {\n const error = new Error(\"oh noes\");\n\n beforeEach(async () => {\n await act(() => client.mock.rejectMostRecentOperation(error));\n });\n\n it(\"invokes the onComplete callback when an error occurs\", () => {\n expect(onCompleted).toHaveBeenCalledWith(error);\n });\n\n it(\"does not update the fragment reference request variables for future requests\", async () => {\n const [_data, refetch] = last(returnedResults());\n refetch({});\n expect(\n client.mock.getMostRecentOperation().request.variables.avatarSize\n ).toBe(21);\n });\n });\n });\n }\n\n describe(useCompiledRefetchableFragment, () => {\n itBehavesLikeFragment(\n () =>\n useRefetchableFragmentResult.map(\n ([data, _refetch]) => data as { id: number }\n ),\n { avatarUrl: '<mock-value-for-field-\"avatarUrl\">' }\n );\n\n itBehavesLikeRefetchableFragment(\n () =>\n useRefetchableFragmentResult as [\n data: { id: number },\n refetch: RefetchFn\n ][]\n );\n });\n\n describe(useCompiledPaginationFragment, () => {\n itBehavesLikeFragment(\n () =>\n forwardUsePaginationFragmentResult.map(\n ({ data }) => data as { id: number }\n ),\n {\n avatarUrl: '<mock-value-for-field-\"avatarUrl\">',\n conversations: {\n __typename: \"ConversationsConnection\",\n edges: [\n {\n __typename: \"ConversationsConnectionEdge\",\n cursor: '<mock-value-for-field-\"cursor\">',\n node: {\n __fragments: {\n avatarSize: 21,\n messagesBackwardCount: 1,\n messagesBeforeCursor: \"\",\n userId: 42,\n },\n __typename: \"Conversation\",\n id: \"first-paged-conversation\",\n title: '<mock-value-for-field-\"title\">',\n },\n },\n ],\n pageInfo: {\n __typename: \"PageInfo\",\n endCursor: \"first-page-end-cursor\",\n hasNextPage: true,\n },\n },\n }\n );\n\n itBehavesLikeRefetchableFragment(() =>\n forwardUsePaginationFragmentResult.map(({ data, refetch }) => [\n data as { id: number },\n refetch,\n ])\n );\n\n describe(\"when paginating forward\", () => {\n it(\"returns that next data is available\", () => {\n const { hasNext } = last(forwardUsePaginationFragmentResult);\n expect(hasNext).toBeTruthy();\n });\n\n it(\"uses the correct count and cursor values\", () => {\n act(() => {\n const { loadNext } = last(forwardUsePaginationFragmentResult);\n loadNext(123);\n });\n\n const operation = client.mock.getMostRecentOperation();\n expect(operation.request.variables).toMatchObject({\n conversationsForwardCount: 123,\n conversationsAfterCursor: \"first-page-end-cursor\",\n });\n });\n\n it(\"returns that a pagination operation is in-flight\", () => {\n act(() => {\n const { loadNext } = last(forwardUsePaginationFragmentResult);\n loadNext(123);\n });\n const { isLoadingNext } = last(forwardUsePaginationFragmentResult);\n expect(isLoadingNext).toBeTruthy();\n });\n\n it(\"can be cancelled\", () => {\n act(() => {\n const { loadNext } = last(forwardUsePaginationFragmentResult);\n const disposable = loadNext(123);\n const query = last(activeQueries(client));\n disposable.dispose();\n expect(client.getObservableQueries().has(query.queryId)).toBeFalsy();\n });\n });\n\n it(\"cancels when unmounting\", async () => {\n await act(async () => {\n const { loadNext } = last(forwardUsePaginationFragmentResult);\n loadNext(123);\n const query = last(activeQueries(client));\n\n testRenderer.unmount();\n await new Promise((resolve) => setTimeout(resolve, 0));\n\n expect(client.getObservableQueries().has(query.queryId)).toBeFalsy();\n });\n });\n\n it(\"invokes the onComplete callback when an error occurs\", async () => {\n const onCompleted = jest.fn();\n const error = new Error(\"oh noes\");\n\n const { loadNext } = last(forwardUsePaginationFragmentResult);\n await act(async () => {\n loadNext(1, { onCompleted });\n await client.mock.rejectMostRecentOperation(error);\n });\n\n expect(onCompleted).toHaveBeenCalledWith(error);\n });\n\n describe(\"and having received the response\", () => {\n let onCompleted: jest.Mock;\n\n beforeEach(async () => {\n onCompleted = jest.fn();\n await act(async () => {\n const { loadNext } = last(forwardUsePaginationFragmentResult);\n loadNext(1, { onCompleted });\n\n // Introduce a slight delay before resolving the request as a\n // regression test with a pagination requst being disposed early.\n await new Promise((resolve) => setTimeout(resolve, 0));\n\n client.mock.resolveMostRecentOperation((operation) =>\n MockPayloadGenerator.generate(operation, {\n Node: () => ({\n id: 42,\n }),\n Conversation: () => ({\n id: \"second-paged-conversation\",\n }),\n PageInfo: () => ({\n endCursor: \"second-page-end-cursor\",\n hasNextPage: false,\n }),\n })\n );\n return new Promise((resolve) => setTimeout(resolve, 0));\n });\n });\n\n it(\"returns that no pagination operation is in-flight\", () => {\n const { isLoadingNext } = last(forwardUsePaginationFragmentResult);\n expect(isLoadingNext).toBeFalsy();\n });\n\n it(\"loads the new data into the store\", () => {\n expect(client.cache.extract()).toMatchObject({\n [typePolicies === typePoliciesWithDefaultApolloClientStoreKeys\n ? \"Conversation:second-paged-conversation\"\n : \"second-paged-conversation\"]: {\n id: \"second-paged-conversation\",\n __typename: \"Conversation\",\n title: '<mock-value-for-field-\"title\">',\n },\n });\n });\n\n it(\"returns the complete list data (previous+new) from the hook\", () => {\n const result = last(forwardUsePaginationFragmentResult);\n expect(\n (result.data as any).conversations.edges.map(\n (edge: any) => edge.node.id\n )\n ).toMatchInlineSnapshot(`\n Array [\n \"first-paged-conversation\",\n \"second-paged-conversation\",\n ]\n `);\n });\n\n it(\"uses the new cursor value\", () => {\n act(() => {\n const { loadNext } = last(forwardUsePaginationFragmentResult);\n loadNext(123);\n });\n\n const operation = client.mock.getMostRecentOperation();\n expect(operation.request.variables).toMatchObject({\n conversationsAfterCursor: \"second-page-end-cursor\",\n });\n });\n\n it(\"returns that no next data is available\", () => {\n const { hasNext } = last(forwardUsePaginationFragmentResult);\n expect(hasNext).toBeFalsy();\n });\n\n it(\"invokes the onComplete callback without error\", () => {\n expect(onCompleted).toHaveBeenCalledWith(null);\n });\n });\n });\n\n describe(\"when paginating backward\", () => {\n it(\"returns that previous data is available\", () => {\n const { hasPrevious } = last(backwardUsePaginationFragmentResult);\n expect(hasPrevious).toBeTruthy();\n });\n\n it(\"uses the correct count and cursor values\", () => {\n act(() => {\n const { loadPrevious } = last(backwardUsePaginationFragmentResult);\n loadPrevious(123);\n });\n\n const operation = client.mock.getMostRecentOperation();\n expect(operation.request.variables).toMatchObject({\n messagesBackwardCount: 123,\n messagesBeforeCursor: \"first-page-start-cursor\",\n });\n });\n\n it(\"returns that a pagination operation is in-flight\", () => {\n act(() => {\n const { loadPrevious } = last(backwardUsePaginationFragmentResult);\n loadPrevious(123);\n });\n const { isLoadingPrevious } = last(backwardUsePaginationFragmentResult);\n expect(isLoadingPrevious).toBeTruthy();\n });\n\n it(\"can be cancelled\", () => {\n act(() => {\n const { loadPrevious } = last(backwardUsePaginationFragmentResult);\n const disposable = loadPrevious(123);\n const query = last(activeQueries(client));\n disposable.dispose();\n expect(client.getObservableQueries().has(query.queryId)).toBeFalsy();\n });\n });\n\n it(\"cancels when unmounting\", async () => {\n await act(async () => {\n const { loadPrevious } = last(backwardUsePaginationFragmentResult);\n loadPrevious(123);\n const query = last(activeQueries(client));\n\n testRenderer.unmount();\n await new Promise((resolve) => setTimeout(resolve, 0));\n\n expect(client.getObservableQueries().has(query.queryId)).toBeFalsy();\n });\n });\n\n it(\"invokes the onComplete callback when an error occurs\", async () => {\n const onCompleted = jest.fn();\n const error = new Error(\"oh noes\");\n\n const { loadPrevious } = last(backwardUsePaginationFragmentResult);\n await act(async () => {\n loadPrevious(1, { onCompleted });\n await client.mock.rejectMostRecentOperation(error);\n });\n\n expect(onCompleted).toHaveBeenCalledWith(error);\n });\n\n describe(\"and having received the response\", () => {\n let onCompleted: jest.Mock;\n\n beforeEach(async () => {\n onCompleted = jest.fn();\n await act(() => {\n const { loadPrevious } = last(backwardUsePaginationFragmentResult);\n loadPrevious(1, { onCompleted });\n\n client.mock.resolveMostRecentOperation((operation) =>\n MockPayloadGenerator.generate(operation, {\n Node: () => ({\n id: 42,\n }),\n Message: () => ({\n id: \"second-paged-message\",\n }),\n PageInfo: () => ({\n startCursor: \"second-page-start-cursor\",\n hasPreviousPage: false,\n }),\n })\n );\n return new Promise((resolve) => setTimeout(resolve, 0));\n });\n });\n\n it(\"returns that no pagination operation is in-flight\", () => {\n const { isLoadingPrevious } = last(\n backwardUsePaginationFragmentResult\n );\n expect(isLoadingPrevious).toBeFalsy();\n });\n\n it(\"loads the new data into the store\", () => {\n expect(client.cache.extract()).toMatchObject({\n [typePolicies === typePoliciesWithDefaultApolloClientStoreKeys\n ? \"Message:second-paged-message\"\n : \"second-paged-message\"]: {\n id: \"second-paged-message\",\n __typename: \"Message\",\n text: '<mock-value-for-field-\"text\">',\n },\n });\n });\n\n it(\"returns the complete list data (previous+new) from the hook\", () => {\n const result = last(backwardUsePaginationFragmentResult);\n expect(\n (result.data as any).messages.edges.map((edge: any) => edge.node.id)\n ).toMatchInlineSnapshot(`\n Array [\n \"second-paged-message\",\n \"first-paged-message\",\n ]\n `);\n });\n\n it(\"uses the new cursor value\", () => {\n act(() => {\n const { loadPrevious } = last(backwardUsePaginationFragmentResult);\n loadPrevious(123);\n });\n\n const operation = client.mock.getMostRecentOperation();\n expect(operation.request.variables).toMatchObject({\n messagesBeforeCursor: \"second-page-start-cursor\",\n });\n });\n\n it(\"returns that no previous data is available\", () => {\n const { hasPrevious } = last(backwardUsePaginationFragmentResult);\n expect(hasPrevious).toBeFalsy();\n });\n\n it(\"invokes the onComplete callback without error\", () => {\n expect(onCompleted).toHaveBeenCalledWith(null);\n });\n });\n });\n });\n});\n\nclass ErrorBoundary extends React.Component {\n state = { hasError: false };\n\n static getDerivedStateFromError(error: Error) {\n return { hasError: true };\n }\n\n componentDidCatch(error: Error, errorInfo: any) {\n console.error({ error, errorInfo });\n }\n\n render() {\n if (this.state.hasError) {\n return <h1>Something went wrong.</h1>;\n }\n\n return this.props.children;\n }\n}\n\nfunction last<T>(list: T[]): T {\n return list[list.length - 1];\n}\n\nfunction activeQueries(client: ApolloClient<any>) {\n return Array.from(client.getObservableQueries().values());\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mBAAkB;AAClB,oBAIO;AACP,iCAIO;AACP,qBAA4B;AAC5B,4BAAwB;AACxB,gCAGO;AACP,2BAAsC;AACtC,SAAoB;AACpB,WAAsB;AAEtB,2BAOO;AACP,0BAGO;AAKP,+CAAyE;AACzE,+CAAmE;AACnE,4DAAyE;AACzE,mDAAuE;AACvE,qEAA+E;AAC/E,sEAAgF;AAGhF,MAAM,SAAS,gCACb,GAAG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from \"@apollo/client\";\nimport {\n act,\n create as createTestRenderer,\n ReactTestRenderer,\n} from \"react-test-renderer\";\nimport { buildSchema } from \"graphql\";\nimport { graphql } from \"@graphitation/graphql-js-tag\";\nimport {\n ApolloMockClient,\n createMockClient,\n} from \"@graphitation/apollo-mock-client\";\nimport * as MockPayloadGenerator from \"@graphitation/graphql-js-operation-payload-generator\";\nimport * as fs from \"fs\";\nimport * as path from \"path\";\n\nimport {\n Disposable,\n RefetchFn,\n useCompiledFragment,\n useCompiledLazyLoadQuery,\n useCompiledPaginationFragment,\n useCompiledRefetchableFragment,\n} from \"./compiledHooks\";\nimport {\n typePoliciesWithDefaultApolloClientStoreKeys,\n typePoliciesWithGlobalObjectIdStoreKeys,\n} from \"./typePolicies\";\nimport { ApolloReactRelayDuctTapeProvider } from \"../useOverridenOrDefaultApolloClient\";\n\n/**\n * NOTE: These compiler artefacts are normally imported using the transform from the createImportDocumentsTransform.ts module\n */\nimport { documents as compiledHooks_Root_executionQuery_documents } from \"./__generated__/compiledHooks_Root_executionQuery.graphql\";\nimport { documents as compiledHooks_ChildFragment_documents } from \"./__generated__/compiledHooks_ChildWatchNodeQuery.graphql\";\nimport { documents as compiledHooks_RefetchableFragment_documents } from \"./__generated__/compiledHooks_RefetchableFragment_RefetchQuery.graphql\";\nimport { documents as compiledHooks_QueryTypeFragment_documents } from \"./__generated__/compiledHooks_QueryTypeWatchNodeQuery.graphql\";\nimport { documents as compiledHooks_ForwardPaginationFragment_documents } from \"./__generated__/compiledHooks_ForwardPaginationFragment_PaginationQuery.graphql\";\nimport { documents as compiledHooks_BackwardPaginationFragment_documents } from \"./__generated__/compiledHooks_BackwardPaginationFragment_PaginationQuery.graphql\";\nimport { compiledHooks_Root_executionQueryVariables } from \"./__generated__/compiledHooks_Root_executionQuery.graphql\";\n\nconst schema = buildSchema(\n fs.readFileSync(\n path.resolve(__dirname, \"../__tests__/schema.graphql\"),\n \"utf8\"\n )\n);\n\nconst Child_fragment = graphql`\n fragment compiledHooks_ChildFragment on User {\n petName\n }\n`;\n\nconst Refetchable_fragment = graphql`\n fragment compiledHooks_RefetchableFragment on User\n @refetchable(queryName: \"compiledHooks_RefetchableFragment_RefetchQuery\") {\n petName\n avatarUrl(size: $avatarSize)\n }\n`;\n\nconst QueryType_fragment = graphql`\n fragment compiledHooks_QueryTypeFragment on Query {\n nonNode {\n id\n }\n }\n`;\n\nconst ForwardPagination_fragment = graphql`\n fragment compiledHooks_ForwardPaginationFragment on User\n @refetchable(\n queryName: \"compiledHooks_ForwardPaginationFragment_PaginationQuery\"\n )\n @argumentDefinitions(\n conversationsForwardCount: { type: \"Int!\", defaultValue: 1 }\n conversationsAfterCursor: { type: \"String!\", defaultValue: \"\" }\n ) {\n petName\n avatarUrl(size: $avatarSize)\n conversations(\n first: $conversationsForwardCount\n after: $conversationsAfterCursor\n ) @connection(key: \"compiledHooks_user_conversations\") {\n edges {\n node {\n title\n ...compiledHooks_BackwardPaginationFragment\n }\n }\n }\n }\n`;\n\nconst BackwardPagination_fragment = graphql`\n fragment compiledHooks_BackwardPaginationFragment on Conversation\n @refetchable(\n queryName: \"compiledHooks_BackwardPaginationFragment_PaginationQuery\"\n ) {\n messages(last: $messagesBackwardCount, before: $messagesBeforeCursor)\n @connection(key: \"compiledHooks_conversation_messages\") {\n edges {\n node {\n text\n }\n }\n }\n }\n`;\n\nconst Root_executionQueryDocument = graphql`\n query compiledHooks_Root_executionQuery(\n $userId: Int!\n $avatarSize: Int = 21\n $messagesBackwardCount: Int!\n $messagesBeforeCursor: String!\n ) {\n user(id: $userId) {\n name\n ...compiledHooks_ChildFragment\n ...compiledHooks_RefetchableFragment\n ...compiledHooks_ForwardPaginationFragment\n }\n ...compiledHooks_QueryTypeFragment\n }\n`;\n\ndescribe.each([\n [\n \"with default Apollo Client type-policies\",\n typePoliciesWithDefaultApolloClientStoreKeys,\n ],\n [\n \"with strict Global Object Id spec type-policies\",\n typePoliciesWithGlobalObjectIdStoreKeys,\n ],\n])(\"compiledHooks %s\", (_, typePolicies) => {\n let client: ApolloMockClient;\n let testRenderer: ReactTestRenderer;\n\n let useFragmentResult: { id: number }[];\n let useRefetchableFragmentResult: ReturnType<\n typeof useCompiledRefetchableFragment\n >[];\n let forwardUsePaginationFragmentResult: ReturnType<\n typeof useCompiledPaginationFragment\n >[];\n let backwardUsePaginationFragmentResult: ReturnType<\n typeof useCompiledPaginationFragment\n >[];\n let useLazyLoadQueryResult: { data?: any; error?: Error } | null = null;\n let componentOnQueryTypeResult: {}[];\n\n const ChildComponent: React.FC<{ user: { id: any } }> = (props) => {\n const result = useCompiledFragment(\n compiledHooks_ChildFragment_documents,\n props.user\n );\n useFragmentResult.push(result as { id: number });\n return null;\n };\n\n const ChildRefetchableComponent: React.FC<{ user: { id: any } }> = (\n props\n ) => {\n const result = useCompiledRefetchableFragment(\n compiledHooks_RefetchableFragment_documents,\n props.user\n );\n useRefetchableFragmentResult.push(result);\n return null;\n };\n\n const ComponentOnQueryType: React.FC<{ query: {} }> = (props) => {\n const result = useCompiledFragment(\n compiledHooks_QueryTypeFragment_documents,\n props.query\n );\n componentOnQueryTypeResult.push(result);\n return null;\n };\n\n const ChildForwardPaginationComponent: React.FC<{ user: { id: any } }> = (\n props\n ) => {\n const result = useCompiledPaginationFragment(\n compiledHooks_ForwardPaginationFragment_documents as any,\n props.user\n );\n forwardUsePaginationFragmentResult.push(result);\n\n return result.data.conversations.edges.map((edge: any, index: number) => {\n return (\n <ChildBackwardPaginationComponent\n conversation={edge.node}\n key={index}\n />\n );\n });\n };\n\n const ChildBackwardPaginationComponent: React.FC<{\n conversation: { id: any };\n }> = (props) => {\n const result = useCompiledPaginationFragment(\n compiledHooks_BackwardPaginationFragment_documents as any,\n props.conversation\n );\n backwardUsePaginationFragmentResult.push(result);\n return null;\n };\n\n const RootComponent: React.FC<{\n variables: compiledHooks_Root_executionQueryVariables;\n }> = (props) => {\n const result = useCompiledLazyLoadQuery(\n compiledHooks_Root_executionQuery_documents,\n { variables: props.variables }\n );\n useLazyLoadQueryResult = result;\n return result.data ? (\n <>\n <ChildComponent user={result.data.user} />\n <ChildRefetchableComponent user={result.data.user} />\n <ChildForwardPaginationComponent user={result.data.user} />\n <ComponentOnQueryType query={result.data} />\n </>\n ) : null;\n };\n\n beforeEach(() => {\n useLazyLoadQueryResult = null;\n useFragmentResult = [];\n useRefetchableFragmentResult = [];\n forwardUsePaginationFragmentResult = [];\n backwardUsePaginationFragmentResult = [];\n componentOnQueryTypeResult = [];\n client = createMockClient(schema, {\n cache: {\n possibleTypes: {\n Node: [\"User\"],\n },\n typePolicies,\n ...(typePolicies === typePoliciesWithDefaultApolloClientStoreKeys\n ? {}\n : {\n dataIdFromObject(responseObject) {\n return (\n responseObject.id?.toString() ||\n defaultDataIdFromObject(responseObject)\n );\n },\n }),\n },\n });\n act(() => {\n testRenderer = createTestRenderer(\n <ApolloReactRelayDuctTapeProvider client={client}>\n <ErrorBoundary>\n <RootComponent\n variables={{\n userId: 42,\n messagesBackwardCount: 1,\n messagesBeforeCursor: \"\",\n }}\n />\n </ErrorBoundary>\n </ApolloReactRelayDuctTapeProvider>\n );\n });\n });\n\n describe(useCompiledLazyLoadQuery, () => {\n it(\"correctly returns loading state\", async () => {\n expect(useLazyLoadQueryResult).toEqual({\n data: undefined,\n error: undefined,\n });\n await act(() =>\n client.mock.resolveMostRecentOperation((operation) =>\n MockPayloadGenerator.generate(operation)\n )\n );\n expect(useLazyLoadQueryResult).toEqual({\n data: expect.objectContaining({}),\n error: undefined,\n });\n });\n\n it(\"cancels the execution query while in-flight on unmount\", async () => {\n expect(activeQueries(client).map((query) => query.queryName)).toEqual([\n \"compiledHooks_Root_executionQuery\",\n ]);\n\n await act(async () => {\n testRenderer.unmount();\n return new Promise((resolve) => setTimeout(resolve, 0));\n });\n expect(client.getObservableQueries().size).toBe(0);\n });\n\n describe(\"once loaded\", () => {\n let executionQueryId: string;\n\n beforeEach(async () => {\n executionQueryId = last(activeQueries(client)).queryId;\n await act(() =>\n client.mock.resolveMostRecentOperation((operation) =>\n MockPayloadGenerator.generate(operation, {\n User: (options, generateId) => {\n return {\n id:\n options.parentType === \"Query\"\n ? operation.request.variables.userId\n : generateId(),\n };\n },\n Conversation: () => ({\n id: \"first-paged-conversation\",\n }),\n Message: () => ({\n id: \"first-paged-message\",\n }),\n })\n )\n );\n });\n\n it(\"unsubscribes from the execution query\", async () => {\n expect(\n activeQueries(client).map((query) => query.queryId)\n ).not.toContain(executionQueryId);\n });\n\n it(\"loads all data of the execution query into the store\", () => {\n expect(client.cache.extract()).toMatchSnapshot();\n });\n\n it(\"only returns the fields selected in the watch query to the component\", () => {\n expect(useLazyLoadQueryResult!.data).toMatchSnapshot();\n });\n\n it(\"does not re-render when a field that was not selected in the watch query is updated in the store\", async () => {\n const before = useLazyLoadQueryResult!.data;\n await act(async () => {\n client.cache.modify({\n id: \"User:42\",\n fields: {\n petName: () => \"Phoenix\",\n },\n });\n return new Promise((resolve) => setTimeout(resolve, 0));\n });\n expect(useLazyLoadQueryResult!.data).toBe(before);\n });\n\n it(\"does re-render when a field that was selected in the watch query is updated in the store\", async () => {\n const before = useLazyLoadQueryResult!.data;\n await act(async () => {\n client.cache.modify({\n id:\n typePolicies === typePoliciesWithDefaultApolloClientStoreKeys\n ? \"User:42\"\n : \"42\",\n fields: {\n name: () => \"Satya\",\n },\n });\n return new Promise((resolve) => setTimeout(resolve, 0));\n });\n expect(useLazyLoadQueryResult!.data).not.toBe(before);\n expect(useLazyLoadQueryResult!.data).toMatchSnapshot();\n });\n\n it(\"fetches new data when variables change\", async () => {\n act(() => {\n testRenderer.update(\n <ApolloReactRelayDuctTapeProvider client={client}>\n <ErrorBoundary>\n <RootComponent\n variables={{\n userId: 21,\n messagesBackwardCount: 1,\n messagesBeforeCursor: \"\",\n }}\n />\n </ErrorBoundary>\n </ApolloReactRelayDuctTapeProvider>\n );\n });\n await act(() =>\n client.mock.resolveMostRecentOperation((operation) =>\n MockPayloadGenerator.generate(operation, {\n User: () => ({ id: operation.request.variables.userId }),\n })\n )\n );\n expect(\n client.cache.extract()[\n typePolicies === typePoliciesWithDefaultApolloClientStoreKeys\n ? \"User:21\"\n : \"21\"\n ]\n ).toMatchSnapshot();\n });\n\n it(\"does not try to kick-off a new query when the variables object deep equals the previous one\", async () => {\n const spy = jest.spyOn(client, \"query\");\n await act(async () => {\n testRenderer.update(\n <ApolloReactRelayDuctTapeProvider client={client}>\n <ErrorBoundary>\n <RootComponent\n variables={{\n userId: 42,\n messagesBackwardCount: 1,\n messagesBeforeCursor: \"\",\n }}\n />\n </ErrorBoundary>\n </ApolloReactRelayDuctTapeProvider>\n );\n return new Promise((resolve) => setTimeout(resolve, 100));\n });\n expect(spy).not.toHaveBeenCalled();\n });\n\n it(\"removes all watch queries on unmount\", async () => {\n await act(async () => {\n testRenderer.unmount();\n return new Promise((resolve) => setTimeout(resolve, 0));\n });\n expect(client.getObservableQueries().size).toBe(0);\n });\n });\n });\n\n function itBehavesLikeFragment(\n returnedResults: () => { id: number }[],\n fragmentSpecificFieldSelections?: {}\n ) {\n // TODO: This should be scoped so it doesn't leak to other tests in the same parent describe\n // describe(\"behaves like useFragment\", () => {\n beforeEach(async () => {\n await act(() =>\n client.mock.resolveMostRecentOperation((operation) => {\n const result = MockPayloadGenerator.generate(operation, {\n User: () => ({\n id: 42,\n }),\n Conversation: () => ({\n id: \"first-paged-conversation\",\n }),\n Message: () => ({\n id: \"first-paged-message\",\n }),\n PageInfo: () => ({\n startCursor: \"first-page-start-cursor\",\n endCursor: \"first-page-end-cursor\",\n hasNextPage: true,\n hasPreviousPage: true,\n }),\n });\n return result;\n })\n );\n });\n\n it(\"only returns the fields selected in the watch query to the component\", () => {\n expect(last(returnedResults())).toEqual({\n __fragments: {\n avatarSize: 21,\n messagesBackwardCount: 1,\n messagesBeforeCursor: \"\",\n userId: 42,\n },\n __typename: \"User\",\n id: 42,\n petName: '<mock-value-for-field-\"petName\">',\n ...fragmentSpecificFieldSelections,\n });\n });\n\n it(\"returns the same object when a field that was not selected in the watch query is updated in the store\", async () => {\n const before = last(returnedResults());\n await act(async () => {\n client.cache.modify({\n id: \"User:42\",\n fields: {\n name: () => \"Satya\",\n },\n });\n return new Promise((resolve) => setTimeout(resolve, 0));\n });\n expect(last(returnedResults())).toBe(before);\n });\n\n it(\"returns a new object when a field that was selected in the watch query is updated in the store\", async () => {\n await act(async () => {\n client.cache.modify({\n id:\n typePolicies === typePoliciesWithDefaultApolloClientStoreKeys\n ? \"User:42\"\n : \"42\",\n fields: {\n petName: () => \"some new value\",\n },\n });\n return new Promise((resolve) => setTimeout(resolve, 0));\n });\n expect(returnedResults().length).toBe(2);\n expect(last(returnedResults())).toMatchObject({\n petName: \"some new value\",\n });\n });\n\n it(\"returns data synchronously\", () => {\n expect(returnedResults().length).toBe(1);\n });\n\n it(\"fetches new data when variables change\", async () => {\n act(() => {\n testRenderer.update(\n <ApolloReactRelayDuctTapeProvider client={client}>\n <ErrorBoundary>\n <RootComponent\n variables={{\n userId: 21,\n messagesBackwardCount: 1,\n messagesBeforeCursor: \"\",\n }}\n />\n </ErrorBoundary>\n </ApolloReactRelayDuctTapeProvider>\n );\n });\n await act(() =>\n client.mock.resolveMostRecentOperation((operation) =>\n MockPayloadGenerator.generate(operation, {\n User: () => ({ id: operation.request.variables.userId }),\n })\n )\n );\n expect(last(returnedResults()).id).toBe(21);\n });\n // });\n }\n\n describe(useCompiledFragment, () => {\n itBehavesLikeFragment(() => useFragmentResult, {\n petName: '<mock-value-for-field-\"petName\">',\n });\n\n it(\"also works with fragments on the Query type\", () => {\n expect(last(componentOnQueryTypeResult)).toMatchInlineSnapshot(`\n Object {\n \"__fragments\": Object {\n \"avatarSize\": 21,\n \"messagesBackwardCount\": 1,\n \"messagesBeforeCursor\": \"\",\n \"userId\": 42,\n },\n \"nonNode\": Object {\n \"__typename\": \"NonNode\",\n \"id\": \"<mock-value-for-field-\\\\\"id\\\\\">\",\n },\n }\n `);\n });\n });\n\n function itBehavesLikeRefetchableFragment(\n returnedResults: () => [data: { id: number }, refetch: RefetchFn][]\n ) {\n it.todo(\n \"supports variables with default values on either operations or with @argumentDefinitions\"\n );\n\n describe(\"when refetching\", () => {\n let onCompleted: jest.Mock;\n let disposable: Disposable;\n\n beforeEach(() => {\n const [_data, refetch] = last(returnedResults());\n onCompleted = jest.fn();\n disposable = refetch({ avatarSize: 42 }, { onCompleted });\n });\n\n it(\"can be cancelled\", () => {\n const query = last(activeQueries(client));\n disposable.dispose();\n expect(client.getObservableQueries().has(query.queryId)).toBeFalsy();\n });\n\n it(\"cancels when unmounting\", async () => {\n await act(async () => {\n const query = last(activeQueries(client));\n testRenderer.unmount();\n await new Promise((resolve) => setTimeout(resolve, 0));\n expect(client.getObservableQueries().has(query.queryId)).toBeFalsy();\n });\n });\n\n describe(\"successfully\", () => {\n beforeEach(async () => {\n await act(() => {\n client.mock.resolveMostRecentOperation((operation) =>\n MockPayloadGenerator.generate(operation, {\n Node: () => ({\n id: 42,\n avatarUrl: `avatarUrl-with-size-${operation.request.variables.avatarSize}`,\n }),\n })\n );\n return new Promise((resolve) => setTimeout(resolve, 0));\n });\n });\n\n it(\"returns a new object from the hook\", () => {\n expect(last(returnedResults())[0]).toMatchObject({\n __typename: \"User\",\n avatarUrl: \"avatarUrl-with-size-42\",\n id: 42,\n });\n });\n\n it(\"updates the fragment reference request variables for future requests\", () => {\n expect(last(returnedResults())[0]).toMatchObject({\n __fragments: {\n avatarSize: 42,\n userId: 42,\n },\n });\n });\n\n it(\"invokes the onComplete callback without error\", () => {\n expect(onCompleted).toHaveBeenCalledWith(null);\n });\n });\n\n describe(\"and an error occurs\", () => {\n const error = new Error(\"oh noes\");\n\n beforeEach(async () => {\n await act(() => client.mock.rejectMostRecentOperation(error));\n });\n\n it(\"invokes the onComplete callback when an error occurs\", () => {\n expect(onCompleted).toHaveBeenCalledWith(error);\n });\n\n it(\"does not update the fragment reference request variables for future requests\", async () => {\n const [_data, refetch] = last(returnedResults());\n refetch({});\n expect(\n client.mock.getMostRecentOperation().request.variables.avatarSize\n ).toBe(21);\n });\n });\n });\n }\n\n describe(useCompiledRefetchableFragment, () => {\n itBehavesLikeFragment(\n () =>\n useRefetchableFragmentResult.map(\n ([data, _refetch]) => data as { id: number }\n ),\n { avatarUrl: '<mock-value-for-field-\"avatarUrl\">' }\n );\n\n itBehavesLikeRefetchableFragment(\n () =>\n useRefetchableFragmentResult as [\n data: { id: number },\n refetch: RefetchFn\n ][]\n );\n });\n\n describe(useCompiledPaginationFragment, () => {\n itBehavesLikeFragment(\n () =>\n forwardUsePaginationFragmentResult.map(\n ({ data }) => data as { id: number }\n ),\n {\n avatarUrl: '<mock-value-for-field-\"avatarUrl\">',\n conversations: {\n __typename: \"ConversationsConnection\",\n edges: [\n {\n __typename: \"ConversationsConnectionEdge\",\n cursor: '<mock-value-for-field-\"cursor\">',\n node: {\n __fragments: {\n avatarSize: 21,\n messagesBackwardCount: 1,\n messagesBeforeCursor: \"\",\n userId: 42,\n },\n __typename: \"Conversation\",\n id: \"first-paged-conversation\",\n title: '<mock-value-for-field-\"title\">',\n },\n },\n ],\n pageInfo: {\n __typename: \"PageInfo\",\n endCursor: \"first-page-end-cursor\",\n hasNextPage: true,\n },\n },\n }\n );\n\n itBehavesLikeRefetchableFragment(() =>\n forwardUsePaginationFragmentResult.map(({ data, refetch }) => [\n data as { id: number },\n refetch,\n ])\n );\n\n describe(\"when paginating forward\", () => {\n it(\"returns that next data is available\", () => {\n const { hasNext } = last(forwardUsePaginationFragmentResult);\n expect(hasNext).toBeTruthy();\n });\n\n it(\"uses the correct count and cursor values\", () => {\n act(() => {\n const { loadNext } = last(forwardUsePaginationFragmentResult);\n loadNext(123);\n });\n\n const operation = client.mock.getMostRecentOperation();\n expect(operation.request.variables).toMatchObject({\n conversationsForwardCount: 123,\n conversationsAfterCursor: \"first-page-end-cursor\",\n });\n });\n\n it(\"returns that a pagination operation is in-flight\", () => {\n act(() => {\n const { loadNext } = last(forwardUsePaginationFragmentResult);\n loadNext(123);\n });\n const { isLoadingNext } = last(forwardUsePaginationFragmentResult);\n expect(isLoadingNext).toBeTruthy();\n });\n\n it(\"can be cancelled\", () => {\n act(() => {\n const { loadNext } = last(forwardUsePaginationFragmentResult);\n const disposable = loadNext(123);\n const query = last(activeQueries(client));\n disposable.dispose();\n expect(client.getObservableQueries().has(query.queryId)).toBeFalsy();\n });\n });\n\n it(\"cancels when unmounting\", async () => {\n await act(async () => {\n const { loadNext } = last(forwardUsePaginationFragmentResult);\n loadNext(123);\n const query = last(activeQueries(client));\n\n testRenderer.unmount();\n await new Promise((resolve) => setTimeout(resolve, 0));\n\n expect(client.getObservableQueries().has(query.queryId)).toBeFalsy();\n });\n });\n\n it(\"invokes the onComplete callback when an error occurs\", async () => {\n const onCompleted = jest.fn();\n const error = new Error(\"oh noes\");\n\n const { loadNext } = last(forwardUsePaginationFragmentResult);\n await act(async () => {\n loadNext(1, { onCompleted });\n await client.mock.rejectMostRecentOperation(error);\n });\n\n expect(onCompleted).toHaveBeenCalledWith(error);\n });\n\n describe(\"and having received the response\", () => {\n let onCompleted: jest.Mock;\n\n beforeEach(async () => {\n onCompleted = jest.fn();\n await act(async () => {\n const { loadNext } = last(forwardUsePaginationFragmentResult);\n loadNext(1, { onCompleted });\n\n // Introduce a slight delay before resolving the request as a\n // regression test with a pagination requst being disposed early.\n await new Promise((resolve) => setTimeout(resolve, 0));\n\n client.mock.resolveMostRecentOperation((operation) =>\n MockPayloadGenerator.generate(operation, {\n Node: () => ({\n id: 42,\n }),\n Conversation: () => ({\n id: \"second-paged-conversation\",\n }),\n PageInfo: () => ({\n endCursor: \"second-page-end-cursor\",\n hasNextPage: false,\n }),\n })\n );\n return new Promise((resolve) => setTimeout(resolve, 0));\n });\n });\n\n it(\"returns that no pagination operation is in-flight\", () => {\n const { isLoadingNext } = last(forwardUsePaginationFragmentResult);\n expect(isLoadingNext).toBeFalsy();\n });\n\n it(\"loads the new data into the store\", () => {\n expect(client.cache.extract()).toMatchObject({\n [typePolicies === typePoliciesWithDefaultApolloClientStoreKeys\n ? \"Conversation:second-paged-conversation\"\n : \"second-paged-conversation\"]: {\n id: \"second-paged-conversation\",\n __typename: \"Conversation\",\n title: '<mock-value-for-field-\"title\">',\n },\n });\n });\n\n it(\"returns the complete list data (previous+new) from the hook\", () => {\n const result = last(forwardUsePaginationFragmentResult);\n expect(\n (result.data as any).conversations.edges.map(\n (edge: any) => edge.node.id\n )\n ).toMatchInlineSnapshot(`\n Array [\n \"first-paged-conversation\",\n \"second-paged-conversation\",\n ]\n `);\n });\n\n it(\"uses the new cursor value\", () => {\n act(() => {\n const { loadNext } = last(forwardUsePaginationFragmentResult);\n loadNext(123);\n });\n\n const operation = client.mock.getMostRecentOperation();\n expect(operation.request.variables).toMatchObject({\n conversationsAfterCursor: \"second-page-end-cursor\",\n });\n });\n\n it(\"returns that no next data is available\", () => {\n const { hasNext } = last(forwardUsePaginationFragmentResult);\n expect(hasNext).toBeFalsy();\n });\n\n it(\"invokes the onComplete callback without error\", () => {\n expect(onCompleted).toHaveBeenCalledWith(null);\n });\n });\n });\n\n describe(\"when paginating backward\", () => {\n it(\"returns that previous data is available\", () => {\n const { hasPrevious } = last(backwardUsePaginationFragmentResult);\n expect(hasPrevious).toBeTruthy();\n });\n\n it(\"uses the correct count and cursor values\", () => {\n act(() => {\n const { loadPrevious } = last(backwardUsePaginationFragmentResult);\n loadPrevious(123);\n });\n\n const operation = client.mock.getMostRecentOperation();\n expect(operation.request.variables).toMatchObject({\n messagesBackwardCount: 123,\n messagesBeforeCursor: \"first-page-start-cursor\",\n });\n });\n\n it(\"returns that a pagination operation is in-flight\", () => {\n act(() => {\n const { loadPrevious } = last(backwardUsePaginationFragmentResult);\n loadPrevious(123);\n });\n const { isLoadingPrevious } = last(backwardUsePaginationFragmentResult);\n expect(isLoadingPrevious).toBeTruthy();\n });\n\n it(\"can be cancelled\", () => {\n act(() => {\n const { loadPrevious } = last(backwardUsePaginationFragmentResult);\n const disposable = loadPrevious(123);\n const query = last(activeQueries(client));\n disposable.dispose();\n expect(client.getObservableQueries().has(query.queryId)).toBeFalsy();\n });\n });\n\n it(\"cancels when unmounting\", async () => {\n await act(async () => {\n const { loadPrevious } = last(backwardUsePaginationFragmentResult);\n loadPrevious(123);\n const query = last(activeQueries(client));\n\n testRenderer.unmount();\n await new Promise((resolve) => setTimeout(resolve, 0));\n\n expect(client.getObservableQueries().has(query.queryId)).toBeFalsy();\n });\n });\n\n it(\"invokes the onComplete callback when an error occurs\", async () => {\n const onCompleted = jest.fn();\n const error = new Error(\"oh noes\");\n\n const { loadPrevious } = last(backwardUsePaginationFragmentResult);\n await act(async () => {\n loadPrevious(1, { onCompleted });\n await client.mock.rejectMostRecentOperation(error);\n });\n\n expect(onCompleted).toHaveBeenCalledWith(error);\n });\n\n describe(\"and having received the response\", () => {\n let onCompleted: jest.Mock;\n\n beforeEach(async () => {\n onCompleted = jest.fn();\n await act(() => {\n const { loadPrevious } = last(backwardUsePaginationFragmentResult);\n loadPrevious(1, { onCompleted });\n\n client.mock.resolveMostRecentOperation((operation) =>\n MockPayloadGenerator.generate(operation, {\n Node: () => ({\n id: 42,\n }),\n Message: () => ({\n id: \"second-paged-message\",\n }),\n PageInfo: () => ({\n startCursor: \"second-page-start-cursor\",\n hasPreviousPage: false,\n }),\n })\n );\n return new Promise((resolve) => setTimeout(resolve, 0));\n });\n });\n\n it(\"returns that no pagination operation is in-flight\", () => {\n const { isLoadingPrevious } = last(\n backwardUsePaginationFragmentResult\n );\n expect(isLoadingPrevious).toBeFalsy();\n });\n\n it(\"loads the new data into the store\", () => {\n expect(client.cache.extract()).toMatchObject({\n [typePolicies === typePoliciesWithDefaultApolloClientStoreKeys\n ? \"Message:second-paged-message\"\n : \"second-paged-message\"]: {\n id: \"second-paged-message\",\n __typename: \"Message\",\n text: '<mock-value-for-field-\"text\">',\n },\n });\n });\n\n it(\"returns the complete list data (previous+new) from the hook\", () => {\n const result = last(backwardUsePaginationFragmentResult);\n expect(\n (result.data as any).messages.edges.map((edge: any) => edge.node.id)\n ).toMatchInlineSnapshot(`\n Array [\n \"second-paged-message\",\n \"first-paged-message\",\n ]\n `);\n });\n\n it(\"uses the new cursor value\", () => {\n act(() => {\n const { loadPrevious } = last(backwardUsePaginationFragmentResult);\n loadPrevious(123);\n });\n\n const operation = client.mock.getMostRecentOperation();\n expect(operation.request.variables).toMatchObject({\n messagesBeforeCursor: \"second-page-start-cursor\",\n });\n });\n\n it(\"returns that no previous data is available\", () => {\n const { hasPrevious } = last(backwardUsePaginationFragmentResult);\n expect(hasPrevious).toBeFalsy();\n });\n\n it(\"invokes the onComplete callback without error\", () => {\n expect(onCompleted).toHaveBeenCalledWith(null);\n });\n });\n });\n });\n});\n\nclass ErrorBoundary extends React.Component {\n state = { hasError: false };\n\n static getDerivedStateFromError(error: Error) {\n return { hasError: true };\n }\n\n componentDidCatch(error: Error, errorInfo: any) {\n console.error({ error, errorInfo });\n }\n\n render() {\n if (this.state.hasError) {\n return <h1>Something went wrong.</h1>;\n }\n\n return this.props.children;\n }\n}\n\nfunction last<T>(list: T[]): T {\n return list[list.length - 1];\n}\n\nfunction activeQueries(client: ApolloClient<any>) {\n return Array.from(client.getObservableQueries().values());\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mBAAkB;AAClB,oBAAsD;AACtD,iCAIO;AACP,qBAA4B;AAC5B,4BAAwB;AACxB,gCAGO;AACP,2BAAsC;AACtC,SAAoB;AACpB,WAAsB;AAEtB,2BAOO;AACP,0BAGO;AACP,+CAAiD;AAKjD,+CAAyE;AACzE,+CAAmE;AACnE,4DAAyE;AACzE,mDAAuE;AACvE,qEAA+E;AAC/E,sEAAgF;AAGhF,MAAM,SAAS,gCACb,GAAG,aACD,KAAK,QAAQ,WAAW,gCACxB;AAIJ,MAAM,iBAAiB;AAAA;AAAA;AAAA;AAAA;AAMvB,MAAM,uBAAuB;AAAA;AAAA;AAAA;AAAA;AAAA;AA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Z,MAAM;AAAA;AAAA;AAAA;AAKZ,WAAG,+DAA+D,MAAM;AACtE,gBAAM,SAAS,KAAK;AACpB,iBACG,OAAO,KAAa,SAAS,MAAM,IAAI,CAAC,SAAc,KAAK,KAAK,KACjE,sBAAsB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQ1B,WAAG,6BAA6B,MAAM;AACpC,8CAAI,MAAM;AACR,kBAAM,CAAE,gBAAiB,KAAK;AAC9B,yBAAa;AAAA;AAGf,gBAAM,YAAY,OAAO,KAAK;AAC9B,iBAAO,UAAU,QAAQ,WAAW,cAAc;AAAA,YAChD,sBAAsB;AAAA;AAAA;AAI1B,WAAG,8CAA8C,MAAM;AACrD,gBAAM,CAAE,eAAgB,KAAK;AAC7B,iBAAO,aAAa;AAAA;AAGtB,WAAG,iDAAiD,MAAM;AACxD,iBAAO,aAAa,qBAAqB;AAAA;AAAA;AAAA;AAAA;AAAA;AAOnD,4BAA4B,qBAAM,UAAU;AAAA,EAA5C,cA7/BA;AA6/BA;AACE,iBAAQ,CAAE,UAAU;AAAA;AAAA,SAEb,yBAAyB,OAAc;AAC5C,WAAO,CAAE,UAAU;AAAA;AAAA,EAGrB,kBAAkB,OAAc,WAAgB;AAC9C,YAAQ,MAAM,CAAE,OAAO;AAAA;AAAA,EAGzB,SAAS;AACP,QAAI,KAAK,MAAM,UAAU;AACvB,aAAO,mDAAC,MAAD,MAAI;AAAA;AAGb,WAAO,KAAK,MAAM;AAAA;AAAA;AAItB,cAAiB,MAAc;AAC7B,SAAO,KAAK,KAAK,SAAS;AAAA;AAG5B,uBAAuB,QAA2B;AAChD,SAAO,MAAM,KAAK,OAAO,uBAAuB;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -37,10 +37,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
37
37
|
|
|
38
38
|
// src/storeObservation/compiledHooks.test.tsx
|
|
39
39
|
import React from "react";
|
|
40
|
-
import {
|
|
41
|
-
ApolloProvider,
|
|
42
|
-
defaultDataIdFromObject
|
|
43
|
-
} from "@apollo/client";
|
|
40
|
+
import {defaultDataIdFromObject} from "@apollo/client";
|
|
44
41
|
import {
|
|
45
42
|
act,
|
|
46
43
|
create as createTestRenderer
|
|
@@ -69,6 +66,7 @@ import {
|
|
|
69
66
|
typePoliciesWithDefaultApolloClientStoreKeys,
|
|
70
67
|
typePoliciesWithGlobalObjectIdStoreKeys
|
|
71
68
|
} from "./typePolicies.mjs";
|
|
69
|
+
import {ApolloReactRelayDuctTapeProvider} from "../useOverridenOrDefaultApolloClient.mjs";
|
|
72
70
|
import {documents as compiledHooks_Root_executionQuery_documents} from "./__generated__/compiledHooks_Root_executionQuery.graphql.mjs";
|
|
73
71
|
import {documents as compiledHooks_ChildFragment_documents} from "./__generated__/compiledHooks_ChildWatchNodeQuery.graphql.mjs";
|
|
74
72
|
import {documents as compiledHooks_RefetchableFragment_documents} from "./__generated__/compiledHooks_RefetchableFragment_RefetchQuery.graphql.mjs";
|
|
@@ -232,7 +230,7 @@ describe.each([
|
|
|
232
230
|
})
|
|
233
231
|
});
|
|
234
232
|
act(() => {
|
|
235
|
-
testRenderer = createTestRenderer(/* @__PURE__ */ React.createElement(
|
|
233
|
+
testRenderer = createTestRenderer(/* @__PURE__ */ React.createElement(ApolloReactRelayDuctTapeProvider, {
|
|
236
234
|
client
|
|
237
235
|
}, /* @__PURE__ */ React.createElement(ErrorBoundary, null, /* @__PURE__ */ React.createElement(RootComponent, {
|
|
238
236
|
variables: {
|
|
@@ -321,7 +319,7 @@ describe.each([
|
|
|
321
319
|
}));
|
|
322
320
|
it("fetches new data when variables change", () => __async(void 0, null, function* () {
|
|
323
321
|
act(() => {
|
|
324
|
-
testRenderer.update(/* @__PURE__ */ React.createElement(
|
|
322
|
+
testRenderer.update(/* @__PURE__ */ React.createElement(ApolloReactRelayDuctTapeProvider, {
|
|
325
323
|
client
|
|
326
324
|
}, /* @__PURE__ */ React.createElement(ErrorBoundary, null, /* @__PURE__ */ React.createElement(RootComponent, {
|
|
327
325
|
variables: {
|
|
@@ -339,7 +337,7 @@ describe.each([
|
|
|
339
337
|
it("does not try to kick-off a new query when the variables object deep equals the previous one", () => __async(void 0, null, function* () {
|
|
340
338
|
const spy = jest.spyOn(client, "query");
|
|
341
339
|
yield act(() => __async(void 0, null, function* () {
|
|
342
|
-
testRenderer.update(/* @__PURE__ */ React.createElement(
|
|
340
|
+
testRenderer.update(/* @__PURE__ */ React.createElement(ApolloReactRelayDuctTapeProvider, {
|
|
343
341
|
client
|
|
344
342
|
}, /* @__PURE__ */ React.createElement(ErrorBoundary, null, /* @__PURE__ */ React.createElement(RootComponent, {
|
|
345
343
|
variables: {
|
|
@@ -430,7 +428,7 @@ describe.each([
|
|
|
430
428
|
});
|
|
431
429
|
it("fetches new data when variables change", () => __async(this, null, function* () {
|
|
432
430
|
act(() => {
|
|
433
|
-
testRenderer.update(/* @__PURE__ */ React.createElement(
|
|
431
|
+
testRenderer.update(/* @__PURE__ */ React.createElement(ApolloReactRelayDuctTapeProvider, {
|
|
434
432
|
client
|
|
435
433
|
}, /* @__PURE__ */ React.createElement(ErrorBoundary, null, /* @__PURE__ */ React.createElement(RootComponent, {
|
|
436
434
|
variables: {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/storeObservation/compiledHooks.test.tsx"],
|
|
4
|
-
"sourcesContent": ["import React from \"react\";\nimport {\n ApolloClient,\n ApolloProvider,\n defaultDataIdFromObject,\n} from \"@apollo/client\";\nimport {\n act,\n create as createTestRenderer,\n ReactTestRenderer,\n} from \"react-test-renderer\";\nimport { buildSchema } from \"graphql\";\nimport { graphql } from \"@graphitation/graphql-js-tag\";\nimport {\n ApolloMockClient,\n createMockClient,\n} from \"@graphitation/apollo-mock-client\";\nimport * as MockPayloadGenerator from \"@graphitation/graphql-js-operation-payload-generator\";\nimport * as fs from \"fs\";\nimport * as path from \"path\";\n\nimport {\n Disposable,\n RefetchFn,\n useCompiledFragment,\n useCompiledLazyLoadQuery,\n useCompiledPaginationFragment,\n useCompiledRefetchableFragment,\n} from \"./compiledHooks\";\nimport {\n typePoliciesWithDefaultApolloClientStoreKeys,\n typePoliciesWithGlobalObjectIdStoreKeys,\n} from \"./typePolicies\";\n\n/**\n * NOTE: These compiler artefacts are normally imported using the transform from the createImportDocumentsTransform.ts module\n */\nimport { documents as compiledHooks_Root_executionQuery_documents } from \"./__generated__/compiledHooks_Root_executionQuery.graphql\";\nimport { documents as compiledHooks_ChildFragment_documents } from \"./__generated__/compiledHooks_ChildWatchNodeQuery.graphql\";\nimport { documents as compiledHooks_RefetchableFragment_documents } from \"./__generated__/compiledHooks_RefetchableFragment_RefetchQuery.graphql\";\nimport { documents as compiledHooks_QueryTypeFragment_documents } from \"./__generated__/compiledHooks_QueryTypeWatchNodeQuery.graphql\";\nimport { documents as compiledHooks_ForwardPaginationFragment_documents } from \"./__generated__/compiledHooks_ForwardPaginationFragment_PaginationQuery.graphql\";\nimport { documents as compiledHooks_BackwardPaginationFragment_documents } from \"./__generated__/compiledHooks_BackwardPaginationFragment_PaginationQuery.graphql\";\nimport { compiledHooks_Root_executionQueryVariables } from \"./__generated__/compiledHooks_Root_executionQuery.graphql\";\n\nconst schema = buildSchema(\n fs.readFileSync(\n path.resolve(__dirname, \"../__tests__/schema.graphql\"),\n \"utf8\"\n )\n);\n\nconst Child_fragment = graphql`\n fragment compiledHooks_ChildFragment on User {\n petName\n }\n`;\n\nconst Refetchable_fragment = graphql`\n fragment compiledHooks_RefetchableFragment on User\n @refetchable(queryName: \"compiledHooks_RefetchableFragment_RefetchQuery\") {\n petName\n avatarUrl(size: $avatarSize)\n }\n`;\n\nconst QueryType_fragment = graphql`\n fragment compiledHooks_QueryTypeFragment on Query {\n nonNode {\n id\n }\n }\n`;\n\nconst ForwardPagination_fragment = graphql`\n fragment compiledHooks_ForwardPaginationFragment on User\n @refetchable(\n queryName: \"compiledHooks_ForwardPaginationFragment_PaginationQuery\"\n )\n @argumentDefinitions(\n conversationsForwardCount: { type: \"Int!\", defaultValue: 1 }\n conversationsAfterCursor: { type: \"String!\", defaultValue: \"\" }\n ) {\n petName\n avatarUrl(size: $avatarSize)\n conversations(\n first: $conversationsForwardCount\n after: $conversationsAfterCursor\n ) @connection(key: \"compiledHooks_user_conversations\") {\n edges {\n node {\n title\n ...compiledHooks_BackwardPaginationFragment\n }\n }\n }\n }\n`;\n\nconst BackwardPagination_fragment = graphql`\n fragment compiledHooks_BackwardPaginationFragment on Conversation\n @refetchable(\n queryName: \"compiledHooks_BackwardPaginationFragment_PaginationQuery\"\n ) {\n messages(last: $messagesBackwardCount, before: $messagesBeforeCursor)\n @connection(key: \"compiledHooks_conversation_messages\") {\n edges {\n node {\n text\n }\n }\n }\n }\n`;\n\nconst Root_executionQueryDocument = graphql`\n query compiledHooks_Root_executionQuery(\n $userId: Int!\n $avatarSize: Int = 21\n $messagesBackwardCount: Int!\n $messagesBeforeCursor: String!\n ) {\n user(id: $userId) {\n name\n ...compiledHooks_ChildFragment\n ...compiledHooks_RefetchableFragment\n ...compiledHooks_ForwardPaginationFragment\n }\n ...compiledHooks_QueryTypeFragment\n }\n`;\n\ndescribe.each([\n [\n \"with default Apollo Client type-policies\",\n typePoliciesWithDefaultApolloClientStoreKeys,\n ],\n [\n \"with strict Global Object Id spec type-policies\",\n typePoliciesWithGlobalObjectIdStoreKeys,\n ],\n])(\"compiledHooks %s\", (_, typePolicies) => {\n let client: ApolloMockClient;\n let testRenderer: ReactTestRenderer;\n\n let useFragmentResult: { id: number }[];\n let useRefetchableFragmentResult: ReturnType<\n typeof useCompiledRefetchableFragment\n >[];\n let forwardUsePaginationFragmentResult: ReturnType<\n typeof useCompiledPaginationFragment\n >[];\n let backwardUsePaginationFragmentResult: ReturnType<\n typeof useCompiledPaginationFragment\n >[];\n let useLazyLoadQueryResult: { data?: any; error?: Error } | null = null;\n let componentOnQueryTypeResult: {}[];\n\n const ChildComponent: React.FC<{ user: { id: any } }> = (props) => {\n const result = useCompiledFragment(\n compiledHooks_ChildFragment_documents,\n props.user\n );\n useFragmentResult.push(result as { id: number });\n return null;\n };\n\n const ChildRefetchableComponent: React.FC<{ user: { id: any } }> = (\n props\n ) => {\n const result = useCompiledRefetchableFragment(\n compiledHooks_RefetchableFragment_documents,\n props.user\n );\n useRefetchableFragmentResult.push(result);\n return null;\n };\n\n const ComponentOnQueryType: React.FC<{ query: {} }> = (props) => {\n const result = useCompiledFragment(\n compiledHooks_QueryTypeFragment_documents,\n props.query\n );\n componentOnQueryTypeResult.push(result);\n return null;\n };\n\n const ChildForwardPaginationComponent: React.FC<{ user: { id: any } }> = (\n props\n ) => {\n const result = useCompiledPaginationFragment(\n compiledHooks_ForwardPaginationFragment_documents as any,\n props.user\n );\n forwardUsePaginationFragmentResult.push(result);\n\n return result.data.conversations.edges.map((edge: any, index: number) => {\n return (\n <ChildBackwardPaginationComponent\n conversation={edge.node}\n key={index}\n />\n );\n });\n };\n\n const ChildBackwardPaginationComponent: React.FC<{\n conversation: { id: any };\n }> = (props) => {\n const result = useCompiledPaginationFragment(\n compiledHooks_BackwardPaginationFragment_documents as any,\n props.conversation\n );\n backwardUsePaginationFragmentResult.push(result);\n return null;\n };\n\n const RootComponent: React.FC<{\n variables: compiledHooks_Root_executionQueryVariables;\n }> = (props) => {\n const result = useCompiledLazyLoadQuery(\n compiledHooks_Root_executionQuery_documents,\n { variables: props.variables }\n );\n useLazyLoadQueryResult = result;\n return result.data ? (\n <>\n <ChildComponent user={result.data.user} />\n <ChildRefetchableComponent user={result.data.user} />\n <ChildForwardPaginationComponent user={result.data.user} />\n <ComponentOnQueryType query={result.data} />\n </>\n ) : null;\n };\n\n beforeEach(() => {\n useLazyLoadQueryResult = null;\n useFragmentResult = [];\n useRefetchableFragmentResult = [];\n forwardUsePaginationFragmentResult = [];\n backwardUsePaginationFragmentResult = [];\n componentOnQueryTypeResult = [];\n client = createMockClient(schema, {\n cache: {\n possibleTypes: {\n Node: [\"User\"],\n },\n typePolicies,\n ...(typePolicies === typePoliciesWithDefaultApolloClientStoreKeys\n ? {}\n : {\n dataIdFromObject(responseObject) {\n return (\n responseObject.id?.toString() ||\n defaultDataIdFromObject(responseObject)\n );\n },\n }),\n },\n });\n act(() => {\n testRenderer = createTestRenderer(\n <ApolloProvider client={client}>\n <ErrorBoundary>\n <RootComponent\n variables={{\n userId: 42,\n messagesBackwardCount: 1,\n messagesBeforeCursor: \"\",\n }}\n />\n </ErrorBoundary>\n </ApolloProvider>\n );\n });\n });\n\n describe(useCompiledLazyLoadQuery, () => {\n it(\"correctly returns loading state\", async () => {\n expect(useLazyLoadQueryResult).toEqual({\n data: undefined,\n error: undefined,\n });\n await act(() =>\n client.mock.resolveMostRecentOperation((operation) =>\n MockPayloadGenerator.generate(operation)\n )\n );\n expect(useLazyLoadQueryResult).toEqual({\n data: expect.objectContaining({}),\n error: undefined,\n });\n });\n\n it(\"cancels the execution query while in-flight on unmount\", async () => {\n expect(activeQueries(client).map((query) => query.queryName)).toEqual([\n \"compiledHooks_Root_executionQuery\",\n ]);\n\n await act(async () => {\n testRenderer.unmount();\n return new Promise((resolve) => setTimeout(resolve, 0));\n });\n expect(client.getObservableQueries().size).toBe(0);\n });\n\n describe(\"once loaded\", () => {\n let executionQueryId: string;\n\n beforeEach(async () => {\n executionQueryId = last(activeQueries(client)).queryId;\n await act(() =>\n client.mock.resolveMostRecentOperation((operation) =>\n MockPayloadGenerator.generate(operation, {\n User: (options, generateId) => {\n return {\n id:\n options.parentType === \"Query\"\n ? operation.request.variables.userId\n : generateId(),\n };\n },\n Conversation: () => ({\n id: \"first-paged-conversation\",\n }),\n Message: () => ({\n id: \"first-paged-message\",\n }),\n })\n )\n );\n });\n\n it(\"unsubscribes from the execution query\", async () => {\n expect(\n activeQueries(client).map((query) => query.queryId)\n ).not.toContain(executionQueryId);\n });\n\n it(\"loads all data of the execution query into the store\", () => {\n expect(client.cache.extract()).toMatchSnapshot();\n });\n\n it(\"only returns the fields selected in the watch query to the component\", () => {\n expect(useLazyLoadQueryResult!.data).toMatchSnapshot();\n });\n\n it(\"does not re-render when a field that was not selected in the watch query is updated in the store\", async () => {\n const before = useLazyLoadQueryResult!.data;\n await act(async () => {\n client.cache.modify({\n id: \"User:42\",\n fields: {\n petName: () => \"Phoenix\",\n },\n });\n return new Promise((resolve) => setTimeout(resolve, 0));\n });\n expect(useLazyLoadQueryResult!.data).toBe(before);\n });\n\n it(\"does re-render when a field that was selected in the watch query is updated in the store\", async () => {\n const before = useLazyLoadQueryResult!.data;\n await act(async () => {\n client.cache.modify({\n id:\n typePolicies === typePoliciesWithDefaultApolloClientStoreKeys\n ? \"User:42\"\n : \"42\",\n fields: {\n name: () => \"Satya\",\n },\n });\n return new Promise((resolve) => setTimeout(resolve, 0));\n });\n expect(useLazyLoadQueryResult!.data).not.toBe(before);\n expect(useLazyLoadQueryResult!.data).toMatchSnapshot();\n });\n\n it(\"fetches new data when variables change\", async () => {\n act(() => {\n testRenderer.update(\n <ApolloProvider client={client}>\n <ErrorBoundary>\n <RootComponent\n variables={{\n userId: 21,\n messagesBackwardCount: 1,\n messagesBeforeCursor: \"\",\n }}\n />\n </ErrorBoundary>\n </ApolloProvider>\n );\n });\n await act(() =>\n client.mock.resolveMostRecentOperation((operation) =>\n MockPayloadGenerator.generate(operation, {\n User: () => ({ id: operation.request.variables.userId }),\n })\n )\n );\n expect(\n client.cache.extract()[\n typePolicies === typePoliciesWithDefaultApolloClientStoreKeys\n ? \"User:21\"\n : \"21\"\n ]\n ).toMatchSnapshot();\n });\n\n it(\"does not try to kick-off a new query when the variables object deep equals the previous one\", async () => {\n const spy = jest.spyOn(client, \"query\");\n await act(async () => {\n testRenderer.update(\n <ApolloProvider client={client}>\n <ErrorBoundary>\n <RootComponent\n variables={{\n userId: 42,\n messagesBackwardCount: 1,\n messagesBeforeCursor: \"\",\n }}\n />\n </ErrorBoundary>\n </ApolloProvider>\n );\n return new Promise((resolve) => setTimeout(resolve, 100));\n });\n expect(spy).not.toHaveBeenCalled();\n });\n\n it(\"removes all watch queries on unmount\", async () => {\n await act(async () => {\n testRenderer.unmount();\n return new Promise((resolve) => setTimeout(resolve, 0));\n });\n expect(client.getObservableQueries().size).toBe(0);\n });\n });\n });\n\n function itBehavesLikeFragment(\n returnedResults: () => { id: number }[],\n fragmentSpecificFieldSelections?: {}\n ) {\n // TODO: This should be scoped so it doesn't leak to other tests in the same parent describe\n // describe(\"behaves like useFragment\", () => {\n beforeEach(async () => {\n await act(() =>\n client.mock.resolveMostRecentOperation((operation) => {\n const result = MockPayloadGenerator.generate(operation, {\n User: () => ({\n id: 42,\n }),\n Conversation: () => ({\n id: \"first-paged-conversation\",\n }),\n Message: () => ({\n id: \"first-paged-message\",\n }),\n PageInfo: () => ({\n startCursor: \"first-page-start-cursor\",\n endCursor: \"first-page-end-cursor\",\n hasNextPage: true,\n hasPreviousPage: true,\n }),\n });\n return result;\n })\n );\n });\n\n it(\"only returns the fields selected in the watch query to the component\", () => {\n expect(last(returnedResults())).toEqual({\n __fragments: {\n avatarSize: 21,\n messagesBackwardCount: 1,\n messagesBeforeCursor: \"\",\n userId: 42,\n },\n __typename: \"User\",\n id: 42,\n petName: '<mock-value-for-field-\"petName\">',\n ...fragmentSpecificFieldSelections,\n });\n });\n\n it(\"returns the same object when a field that was not selected in the watch query is updated in the store\", async () => {\n const before = last(returnedResults());\n await act(async () => {\n client.cache.modify({\n id: \"User:42\",\n fields: {\n name: () => \"Satya\",\n },\n });\n return new Promise((resolve) => setTimeout(resolve, 0));\n });\n expect(last(returnedResults())).toBe(before);\n });\n\n it(\"returns a new object when a field that was selected in the watch query is updated in the store\", async () => {\n await act(async () => {\n client.cache.modify({\n id:\n typePolicies === typePoliciesWithDefaultApolloClientStoreKeys\n ? \"User:42\"\n : \"42\",\n fields: {\n petName: () => \"some new value\",\n },\n });\n return new Promise((resolve) => setTimeout(resolve, 0));\n });\n expect(returnedResults().length).toBe(2);\n expect(last(returnedResults())).toMatchObject({\n petName: \"some new value\",\n });\n });\n\n it(\"returns data synchronously\", () => {\n expect(returnedResults().length).toBe(1);\n });\n\n it(\"fetches new data when variables change\", async () => {\n act(() => {\n testRenderer.update(\n <ApolloProvider client={client}>\n <ErrorBoundary>\n <RootComponent\n variables={{\n userId: 21,\n messagesBackwardCount: 1,\n messagesBeforeCursor: \"\",\n }}\n />\n </ErrorBoundary>\n </ApolloProvider>\n );\n });\n await act(() =>\n client.mock.resolveMostRecentOperation((operation) =>\n MockPayloadGenerator.generate(operation, {\n User: () => ({ id: operation.request.variables.userId }),\n })\n )\n );\n expect(last(returnedResults()).id).toBe(21);\n });\n // });\n }\n\n describe(useCompiledFragment, () => {\n itBehavesLikeFragment(() => useFragmentResult, {\n petName: '<mock-value-for-field-\"petName\">',\n });\n\n it(\"also works with fragments on the Query type\", () => {\n expect(last(componentOnQueryTypeResult)).toMatchInlineSnapshot(`\n Object {\n \"__fragments\": Object {\n \"avatarSize\": 21,\n \"messagesBackwardCount\": 1,\n \"messagesBeforeCursor\": \"\",\n \"userId\": 42,\n },\n \"nonNode\": Object {\n \"__typename\": \"NonNode\",\n \"id\": \"<mock-value-for-field-\\\\\"id\\\\\">\",\n },\n }\n `);\n });\n });\n\n function itBehavesLikeRefetchableFragment(\n returnedResults: () => [data: { id: number }, refetch: RefetchFn][]\n ) {\n it.todo(\n \"supports variables with default values on either operations or with @argumentDefinitions\"\n );\n\n describe(\"when refetching\", () => {\n let onCompleted: jest.Mock;\n let disposable: Disposable;\n\n beforeEach(() => {\n const [_data, refetch] = last(returnedResults());\n onCompleted = jest.fn();\n disposable = refetch({ avatarSize: 42 }, { onCompleted });\n });\n\n it(\"can be cancelled\", () => {\n const query = last(activeQueries(client));\n disposable.dispose();\n expect(client.getObservableQueries().has(query.queryId)).toBeFalsy();\n });\n\n it(\"cancels when unmounting\", async () => {\n await act(async () => {\n const query = last(activeQueries(client));\n testRenderer.unmount();\n await new Promise((resolve) => setTimeout(resolve, 0));\n expect(client.getObservableQueries().has(query.queryId)).toBeFalsy();\n });\n });\n\n describe(\"successfully\", () => {\n beforeEach(async () => {\n await act(() => {\n client.mock.resolveMostRecentOperation((operation) =>\n MockPayloadGenerator.generate(operation, {\n Node: () => ({\n id: 42,\n avatarUrl: `avatarUrl-with-size-${operation.request.variables.avatarSize}`,\n }),\n })\n );\n return new Promise((resolve) => setTimeout(resolve, 0));\n });\n });\n\n it(\"returns a new object from the hook\", () => {\n expect(last(returnedResults())[0]).toMatchObject({\n __typename: \"User\",\n avatarUrl: \"avatarUrl-with-size-42\",\n id: 42,\n });\n });\n\n it(\"updates the fragment reference request variables for future requests\", () => {\n expect(last(returnedResults())[0]).toMatchObject({\n __fragments: {\n avatarSize: 42,\n userId: 42,\n },\n });\n });\n\n it(\"invokes the onComplete callback without error\", () => {\n expect(onCompleted).toHaveBeenCalledWith(null);\n });\n });\n\n describe(\"and an error occurs\", () => {\n const error = new Error(\"oh noes\");\n\n beforeEach(async () => {\n await act(() => client.mock.rejectMostRecentOperation(error));\n });\n\n it(\"invokes the onComplete callback when an error occurs\", () => {\n expect(onCompleted).toHaveBeenCalledWith(error);\n });\n\n it(\"does not update the fragment reference request variables for future requests\", async () => {\n const [_data, refetch] = last(returnedResults());\n refetch({});\n expect(\n client.mock.getMostRecentOperation().request.variables.avatarSize\n ).toBe(21);\n });\n });\n });\n }\n\n describe(useCompiledRefetchableFragment, () => {\n itBehavesLikeFragment(\n () =>\n useRefetchableFragmentResult.map(\n ([data, _refetch]) => data as { id: number }\n ),\n { avatarUrl: '<mock-value-for-field-\"avatarUrl\">' }\n );\n\n itBehavesLikeRefetchableFragment(\n () =>\n useRefetchableFragmentResult as [\n data: { id: number },\n refetch: RefetchFn\n ][]\n );\n });\n\n describe(useCompiledPaginationFragment, () => {\n itBehavesLikeFragment(\n () =>\n forwardUsePaginationFragmentResult.map(\n ({ data }) => data as { id: number }\n ),\n {\n avatarUrl: '<mock-value-for-field-\"avatarUrl\">',\n conversations: {\n __typename: \"ConversationsConnection\",\n edges: [\n {\n __typename: \"ConversationsConnectionEdge\",\n cursor: '<mock-value-for-field-\"cursor\">',\n node: {\n __fragments: {\n avatarSize: 21,\n messagesBackwardCount: 1,\n messagesBeforeCursor: \"\",\n userId: 42,\n },\n __typename: \"Conversation\",\n id: \"first-paged-conversation\",\n title: '<mock-value-for-field-\"title\">',\n },\n },\n ],\n pageInfo: {\n __typename: \"PageInfo\",\n endCursor: \"first-page-end-cursor\",\n hasNextPage: true,\n },\n },\n }\n );\n\n itBehavesLikeRefetchableFragment(() =>\n forwardUsePaginationFragmentResult.map(({ data, refetch }) => [\n data as { id: number },\n refetch,\n ])\n );\n\n describe(\"when paginating forward\", () => {\n it(\"returns that next data is available\", () => {\n const { hasNext } = last(forwardUsePaginationFragmentResult);\n expect(hasNext).toBeTruthy();\n });\n\n it(\"uses the correct count and cursor values\", () => {\n act(() => {\n const { loadNext } = last(forwardUsePaginationFragmentResult);\n loadNext(123);\n });\n\n const operation = client.mock.getMostRecentOperation();\n expect(operation.request.variables).toMatchObject({\n conversationsForwardCount: 123,\n conversationsAfterCursor: \"first-page-end-cursor\",\n });\n });\n\n it(\"returns that a pagination operation is in-flight\", () => {\n act(() => {\n const { loadNext } = last(forwardUsePaginationFragmentResult);\n loadNext(123);\n });\n const { isLoadingNext } = last(forwardUsePaginationFragmentResult);\n expect(isLoadingNext).toBeTruthy();\n });\n\n it(\"can be cancelled\", () => {\n act(() => {\n const { loadNext } = last(forwardUsePaginationFragmentResult);\n const disposable = loadNext(123);\n const query = last(activeQueries(client));\n disposable.dispose();\n expect(client.getObservableQueries().has(query.queryId)).toBeFalsy();\n });\n });\n\n it(\"cancels when unmounting\", async () => {\n await act(async () => {\n const { loadNext } = last(forwardUsePaginationFragmentResult);\n loadNext(123);\n const query = last(activeQueries(client));\n\n testRenderer.unmount();\n await new Promise((resolve) => setTimeout(resolve, 0));\n\n expect(client.getObservableQueries().has(query.queryId)).toBeFalsy();\n });\n });\n\n it(\"invokes the onComplete callback when an error occurs\", async () => {\n const onCompleted = jest.fn();\n const error = new Error(\"oh noes\");\n\n const { loadNext } = last(forwardUsePaginationFragmentResult);\n await act(async () => {\n loadNext(1, { onCompleted });\n await client.mock.rejectMostRecentOperation(error);\n });\n\n expect(onCompleted).toHaveBeenCalledWith(error);\n });\n\n describe(\"and having received the response\", () => {\n let onCompleted: jest.Mock;\n\n beforeEach(async () => {\n onCompleted = jest.fn();\n await act(async () => {\n const { loadNext } = last(forwardUsePaginationFragmentResult);\n loadNext(1, { onCompleted });\n\n // Introduce a slight delay before resolving the request as a\n // regression test with a pagination requst being disposed early.\n await new Promise((resolve) => setTimeout(resolve, 0));\n\n client.mock.resolveMostRecentOperation((operation) =>\n MockPayloadGenerator.generate(operation, {\n Node: () => ({\n id: 42,\n }),\n Conversation: () => ({\n id: \"second-paged-conversation\",\n }),\n PageInfo: () => ({\n endCursor: \"second-page-end-cursor\",\n hasNextPage: false,\n }),\n })\n );\n return new Promise((resolve) => setTimeout(resolve, 0));\n });\n });\n\n it(\"returns that no pagination operation is in-flight\", () => {\n const { isLoadingNext } = last(forwardUsePaginationFragmentResult);\n expect(isLoadingNext).toBeFalsy();\n });\n\n it(\"loads the new data into the store\", () => {\n expect(client.cache.extract()).toMatchObject({\n [typePolicies === typePoliciesWithDefaultApolloClientStoreKeys\n ? \"Conversation:second-paged-conversation\"\n : \"second-paged-conversation\"]: {\n id: \"second-paged-conversation\",\n __typename: \"Conversation\",\n title: '<mock-value-for-field-\"title\">',\n },\n });\n });\n\n it(\"returns the complete list data (previous+new) from the hook\", () => {\n const result = last(forwardUsePaginationFragmentResult);\n expect(\n (result.data as any).conversations.edges.map(\n (edge: any) => edge.node.id\n )\n ).toMatchInlineSnapshot(`\n Array [\n \"first-paged-conversation\",\n \"second-paged-conversation\",\n ]\n `);\n });\n\n it(\"uses the new cursor value\", () => {\n act(() => {\n const { loadNext } = last(forwardUsePaginationFragmentResult);\n loadNext(123);\n });\n\n const operation = client.mock.getMostRecentOperation();\n expect(operation.request.variables).toMatchObject({\n conversationsAfterCursor: \"second-page-end-cursor\",\n });\n });\n\n it(\"returns that no next data is available\", () => {\n const { hasNext } = last(forwardUsePaginationFragmentResult);\n expect(hasNext).toBeFalsy();\n });\n\n it(\"invokes the onComplete callback without error\", () => {\n expect(onCompleted).toHaveBeenCalledWith(null);\n });\n });\n });\n\n describe(\"when paginating backward\", () => {\n it(\"returns that previous data is available\", () => {\n const { hasPrevious } = last(backwardUsePaginationFragmentResult);\n expect(hasPrevious).toBeTruthy();\n });\n\n it(\"uses the correct count and cursor values\", () => {\n act(() => {\n const { loadPrevious } = last(backwardUsePaginationFragmentResult);\n loadPrevious(123);\n });\n\n const operation = client.mock.getMostRecentOperation();\n expect(operation.request.variables).toMatchObject({\n messagesBackwardCount: 123,\n messagesBeforeCursor: \"first-page-start-cursor\",\n });\n });\n\n it(\"returns that a pagination operation is in-flight\", () => {\n act(() => {\n const { loadPrevious } = last(backwardUsePaginationFragmentResult);\n loadPrevious(123);\n });\n const { isLoadingPrevious } = last(backwardUsePaginationFragmentResult);\n expect(isLoadingPrevious).toBeTruthy();\n });\n\n it(\"can be cancelled\", () => {\n act(() => {\n const { loadPrevious } = last(backwardUsePaginationFragmentResult);\n const disposable = loadPrevious(123);\n const query = last(activeQueries(client));\n disposable.dispose();\n expect(client.getObservableQueries().has(query.queryId)).toBeFalsy();\n });\n });\n\n it(\"cancels when unmounting\", async () => {\n await act(async () => {\n const { loadPrevious } = last(backwardUsePaginationFragmentResult);\n loadPrevious(123);\n const query = last(activeQueries(client));\n\n testRenderer.unmount();\n await new Promise((resolve) => setTimeout(resolve, 0));\n\n expect(client.getObservableQueries().has(query.queryId)).toBeFalsy();\n });\n });\n\n it(\"invokes the onComplete callback when an error occurs\", async () => {\n const onCompleted = jest.fn();\n const error = new Error(\"oh noes\");\n\n const { loadPrevious } = last(backwardUsePaginationFragmentResult);\n await act(async () => {\n loadPrevious(1, { onCompleted });\n await client.mock.rejectMostRecentOperation(error);\n });\n\n expect(onCompleted).toHaveBeenCalledWith(error);\n });\n\n describe(\"and having received the response\", () => {\n let onCompleted: jest.Mock;\n\n beforeEach(async () => {\n onCompleted = jest.fn();\n await act(() => {\n const { loadPrevious } = last(backwardUsePaginationFragmentResult);\n loadPrevious(1, { onCompleted });\n\n client.mock.resolveMostRecentOperation((operation) =>\n MockPayloadGenerator.generate(operation, {\n Node: () => ({\n id: 42,\n }),\n Message: () => ({\n id: \"second-paged-message\",\n }),\n PageInfo: () => ({\n startCursor: \"second-page-start-cursor\",\n hasPreviousPage: false,\n }),\n })\n );\n return new Promise((resolve) => setTimeout(resolve, 0));\n });\n });\n\n it(\"returns that no pagination operation is in-flight\", () => {\n const { isLoadingPrevious } = last(\n backwardUsePaginationFragmentResult\n );\n expect(isLoadingPrevious).toBeFalsy();\n });\n\n it(\"loads the new data into the store\", () => {\n expect(client.cache.extract()).toMatchObject({\n [typePolicies === typePoliciesWithDefaultApolloClientStoreKeys\n ? \"Message:second-paged-message\"\n : \"second-paged-message\"]: {\n id: \"second-paged-message\",\n __typename: \"Message\",\n text: '<mock-value-for-field-\"text\">',\n },\n });\n });\n\n it(\"returns the complete list data (previous+new) from the hook\", () => {\n const result = last(backwardUsePaginationFragmentResult);\n expect(\n (result.data as any).messages.edges.map((edge: any) => edge.node.id)\n ).toMatchInlineSnapshot(`\n Array [\n \"second-paged-message\",\n \"first-paged-message\",\n ]\n `);\n });\n\n it(\"uses the new cursor value\", () => {\n act(() => {\n const { loadPrevious } = last(backwardUsePaginationFragmentResult);\n loadPrevious(123);\n });\n\n const operation = client.mock.getMostRecentOperation();\n expect(operation.request.variables).toMatchObject({\n messagesBeforeCursor: \"second-page-start-cursor\",\n });\n });\n\n it(\"returns that no previous data is available\", () => {\n const { hasPrevious } = last(backwardUsePaginationFragmentResult);\n expect(hasPrevious).toBeFalsy();\n });\n\n it(\"invokes the onComplete callback without error\", () => {\n expect(onCompleted).toHaveBeenCalledWith(null);\n });\n });\n });\n });\n});\n\nclass ErrorBoundary extends React.Component {\n state = { hasError: false };\n\n static getDerivedStateFromError(error: Error) {\n return { hasError: true };\n }\n\n componentDidCatch(error: Error, errorInfo: any) {\n console.error({ error, errorInfo });\n }\n\n render() {\n if (this.state.hasError) {\n return <h1>Something went wrong.</h1>;\n }\n\n return this.props.children;\n }\n}\n\nfunction last<T>(list: T[]): T {\n return list[list.length - 1];\n}\n\nfunction activeQueries(client: ApolloClient<any>) {\n return Array.from(client.getObservableQueries().values());\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AAAA;AAAA;AAAA;AAKA;AAAA;AAAA;AAAA;AAKA;AACA;AACA;AAAA;AAAA;AAIA;AAAA;AAAA;AACA;AAAA;AAAA;AACA;AAAA;AAAA;AAEA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA;AAAA;AAAA;AAAA;AAQA;AACA;AACA;AACA;AACA;AACA;AAGA,IAAM,SAAS,YACb,AAAG,aACD,AAAK,QAAQ,WAAW,gCACxB;AAIJ,IAAM,iBAAiB;AAAA;AAAA;AAAA;AAAA;AAMvB,IAAM,uBAAuB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQ7B,IAAM,qBAAqB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQ3B,IAAM,6BAA6B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAyBnC,IAAM,8BAA8B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBpC,IAAM,8BAA8B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAiBpC,SAAS,KAAK;AAAA,EACZ;AAAA,IACE;AAAA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AAA;AAAA;AAAA;AAAA;AAAA;AAOnD,kCAA4B,MAAM,UAAU;AAAA,EAA5C,cAhgCA;AAggCA;AACE,iBAAQ,CAAE,UAAU;AAAA;AAAA,SAEb,yBAAyB,OAAc;AAC5C,WAAO,CAAE,UAAU;AAAA;AAAA,EAGrB,kBAAkB,OAAc,WAAgB;AAC9C,YAAQ,MAAM,CAAE,OAAO;AAAA;AAAA,EAGzB,SAAS;AACP,QAAI,KAAK,MAAM,UAAU;AACvB,aAAO,oCAAC,MAAD,MAAI;AAAA;AAGb,WAAO,KAAK,MAAM;AAAA;AAAA;AAItB,cAAiB,MAAc;AAC7B,SAAO,KAAK,KAAK,SAAS;AAAA;AAG5B,uBAAuB,QAA2B;AAChD,SAAO,MAAM,KAAK,OAAO,uBAAuB;AAAA;",
|
|
4
|
+
"sourcesContent": ["import React from \"react\";\nimport { ApolloClient, defaultDataIdFromObject } from \"@apollo/client\";\nimport {\n act,\n create as createTestRenderer,\n ReactTestRenderer,\n} from \"react-test-renderer\";\nimport { buildSchema } from \"graphql\";\nimport { graphql } from \"@graphitation/graphql-js-tag\";\nimport {\n ApolloMockClient,\n createMockClient,\n} from \"@graphitation/apollo-mock-client\";\nimport * as MockPayloadGenerator from \"@graphitation/graphql-js-operation-payload-generator\";\nimport * as fs from \"fs\";\nimport * as path from \"path\";\n\nimport {\n Disposable,\n RefetchFn,\n useCompiledFragment,\n useCompiledLazyLoadQuery,\n useCompiledPaginationFragment,\n useCompiledRefetchableFragment,\n} from \"./compiledHooks\";\nimport {\n typePoliciesWithDefaultApolloClientStoreKeys,\n typePoliciesWithGlobalObjectIdStoreKeys,\n} from \"./typePolicies\";\nimport { ApolloReactRelayDuctTapeProvider } from \"../useOverridenOrDefaultApolloClient\";\n\n/**\n * NOTE: These compiler artefacts are normally imported using the transform from the createImportDocumentsTransform.ts module\n */\nimport { documents as compiledHooks_Root_executionQuery_documents } from \"./__generated__/compiledHooks_Root_executionQuery.graphql\";\nimport { documents as compiledHooks_ChildFragment_documents } from \"./__generated__/compiledHooks_ChildWatchNodeQuery.graphql\";\nimport { documents as compiledHooks_RefetchableFragment_documents } from \"./__generated__/compiledHooks_RefetchableFragment_RefetchQuery.graphql\";\nimport { documents as compiledHooks_QueryTypeFragment_documents } from \"./__generated__/compiledHooks_QueryTypeWatchNodeQuery.graphql\";\nimport { documents as compiledHooks_ForwardPaginationFragment_documents } from \"./__generated__/compiledHooks_ForwardPaginationFragment_PaginationQuery.graphql\";\nimport { documents as compiledHooks_BackwardPaginationFragment_documents } from \"./__generated__/compiledHooks_BackwardPaginationFragment_PaginationQuery.graphql\";\nimport { compiledHooks_Root_executionQueryVariables } from \"./__generated__/compiledHooks_Root_executionQuery.graphql\";\n\nconst schema = buildSchema(\n fs.readFileSync(\n path.resolve(__dirname, \"../__tests__/schema.graphql\"),\n \"utf8\"\n )\n);\n\nconst Child_fragment = graphql`\n fragment compiledHooks_ChildFragment on User {\n petName\n }\n`;\n\nconst Refetchable_fragment = graphql`\n fragment compiledHooks_RefetchableFragment on User\n @refetchable(queryName: \"compiledHooks_RefetchableFragment_RefetchQuery\") {\n petName\n avatarUrl(size: $avatarSize)\n }\n`;\n\nconst QueryType_fragment = graphql`\n fragment compiledHooks_QueryTypeFragment on Query {\n nonNode {\n id\n }\n }\n`;\n\nconst ForwardPagination_fragment = graphql`\n fragment compiledHooks_ForwardPaginationFragment on User\n @refetchable(\n queryName: \"compiledHooks_ForwardPaginationFragment_PaginationQuery\"\n )\n @argumentDefinitions(\n conversationsForwardCount: { type: \"Int!\", defaultValue: 1 }\n conversationsAfterCursor: { type: \"String!\", defaultValue: \"\" }\n ) {\n petName\n avatarUrl(size: $avatarSize)\n conversations(\n first: $conversationsForwardCount\n after: $conversationsAfterCursor\n ) @connection(key: \"compiledHooks_user_conversations\") {\n edges {\n node {\n title\n ...compiledHooks_BackwardPaginationFragment\n }\n }\n }\n }\n`;\n\nconst BackwardPagination_fragment = graphql`\n fragment compiledHooks_BackwardPaginationFragment on Conversation\n @refetchable(\n queryName: \"compiledHooks_BackwardPaginationFragment_PaginationQuery\"\n ) {\n messages(last: $messagesBackwardCount, before: $messagesBeforeCursor)\n @connection(key: \"compiledHooks_conversation_messages\") {\n edges {\n node {\n text\n }\n }\n }\n }\n`;\n\nconst Root_executionQueryDocument = graphql`\n query compiledHooks_Root_executionQuery(\n $userId: Int!\n $avatarSize: Int = 21\n $messagesBackwardCount: Int!\n $messagesBeforeCursor: String!\n ) {\n user(id: $userId) {\n name\n ...compiledHooks_ChildFragment\n ...compiledHooks_RefetchableFragment\n ...compiledHooks_ForwardPaginationFragment\n }\n ...compiledHooks_QueryTypeFragment\n }\n`;\n\ndescribe.each([\n [\n \"with default Apollo Client type-policies\",\n typePoliciesWithDefaultApolloClientStoreKeys,\n ],\n [\n \"with strict Global Object Id spec type-policies\",\n typePoliciesWithGlobalObjectIdStoreKeys,\n ],\n])(\"compiledHooks %s\", (_, typePolicies) => {\n let client: ApolloMockClient;\n let testRenderer: ReactTestRenderer;\n\n let useFragmentResult: { id: number }[];\n let useRefetchableFragmentResult: ReturnType<\n typeof useCompiledRefetchableFragment\n >[];\n let forwardUsePaginationFragmentResult: ReturnType<\n typeof useCompiledPaginationFragment\n >[];\n let backwardUsePaginationFragmentResult: ReturnType<\n typeof useCompiledPaginationFragment\n >[];\n let useLazyLoadQueryResult: { data?: any; error?: Error } | null = null;\n let componentOnQueryTypeResult: {}[];\n\n const ChildComponent: React.FC<{ user: { id: any } }> = (props) => {\n const result = useCompiledFragment(\n compiledHooks_ChildFragment_documents,\n props.user\n );\n useFragmentResult.push(result as { id: number });\n return null;\n };\n\n const ChildRefetchableComponent: React.FC<{ user: { id: any } }> = (\n props\n ) => {\n const result = useCompiledRefetchableFragment(\n compiledHooks_RefetchableFragment_documents,\n props.user\n );\n useRefetchableFragmentResult.push(result);\n return null;\n };\n\n const ComponentOnQueryType: React.FC<{ query: {} }> = (props) => {\n const result = useCompiledFragment(\n compiledHooks_QueryTypeFragment_documents,\n props.query\n );\n componentOnQueryTypeResult.push(result);\n return null;\n };\n\n const ChildForwardPaginationComponent: React.FC<{ user: { id: any } }> = (\n props\n ) => {\n const result = useCompiledPaginationFragment(\n compiledHooks_ForwardPaginationFragment_documents as any,\n props.user\n );\n forwardUsePaginationFragmentResult.push(result);\n\n return result.data.conversations.edges.map((edge: any, index: number) => {\n return (\n <ChildBackwardPaginationComponent\n conversation={edge.node}\n key={index}\n />\n );\n });\n };\n\n const ChildBackwardPaginationComponent: React.FC<{\n conversation: { id: any };\n }> = (props) => {\n const result = useCompiledPaginationFragment(\n compiledHooks_BackwardPaginationFragment_documents as any,\n props.conversation\n );\n backwardUsePaginationFragmentResult.push(result);\n return null;\n };\n\n const RootComponent: React.FC<{\n variables: compiledHooks_Root_executionQueryVariables;\n }> = (props) => {\n const result = useCompiledLazyLoadQuery(\n compiledHooks_Root_executionQuery_documents,\n { variables: props.variables }\n );\n useLazyLoadQueryResult = result;\n return result.data ? (\n <>\n <ChildComponent user={result.data.user} />\n <ChildRefetchableComponent user={result.data.user} />\n <ChildForwardPaginationComponent user={result.data.user} />\n <ComponentOnQueryType query={result.data} />\n </>\n ) : null;\n };\n\n beforeEach(() => {\n useLazyLoadQueryResult = null;\n useFragmentResult = [];\n useRefetchableFragmentResult = [];\n forwardUsePaginationFragmentResult = [];\n backwardUsePaginationFragmentResult = [];\n componentOnQueryTypeResult = [];\n client = createMockClient(schema, {\n cache: {\n possibleTypes: {\n Node: [\"User\"],\n },\n typePolicies,\n ...(typePolicies === typePoliciesWithDefaultApolloClientStoreKeys\n ? {}\n : {\n dataIdFromObject(responseObject) {\n return (\n responseObject.id?.toString() ||\n defaultDataIdFromObject(responseObject)\n );\n },\n }),\n },\n });\n act(() => {\n testRenderer = createTestRenderer(\n <ApolloReactRelayDuctTapeProvider client={client}>\n <ErrorBoundary>\n <RootComponent\n variables={{\n userId: 42,\n messagesBackwardCount: 1,\n messagesBeforeCursor: \"\",\n }}\n />\n </ErrorBoundary>\n </ApolloReactRelayDuctTapeProvider>\n );\n });\n });\n\n describe(useCompiledLazyLoadQuery, () => {\n it(\"correctly returns loading state\", async () => {\n expect(useLazyLoadQueryResult).toEqual({\n data: undefined,\n error: undefined,\n });\n await act(() =>\n client.mock.resolveMostRecentOperation((operation) =>\n MockPayloadGenerator.generate(operation)\n )\n );\n expect(useLazyLoadQueryResult).toEqual({\n data: expect.objectContaining({}),\n error: undefined,\n });\n });\n\n it(\"cancels the execution query while in-flight on unmount\", async () => {\n expect(activeQueries(client).map((query) => query.queryName)).toEqual([\n \"compiledHooks_Root_executionQuery\",\n ]);\n\n await act(async () => {\n testRenderer.unmount();\n return new Promise((resolve) => setTimeout(resolve, 0));\n });\n expect(client.getObservableQueries().size).toBe(0);\n });\n\n describe(\"once loaded\", () => {\n let executionQueryId: string;\n\n beforeEach(async () => {\n executionQueryId = last(activeQueries(client)).queryId;\n await act(() =>\n client.mock.resolveMostRecentOperation((operation) =>\n MockPayloadGenerator.generate(operation, {\n User: (options, generateId) => {\n return {\n id:\n options.parentType === \"Query\"\n ? operation.request.variables.userId\n : generateId(),\n };\n },\n Conversation: () => ({\n id: \"first-paged-conversation\",\n }),\n Message: () => ({\n id: \"first-paged-message\",\n }),\n })\n )\n );\n });\n\n it(\"unsubscribes from the execution query\", async () => {\n expect(\n activeQueries(client).map((query) => query.queryId)\n ).not.toContain(executionQueryId);\n });\n\n it(\"loads all data of the execution query into the store\", () => {\n expect(client.cache.extract()).toMatchSnapshot();\n });\n\n it(\"only returns the fields selected in the watch query to the component\", () => {\n expect(useLazyLoadQueryResult!.data).toMatchSnapshot();\n });\n\n it(\"does not re-render when a field that was not selected in the watch query is updated in the store\", async () => {\n const before = useLazyLoadQueryResult!.data;\n await act(async () => {\n client.cache.modify({\n id: \"User:42\",\n fields: {\n petName: () => \"Phoenix\",\n },\n });\n return new Promise((resolve) => setTimeout(resolve, 0));\n });\n expect(useLazyLoadQueryResult!.data).toBe(before);\n });\n\n it(\"does re-render when a field that was selected in the watch query is updated in the store\", async () => {\n const before = useLazyLoadQueryResult!.data;\n await act(async () => {\n client.cache.modify({\n id:\n typePolicies === typePoliciesWithDefaultApolloClientStoreKeys\n ? \"User:42\"\n : \"42\",\n fields: {\n name: () => \"Satya\",\n },\n });\n return new Promise((resolve) => setTimeout(resolve, 0));\n });\n expect(useLazyLoadQueryResult!.data).not.toBe(before);\n expect(useLazyLoadQueryResult!.data).toMatchSnapshot();\n });\n\n it(\"fetches new data when variables change\", async () => {\n act(() => {\n testRenderer.update(\n <ApolloReactRelayDuctTapeProvider client={client}>\n <ErrorBoundary>\n <RootComponent\n variables={{\n userId: 21,\n messagesBackwardCount: 1,\n messagesBeforeCursor: \"\",\n }}\n />\n </ErrorBoundary>\n </ApolloReactRelayDuctTapeProvider>\n );\n });\n await act(() =>\n client.mock.resolveMostRecentOperation((operation) =>\n MockPayloadGenerator.generate(operation, {\n User: () => ({ id: operation.request.variables.userId }),\n })\n )\n );\n expect(\n client.cache.extract()[\n typePolicies === typePoliciesWithDefaultApolloClientStoreKeys\n ? \"User:21\"\n : \"21\"\n ]\n ).toMatchSnapshot();\n });\n\n it(\"does not try to kick-off a new query when the variables object deep equals the previous one\", async () => {\n const spy = jest.spyOn(client, \"query\");\n await act(async () => {\n testRenderer.update(\n <ApolloReactRelayDuctTapeProvider client={client}>\n <ErrorBoundary>\n <RootComponent\n variables={{\n userId: 42,\n messagesBackwardCount: 1,\n messagesBeforeCursor: \"\",\n }}\n />\n </ErrorBoundary>\n </ApolloReactRelayDuctTapeProvider>\n );\n return new Promise((resolve) => setTimeout(resolve, 100));\n });\n expect(spy).not.toHaveBeenCalled();\n });\n\n it(\"removes all watch queries on unmount\", async () => {\n await act(async () => {\n testRenderer.unmount();\n return new Promise((resolve) => setTimeout(resolve, 0));\n });\n expect(client.getObservableQueries().size).toBe(0);\n });\n });\n });\n\n function itBehavesLikeFragment(\n returnedResults: () => { id: number }[],\n fragmentSpecificFieldSelections?: {}\n ) {\n // TODO: This should be scoped so it doesn't leak to other tests in the same parent describe\n // describe(\"behaves like useFragment\", () => {\n beforeEach(async () => {\n await act(() =>\n client.mock.resolveMostRecentOperation((operation) => {\n const result = MockPayloadGenerator.generate(operation, {\n User: () => ({\n id: 42,\n }),\n Conversation: () => ({\n id: \"first-paged-conversation\",\n }),\n Message: () => ({\n id: \"first-paged-message\",\n }),\n PageInfo: () => ({\n startCursor: \"first-page-start-cursor\",\n endCursor: \"first-page-end-cursor\",\n hasNextPage: true,\n hasPreviousPage: true,\n }),\n });\n return result;\n })\n );\n });\n\n it(\"only returns the fields selected in the watch query to the component\", () => {\n expect(last(returnedResults())).toEqual({\n __fragments: {\n avatarSize: 21,\n messagesBackwardCount: 1,\n messagesBeforeCursor: \"\",\n userId: 42,\n },\n __typename: \"User\",\n id: 42,\n petName: '<mock-value-for-field-\"petName\">',\n ...fragmentSpecificFieldSelections,\n });\n });\n\n it(\"returns the same object when a field that was not selected in the watch query is updated in the store\", async () => {\n const before = last(returnedResults());\n await act(async () => {\n client.cache.modify({\n id: \"User:42\",\n fields: {\n name: () => \"Satya\",\n },\n });\n return new Promise((resolve) => setTimeout(resolve, 0));\n });\n expect(last(returnedResults())).toBe(before);\n });\n\n it(\"returns a new object when a field that was selected in the watch query is updated in the store\", async () => {\n await act(async () => {\n client.cache.modify({\n id:\n typePolicies === typePoliciesWithDefaultApolloClientStoreKeys\n ? \"User:42\"\n : \"42\",\n fields: {\n petName: () => \"some new value\",\n },\n });\n return new Promise((resolve) => setTimeout(resolve, 0));\n });\n expect(returnedResults().length).toBe(2);\n expect(last(returnedResults())).toMatchObject({\n petName: \"some new value\",\n });\n });\n\n it(\"returns data synchronously\", () => {\n expect(returnedResults().length).toBe(1);\n });\n\n it(\"fetches new data when variables change\", async () => {\n act(() => {\n testRenderer.update(\n <ApolloReactRelayDuctTapeProvider client={client}>\n <ErrorBoundary>\n <RootComponent\n variables={{\n userId: 21,\n messagesBackwardCount: 1,\n messagesBeforeCursor: \"\",\n }}\n />\n </ErrorBoundary>\n </ApolloReactRelayDuctTapeProvider>\n );\n });\n await act(() =>\n client.mock.resolveMostRecentOperation((operation) =>\n MockPayloadGenerator.generate(operation, {\n User: () => ({ id: operation.request.variables.userId }),\n })\n )\n );\n expect(last(returnedResults()).id).toBe(21);\n });\n // });\n }\n\n describe(useCompiledFragment, () => {\n itBehavesLikeFragment(() => useFragmentResult, {\n petName: '<mock-value-for-field-\"petName\">',\n });\n\n it(\"also works with fragments on the Query type\", () => {\n expect(last(componentOnQueryTypeResult)).toMatchInlineSnapshot(`\n Object {\n \"__fragments\": Object {\n \"avatarSize\": 21,\n \"messagesBackwardCount\": 1,\n \"messagesBeforeCursor\": \"\",\n \"userId\": 42,\n },\n \"nonNode\": Object {\n \"__typename\": \"NonNode\",\n \"id\": \"<mock-value-for-field-\\\\\"id\\\\\">\",\n },\n }\n `);\n });\n });\n\n function itBehavesLikeRefetchableFragment(\n returnedResults: () => [data: { id: number }, refetch: RefetchFn][]\n ) {\n it.todo(\n \"supports variables with default values on either operations or with @argumentDefinitions\"\n );\n\n describe(\"when refetching\", () => {\n let onCompleted: jest.Mock;\n let disposable: Disposable;\n\n beforeEach(() => {\n const [_data, refetch] = last(returnedResults());\n onCompleted = jest.fn();\n disposable = refetch({ avatarSize: 42 }, { onCompleted });\n });\n\n it(\"can be cancelled\", () => {\n const query = last(activeQueries(client));\n disposable.dispose();\n expect(client.getObservableQueries().has(query.queryId)).toBeFalsy();\n });\n\n it(\"cancels when unmounting\", async () => {\n await act(async () => {\n const query = last(activeQueries(client));\n testRenderer.unmount();\n await new Promise((resolve) => setTimeout(resolve, 0));\n expect(client.getObservableQueries().has(query.queryId)).toBeFalsy();\n });\n });\n\n describe(\"successfully\", () => {\n beforeEach(async () => {\n await act(() => {\n client.mock.resolveMostRecentOperation((operation) =>\n MockPayloadGenerator.generate(operation, {\n Node: () => ({\n id: 42,\n avatarUrl: `avatarUrl-with-size-${operation.request.variables.avatarSize}`,\n }),\n })\n );\n return new Promise((resolve) => setTimeout(resolve, 0));\n });\n });\n\n it(\"returns a new object from the hook\", () => {\n expect(last(returnedResults())[0]).toMatchObject({\n __typename: \"User\",\n avatarUrl: \"avatarUrl-with-size-42\",\n id: 42,\n });\n });\n\n it(\"updates the fragment reference request variables for future requests\", () => {\n expect(last(returnedResults())[0]).toMatchObject({\n __fragments: {\n avatarSize: 42,\n userId: 42,\n },\n });\n });\n\n it(\"invokes the onComplete callback without error\", () => {\n expect(onCompleted).toHaveBeenCalledWith(null);\n });\n });\n\n describe(\"and an error occurs\", () => {\n const error = new Error(\"oh noes\");\n\n beforeEach(async () => {\n await act(() => client.mock.rejectMostRecentOperation(error));\n });\n\n it(\"invokes the onComplete callback when an error occurs\", () => {\n expect(onCompleted).toHaveBeenCalledWith(error);\n });\n\n it(\"does not update the fragment reference request variables for future requests\", async () => {\n const [_data, refetch] = last(returnedResults());\n refetch({});\n expect(\n client.mock.getMostRecentOperation().request.variables.avatarSize\n ).toBe(21);\n });\n });\n });\n }\n\n describe(useCompiledRefetchableFragment, () => {\n itBehavesLikeFragment(\n () =>\n useRefetchableFragmentResult.map(\n ([data, _refetch]) => data as { id: number }\n ),\n { avatarUrl: '<mock-value-for-field-\"avatarUrl\">' }\n );\n\n itBehavesLikeRefetchableFragment(\n () =>\n useRefetchableFragmentResult as [\n data: { id: number },\n refetch: RefetchFn\n ][]\n );\n });\n\n describe(useCompiledPaginationFragment, () => {\n itBehavesLikeFragment(\n () =>\n forwardUsePaginationFragmentResult.map(\n ({ data }) => data as { id: number }\n ),\n {\n avatarUrl: '<mock-value-for-field-\"avatarUrl\">',\n conversations: {\n __typename: \"ConversationsConnection\",\n edges: [\n {\n __typename: \"ConversationsConnectionEdge\",\n cursor: '<mock-value-for-field-\"cursor\">',\n node: {\n __fragments: {\n avatarSize: 21,\n messagesBackwardCount: 1,\n messagesBeforeCursor: \"\",\n userId: 42,\n },\n __typename: \"Conversation\",\n id: \"first-paged-conversation\",\n title: '<mock-value-for-field-\"title\">',\n },\n },\n ],\n pageInfo: {\n __typename: \"PageInfo\",\n endCursor: \"first-page-end-cursor\",\n hasNextPage: true,\n },\n },\n }\n );\n\n itBehavesLikeRefetchableFragment(() =>\n forwardUsePaginationFragmentResult.map(({ data, refetch }) => [\n data as { id: number },\n refetch,\n ])\n );\n\n describe(\"when paginating forward\", () => {\n it(\"returns that next data is available\", () => {\n const { hasNext } = last(forwardUsePaginationFragmentResult);\n expect(hasNext).toBeTruthy();\n });\n\n it(\"uses the correct count and cursor values\", () => {\n act(() => {\n const { loadNext } = last(forwardUsePaginationFragmentResult);\n loadNext(123);\n });\n\n const operation = client.mock.getMostRecentOperation();\n expect(operation.request.variables).toMatchObject({\n conversationsForwardCount: 123,\n conversationsAfterCursor: \"first-page-end-cursor\",\n });\n });\n\n it(\"returns that a pagination operation is in-flight\", () => {\n act(() => {\n const { loadNext } = last(forwardUsePaginationFragmentResult);\n loadNext(123);\n });\n const { isLoadingNext } = last(forwardUsePaginationFragmentResult);\n expect(isLoadingNext).toBeTruthy();\n });\n\n it(\"can be cancelled\", () => {\n act(() => {\n const { loadNext } = last(forwardUsePaginationFragmentResult);\n const disposable = loadNext(123);\n const query = last(activeQueries(client));\n disposable.dispose();\n expect(client.getObservableQueries().has(query.queryId)).toBeFalsy();\n });\n });\n\n it(\"cancels when unmounting\", async () => {\n await act(async () => {\n const { loadNext } = last(forwardUsePaginationFragmentResult);\n loadNext(123);\n const query = last(activeQueries(client));\n\n testRenderer.unmount();\n await new Promise((resolve) => setTimeout(resolve, 0));\n\n expect(client.getObservableQueries().has(query.queryId)).toBeFalsy();\n });\n });\n\n it(\"invokes the onComplete callback when an error occurs\", async () => {\n const onCompleted = jest.fn();\n const error = new Error(\"oh noes\");\n\n const { loadNext } = last(forwardUsePaginationFragmentResult);\n await act(async () => {\n loadNext(1, { onCompleted });\n await client.mock.rejectMostRecentOperation(error);\n });\n\n expect(onCompleted).toHaveBeenCalledWith(error);\n });\n\n describe(\"and having received the response\", () => {\n let onCompleted: jest.Mock;\n\n beforeEach(async () => {\n onCompleted = jest.fn();\n await act(async () => {\n const { loadNext } = last(forwardUsePaginationFragmentResult);\n loadNext(1, { onCompleted });\n\n // Introduce a slight delay before resolving the request as a\n // regression test with a pagination requst being disposed early.\n await new Promise((resolve) => setTimeout(resolve, 0));\n\n client.mock.resolveMostRecentOperation((operation) =>\n MockPayloadGenerator.generate(operation, {\n Node: () => ({\n id: 42,\n }),\n Conversation: () => ({\n id: \"second-paged-conversation\",\n }),\n PageInfo: () => ({\n endCursor: \"second-page-end-cursor\",\n hasNextPage: false,\n }),\n })\n );\n return new Promise((resolve) => setTimeout(resolve, 0));\n });\n });\n\n it(\"returns that no pagination operation is in-flight\", () => {\n const { isLoadingNext } = last(forwardUsePaginationFragmentResult);\n expect(isLoadingNext).toBeFalsy();\n });\n\n it(\"loads the new data into the store\", () => {\n expect(client.cache.extract()).toMatchObject({\n [typePolicies === typePoliciesWithDefaultApolloClientStoreKeys\n ? \"Conversation:second-paged-conversation\"\n : \"second-paged-conversation\"]: {\n id: \"second-paged-conversation\",\n __typename: \"Conversation\",\n title: '<mock-value-for-field-\"title\">',\n },\n });\n });\n\n it(\"returns the complete list data (previous+new) from the hook\", () => {\n const result = last(forwardUsePaginationFragmentResult);\n expect(\n (result.data as any).conversations.edges.map(\n (edge: any) => edge.node.id\n )\n ).toMatchInlineSnapshot(`\n Array [\n \"first-paged-conversation\",\n \"second-paged-conversation\",\n ]\n `);\n });\n\n it(\"uses the new cursor value\", () => {\n act(() => {\n const { loadNext } = last(forwardUsePaginationFragmentResult);\n loadNext(123);\n });\n\n const operation = client.mock.getMostRecentOperation();\n expect(operation.request.variables).toMatchObject({\n conversationsAfterCursor: \"second-page-end-cursor\",\n });\n });\n\n it(\"returns that no next data is available\", () => {\n const { hasNext } = last(forwardUsePaginationFragmentResult);\n expect(hasNext).toBeFalsy();\n });\n\n it(\"invokes the onComplete callback without error\", () => {\n expect(onCompleted).toHaveBeenCalledWith(null);\n });\n });\n });\n\n describe(\"when paginating backward\", () => {\n it(\"returns that previous data is available\", () => {\n const { hasPrevious } = last(backwardUsePaginationFragmentResult);\n expect(hasPrevious).toBeTruthy();\n });\n\n it(\"uses the correct count and cursor values\", () => {\n act(() => {\n const { loadPrevious } = last(backwardUsePaginationFragmentResult);\n loadPrevious(123);\n });\n\n const operation = client.mock.getMostRecentOperation();\n expect(operation.request.variables).toMatchObject({\n messagesBackwardCount: 123,\n messagesBeforeCursor: \"first-page-start-cursor\",\n });\n });\n\n it(\"returns that a pagination operation is in-flight\", () => {\n act(() => {\n const { loadPrevious } = last(backwardUsePaginationFragmentResult);\n loadPrevious(123);\n });\n const { isLoadingPrevious } = last(backwardUsePaginationFragmentResult);\n expect(isLoadingPrevious).toBeTruthy();\n });\n\n it(\"can be cancelled\", () => {\n act(() => {\n const { loadPrevious } = last(backwardUsePaginationFragmentResult);\n const disposable = loadPrevious(123);\n const query = last(activeQueries(client));\n disposable.dispose();\n expect(client.getObservableQueries().has(query.queryId)).toBeFalsy();\n });\n });\n\n it(\"cancels when unmounting\", async () => {\n await act(async () => {\n const { loadPrevious } = last(backwardUsePaginationFragmentResult);\n loadPrevious(123);\n const query = last(activeQueries(client));\n\n testRenderer.unmount();\n await new Promise((resolve) => setTimeout(resolve, 0));\n\n expect(client.getObservableQueries().has(query.queryId)).toBeFalsy();\n });\n });\n\n it(\"invokes the onComplete callback when an error occurs\", async () => {\n const onCompleted = jest.fn();\n const error = new Error(\"oh noes\");\n\n const { loadPrevious } = last(backwardUsePaginationFragmentResult);\n await act(async () => {\n loadPrevious(1, { onCompleted });\n await client.mock.rejectMostRecentOperation(error);\n });\n\n expect(onCompleted).toHaveBeenCalledWith(error);\n });\n\n describe(\"and having received the response\", () => {\n let onCompleted: jest.Mock;\n\n beforeEach(async () => {\n onCompleted = jest.fn();\n await act(() => {\n const { loadPrevious } = last(backwardUsePaginationFragmentResult);\n loadPrevious(1, { onCompleted });\n\n client.mock.resolveMostRecentOperation((operation) =>\n MockPayloadGenerator.generate(operation, {\n Node: () => ({\n id: 42,\n }),\n Message: () => ({\n id: \"second-paged-message\",\n }),\n PageInfo: () => ({\n startCursor: \"second-page-start-cursor\",\n hasPreviousPage: false,\n }),\n })\n );\n return new Promise((resolve) => setTimeout(resolve, 0));\n });\n });\n\n it(\"returns that no pagination operation is in-flight\", () => {\n const { isLoadingPrevious } = last(\n backwardUsePaginationFragmentResult\n );\n expect(isLoadingPrevious).toBeFalsy();\n });\n\n it(\"loads the new data into the store\", () => {\n expect(client.cache.extract()).toMatchObject({\n [typePolicies === typePoliciesWithDefaultApolloClientStoreKeys\n ? \"Message:second-paged-message\"\n : \"second-paged-message\"]: {\n id: \"second-paged-message\",\n __typename: \"Message\",\n text: '<mock-value-for-field-\"text\">',\n },\n });\n });\n\n it(\"returns the complete list data (previous+new) from the hook\", () => {\n const result = last(backwardUsePaginationFragmentResult);\n expect(\n (result.data as any).messages.edges.map((edge: any) => edge.node.id)\n ).toMatchInlineSnapshot(`\n Array [\n \"second-paged-message\",\n \"first-paged-message\",\n ]\n `);\n });\n\n it(\"uses the new cursor value\", () => {\n act(() => {\n const { loadPrevious } = last(backwardUsePaginationFragmentResult);\n loadPrevious(123);\n });\n\n const operation = client.mock.getMostRecentOperation();\n expect(operation.request.variables).toMatchObject({\n messagesBeforeCursor: \"second-page-start-cursor\",\n });\n });\n\n it(\"returns that no previous data is available\", () => {\n const { hasPrevious } = last(backwardUsePaginationFragmentResult);\n expect(hasPrevious).toBeFalsy();\n });\n\n it(\"invokes the onComplete callback without error\", () => {\n expect(onCompleted).toHaveBeenCalledWith(null);\n });\n });\n });\n });\n});\n\nclass ErrorBoundary extends React.Component {\n state = { hasError: false };\n\n static getDerivedStateFromError(error: Error) {\n return { hasError: true };\n }\n\n componentDidCatch(error: Error, errorInfo: any) {\n console.error({ error, errorInfo });\n }\n\n render() {\n if (this.state.hasError) {\n return <h1>Something went wrong.</h1>;\n }\n\n return this.props.children;\n }\n}\n\nfunction last<T>(list: T[]): T {\n return list[list.length - 1];\n}\n\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AO;AAAA;AAAA,EAGzB,SAAS;AACP,QAAI,KAAK,MAAM,UAAU;AACvB,aAAO,oCAAC,MAAD,MAAI;AAAA;AAGb,WAAO,KAAK,MAAM;AAAA;AAAA;AAItB,cAAiB,MAAc;AAC7B,SAAO,KAAK,KAAK,SAAS;AAAA;AAG5B,uBAAuB,QAA2B;AAChD,SAAO,MAAM,KAAK,OAAO,uBAAuB;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useOverridenOrDefaultApolloClient.d.ts","sourceRoot":"","sources":["../src/useOverridenOrDefaultApolloClient.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAEb,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"useOverridenOrDefaultApolloClient.d.ts","sourceRoot":"","sources":["../src/useOverridenOrDefaultApolloClient.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAEb,MAAM,gBAAgB,CAAC;AAExB,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B;;GAEG;AACH,wBAAgB,iCAAiC,IAAI,YAAY,CAAC,GAAG,CAAC,CAMrE;AAMD;;;;;;;GAOG;AACH,eAAO,MAAM,gCAAgC,EAAE,KAAK,CAAC,EAAE,CAAC;IACtD,MAAM,EAAE,YAAY,CAAC,GAAG,CAAC,CAAC;CAC3B,CAUA,CAAC"}
|
|
@@ -26,6 +26,7 @@ __export(exports, {
|
|
|
26
26
|
useOverridenOrDefaultApolloClient: () => useOverridenOrDefaultApolloClient
|
|
27
27
|
});
|
|
28
28
|
var import_client = __toModule(require("@apollo/client"));
|
|
29
|
+
var import_invariant = __toModule(require("invariant"));
|
|
29
30
|
var import_react = __toModule(require("react"));
|
|
30
31
|
function useOverridenOrDefaultApolloClient() {
|
|
31
32
|
const client = import_react.default.useContext(ApolloReactRelayDuctTapeContext);
|
|
@@ -36,5 +37,6 @@ function useOverridenOrDefaultApolloClient() {
|
|
|
36
37
|
}
|
|
37
38
|
const ApolloReactRelayDuctTapeContext = import_react.default.createContext(void 0);
|
|
38
39
|
const ApolloReactRelayDuctTapeProvider = (props) => {
|
|
40
|
+
(0, import_invariant.default)(props.client, "ApolloReactRelayDuctTapeProvider: client is required");
|
|
39
41
|
return import_react.default.createElement(ApolloReactRelayDuctTapeContext.Provider, {value: props.client}, props.children);
|
|
40
42
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/useOverridenOrDefaultApolloClient.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n ApolloClient,\n useApolloClient as useDefaultApolloClient,\n} from \"@apollo/client\";\nimport React from \"react\";\n\n/**\n * @internal\n */\nexport function useOverridenOrDefaultApolloClient(): ApolloClient<any> {\n const client = React.useContext(ApolloReactRelayDuctTapeContext);\n if (client) {\n return client;\n }\n return useDefaultApolloClient();\n}\n\nconst ApolloReactRelayDuctTapeContext = React.createContext<\n ApolloClient<any> | undefined\n>(undefined);\n\n/**\n * A context provider that allows passing an explicit ApolloClient instance to\n * the apollo-react-relay-duct-tape hooks. If this provider is not used, the\n * hooks will default to one provided by @apollo/client's ApolloProvider.\n *\n * This allows a subset of a tree to use apollo-react-relay-duct-tape using a\n * different ApolloClient instance than the rest of the tree above and below it.\n */\nexport const ApolloReactRelayDuctTapeProvider: React.FC<{\n client: ApolloClient<any>;\n}> = (props) => {\n return React.createElement(\n ApolloReactRelayDuctTapeContext.Provider,\n { value: props.client },\n props.children\n );\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAGO;AACP,mBAAkB;AAKX,6CAAgE;AACrE,QAAM,SAAS,qBAAM,WAAW;AAChC,MAAI,QAAQ;AACV,WAAO;AAAA;AAET,SAAO;AAAA;AAGT,MAAM,kCAAkC,qBAAM,cAE5C;AAUK,MAAM,mCAER,CAAC,UAAU;AACd,SAAO,qBAAM,cACX,gCAAgC,UAChC,CAAE,OAAO,MAAM,SACf,MAAM;AAAA;",
|
|
4
|
+
"sourcesContent": ["import {\n ApolloClient,\n useApolloClient as useDefaultApolloClient,\n} from \"@apollo/client\";\nimport invariant from \"invariant\";\nimport React from \"react\";\n\n/**\n * @internal\n */\nexport function useOverridenOrDefaultApolloClient(): ApolloClient<any> {\n const client = React.useContext(ApolloReactRelayDuctTapeContext);\n if (client) {\n return client;\n }\n return useDefaultApolloClient();\n}\n\nconst ApolloReactRelayDuctTapeContext = React.createContext<\n ApolloClient<any> | undefined\n>(undefined);\n\n/**\n * A context provider that allows passing an explicit ApolloClient instance to\n * the apollo-react-relay-duct-tape hooks. If this provider is not used, the\n * hooks will default to one provided by @apollo/client's ApolloProvider.\n *\n * This allows a subset of a tree to use apollo-react-relay-duct-tape using a\n * different ApolloClient instance than the rest of the tree above and below it.\n */\nexport const ApolloReactRelayDuctTapeProvider: React.FC<{\n client: ApolloClient<any>;\n}> = (props) => {\n invariant(\n props.client,\n \"ApolloReactRelayDuctTapeProvider: client is required\"\n );\n return React.createElement(\n ApolloReactRelayDuctTapeContext.Provider,\n { value: props.client },\n props.children\n );\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAGO;AACP,uBAAsB;AACtB,mBAAkB;AAKX,6CAAgE;AACrE,QAAM,SAAS,qBAAM,WAAW;AAChC,MAAI,QAAQ;AACV,WAAO;AAAA;AAET,SAAO;AAAA;AAGT,MAAM,kCAAkC,qBAAM,cAE5C;AAUK,MAAM,mCAER,CAAC,UAAU;AACd,gCACE,MAAM,QACN;AAEF,SAAO,qBAAM,cACX,gCAAgC,UAChC,CAAE,OAAO,MAAM,SACf,MAAM;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import {
|
|
3
3
|
useApolloClient as useDefaultApolloClient
|
|
4
4
|
} from "@apollo/client";
|
|
5
|
+
import invariant from "invariant";
|
|
5
6
|
import React from "react";
|
|
6
7
|
function useOverridenOrDefaultApolloClient() {
|
|
7
8
|
const client = React.useContext(ApolloReactRelayDuctTapeContext);
|
|
@@ -12,6 +13,7 @@ function useOverridenOrDefaultApolloClient() {
|
|
|
12
13
|
}
|
|
13
14
|
var ApolloReactRelayDuctTapeContext = React.createContext(void 0);
|
|
14
15
|
var ApolloReactRelayDuctTapeProvider = (props) => {
|
|
16
|
+
invariant(props.client, "ApolloReactRelayDuctTapeProvider: client is required");
|
|
15
17
|
return React.createElement(ApolloReactRelayDuctTapeContext.Provider, {value: props.client}, props.children);
|
|
16
18
|
};
|
|
17
19
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/useOverridenOrDefaultApolloClient.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n ApolloClient,\n useApolloClient as useDefaultApolloClient,\n} from \"@apollo/client\";\nimport React from \"react\";\n\n/**\n * @internal\n */\nexport function useOverridenOrDefaultApolloClient(): ApolloClient<any> {\n const client = React.useContext(ApolloReactRelayDuctTapeContext);\n if (client) {\n return client;\n }\n return useDefaultApolloClient();\n}\n\nconst ApolloReactRelayDuctTapeContext = React.createContext<\n ApolloClient<any> | undefined\n>(undefined);\n\n/**\n * A context provider that allows passing an explicit ApolloClient instance to\n * the apollo-react-relay-duct-tape hooks. If this provider is not used, the\n * hooks will default to one provided by @apollo/client's ApolloProvider.\n *\n * This allows a subset of a tree to use apollo-react-relay-duct-tape using a\n * different ApolloClient instance than the rest of the tree above and below it.\n */\nexport const ApolloReactRelayDuctTapeProvider: React.FC<{\n client: ApolloClient<any>;\n}> = (props) => {\n return React.createElement(\n ApolloReactRelayDuctTapeContext.Provider,\n { value: props.client },\n props.children\n );\n};\n"],
|
|
5
|
-
"mappings": ";AAAA;AAAA;AAAA;AAIA;AAKO,6CAAgE;AACrE,QAAM,SAAS,MAAM,WAAW;AAChC,MAAI,QAAQ;AACV,WAAO;AAAA;AAET,SAAO;AAAA;AAGT,IAAM,kCAAkC,MAAM,cAE5C;AAUK,IAAM,mCAER,CAAC,UAAU;AACd,SAAO,MAAM,cACX,gCAAgC,UAChC,CAAE,OAAO,MAAM,SACf,MAAM;AAAA;",
|
|
4
|
+
"sourcesContent": ["import {\n ApolloClient,\n useApolloClient as useDefaultApolloClient,\n} from \"@apollo/client\";\nimport invariant from \"invariant\";\nimport React from \"react\";\n\n/**\n * @internal\n */\nexport function useOverridenOrDefaultApolloClient(): ApolloClient<any> {\n const client = React.useContext(ApolloReactRelayDuctTapeContext);\n if (client) {\n return client;\n }\n return useDefaultApolloClient();\n}\n\nconst ApolloReactRelayDuctTapeContext = React.createContext<\n ApolloClient<any> | undefined\n>(undefined);\n\n/**\n * A context provider that allows passing an explicit ApolloClient instance to\n * the apollo-react-relay-duct-tape hooks. If this provider is not used, the\n * hooks will default to one provided by @apollo/client's ApolloProvider.\n *\n * This allows a subset of a tree to use apollo-react-relay-duct-tape using a\n * different ApolloClient instance than the rest of the tree above and below it.\n */\nexport const ApolloReactRelayDuctTapeProvider: React.FC<{\n client: ApolloClient<any>;\n}> = (props) => {\n invariant(\n props.client,\n \"ApolloReactRelayDuctTapeProvider: client is required\"\n );\n return React.createElement(\n ApolloReactRelayDuctTapeContext.Provider,\n { value: props.client },\n props.children\n );\n};\n"],
|
|
5
|
+
"mappings": ";AAAA;AAAA;AAAA;AAIA;AACA;AAKO,6CAAgE;AACrE,QAAM,SAAS,MAAM,WAAW;AAChC,MAAI,QAAQ;AACV,WAAO;AAAA;AAET,SAAO;AAAA;AAGT,IAAM,kCAAkC,MAAM,cAE5C;AAUK,IAAM,mCAER,CAAC,UAAU;AACd,YACE,MAAM,QACN;AAEF,SAAO,MAAM,cACX,gCAAgC,UAChC,CAAE,OAAO,MAAM,SACf,MAAM;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@graphitation/apollo-react-relay-duct-tape",
|
|
3
3
|
"description": "A compatibility wrapper that provides the react-relay API on top of Apollo Client.",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "1.0.1-alpha.
|
|
5
|
+
"version": "1.0.1-alpha.6",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "https://github.com/microsoft/graphitation.git",
|