@graphitation/apollo-react-relay-duct-tape 1.0.0 → 1.0.1-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (202) hide show
  1. package/.eslintcache +1 -0
  2. package/CHANGELOG.md +11 -6
  3. package/lib/convertFetchPolicy.d.ts +9 -0
  4. package/lib/convertFetchPolicy.d.ts.map +1 -0
  5. package/lib/convertFetchPolicy.js +20 -0
  6. package/lib/convertFetchPolicy.js.map +7 -0
  7. package/lib/convertFetchPolicy.mjs +14 -0
  8. package/lib/convertFetchPolicy.mjs.map +7 -0
  9. package/lib/hooks.d.ts +106 -0
  10. package/lib/hooks.d.ts.map +1 -0
  11. package/lib/hooks.js +135 -0
  12. package/lib/hooks.js.map +7 -0
  13. package/lib/hooks.mjs +125 -0
  14. package/lib/hooks.mjs.map +7 -0
  15. package/lib/index.d.ts +4 -0
  16. package/lib/index.d.ts.map +1 -0
  17. package/lib/index.js +22 -0
  18. package/lib/index.js.map +7 -0
  19. package/lib/index.mjs +4 -0
  20. package/lib/index.mjs.map +7 -0
  21. package/lib/storeObservation/__generated__/compiledHooks_BackwardPaginationFragment.graphql.d.ts +18 -0
  22. package/lib/storeObservation/__generated__/compiledHooks_BackwardPaginationFragment.graphql.d.ts.map +1 -0
  23. package/lib/storeObservation/__generated__/compiledHooks_BackwardPaginationFragment.graphql.js +4 -0
  24. package/lib/storeObservation/__generated__/compiledHooks_BackwardPaginationFragment.graphql.js.map +7 -0
  25. package/lib/storeObservation/__generated__/compiledHooks_BackwardPaginationFragment.graphql.mjs +0 -0
  26. package/lib/storeObservation/__generated__/compiledHooks_BackwardPaginationFragment.graphql.mjs.map +7 -0
  27. package/lib/storeObservation/__generated__/compiledHooks_BackwardPaginationFragment_PaginationQuery.graphql.d.ts +17 -0
  28. package/lib/storeObservation/__generated__/compiledHooks_BackwardPaginationFragment_PaginationQuery.graphql.d.ts.map +1 -0
  29. package/lib/storeObservation/__generated__/compiledHooks_BackwardPaginationFragment_PaginationQuery.graphql.js +654 -0
  30. package/lib/storeObservation/__generated__/compiledHooks_BackwardPaginationFragment_PaginationQuery.graphql.js.map +7 -0
  31. package/lib/storeObservation/__generated__/compiledHooks_BackwardPaginationFragment_PaginationQuery.graphql.mjs +647 -0
  32. package/lib/storeObservation/__generated__/compiledHooks_BackwardPaginationFragment_PaginationQuery.graphql.mjs.map +7 -0
  33. package/lib/storeObservation/__generated__/compiledHooks_ChildFragment.graphql.d.ts +11 -0
  34. package/lib/storeObservation/__generated__/compiledHooks_ChildFragment.graphql.d.ts.map +1 -0
  35. package/lib/storeObservation/__generated__/compiledHooks_ChildFragment.graphql.js +4 -0
  36. package/lib/storeObservation/__generated__/compiledHooks_ChildFragment.graphql.js.map +7 -0
  37. package/lib/storeObservation/__generated__/compiledHooks_ChildFragment.graphql.mjs +0 -0
  38. package/lib/storeObservation/__generated__/compiledHooks_ChildFragment.graphql.mjs.map +7 -0
  39. package/lib/storeObservation/__generated__/compiledHooks_ChildWatchNodeQuery.graphql.d.ts +2 -0
  40. package/lib/storeObservation/__generated__/compiledHooks_ChildWatchNodeQuery.graphql.d.ts.map +1 -0
  41. package/lib/storeObservation/__generated__/compiledHooks_ChildWatchNodeQuery.graphql.js +173 -0
  42. package/lib/storeObservation/__generated__/compiledHooks_ChildWatchNodeQuery.graphql.js.map +7 -0
  43. package/lib/storeObservation/__generated__/compiledHooks_ChildWatchNodeQuery.graphql.mjs +166 -0
  44. package/lib/storeObservation/__generated__/compiledHooks_ChildWatchNodeQuery.graphql.mjs.map +7 -0
  45. package/lib/storeObservation/__generated__/compiledHooks_ForwardPaginationFragment.graphql.d.ts +21 -0
  46. package/lib/storeObservation/__generated__/compiledHooks_ForwardPaginationFragment.graphql.d.ts.map +1 -0
  47. package/lib/storeObservation/__generated__/compiledHooks_ForwardPaginationFragment.graphql.js +4 -0
  48. package/lib/storeObservation/__generated__/compiledHooks_ForwardPaginationFragment.graphql.js.map +7 -0
  49. package/lib/storeObservation/__generated__/compiledHooks_ForwardPaginationFragment.graphql.mjs +0 -0
  50. package/lib/storeObservation/__generated__/compiledHooks_ForwardPaginationFragment.graphql.mjs.map +7 -0
  51. package/lib/storeObservation/__generated__/compiledHooks_ForwardPaginationFragment_PaginationQuery.graphql.d.ts +20 -0
  52. package/lib/storeObservation/__generated__/compiledHooks_ForwardPaginationFragment_PaginationQuery.graphql.d.ts.map +1 -0
  53. package/lib/storeObservation/__generated__/compiledHooks_ForwardPaginationFragment_PaginationQuery.graphql.js +1059 -0
  54. package/lib/storeObservation/__generated__/compiledHooks_ForwardPaginationFragment_PaginationQuery.graphql.js.map +7 -0
  55. package/lib/storeObservation/__generated__/compiledHooks_ForwardPaginationFragment_PaginationQuery.graphql.mjs +1052 -0
  56. package/lib/storeObservation/__generated__/compiledHooks_ForwardPaginationFragment_PaginationQuery.graphql.mjs.map +7 -0
  57. package/lib/storeObservation/__generated__/compiledHooks_QueryTypeFragment.graphql.d.ts +13 -0
  58. package/lib/storeObservation/__generated__/compiledHooks_QueryTypeFragment.graphql.d.ts.map +1 -0
  59. package/lib/storeObservation/__generated__/compiledHooks_QueryTypeFragment.graphql.js +4 -0
  60. package/lib/storeObservation/__generated__/compiledHooks_QueryTypeFragment.graphql.js.map +7 -0
  61. package/lib/storeObservation/__generated__/compiledHooks_QueryTypeFragment.graphql.mjs +0 -0
  62. package/lib/storeObservation/__generated__/compiledHooks_QueryTypeFragment.graphql.mjs.map +7 -0
  63. package/lib/storeObservation/__generated__/compiledHooks_QueryTypeWatchNodeQuery.graphql.d.ts +2 -0
  64. package/lib/storeObservation/__generated__/compiledHooks_QueryTypeWatchNodeQuery.graphql.d.ts.map +1 -0
  65. package/lib/storeObservation/__generated__/compiledHooks_QueryTypeWatchNodeQuery.graphql.js +98 -0
  66. package/lib/storeObservation/__generated__/compiledHooks_QueryTypeWatchNodeQuery.graphql.js.map +7 -0
  67. package/lib/storeObservation/__generated__/compiledHooks_QueryTypeWatchNodeQuery.graphql.mjs +91 -0
  68. package/lib/storeObservation/__generated__/compiledHooks_QueryTypeWatchNodeQuery.graphql.mjs.map +7 -0
  69. package/lib/storeObservation/__generated__/compiledHooks_RefetchableFragment.graphql.d.ts +13 -0
  70. package/lib/storeObservation/__generated__/compiledHooks_RefetchableFragment.graphql.d.ts.map +1 -0
  71. package/lib/storeObservation/__generated__/compiledHooks_RefetchableFragment.graphql.js +4 -0
  72. package/lib/storeObservation/__generated__/compiledHooks_RefetchableFragment.graphql.js.map +7 -0
  73. package/lib/storeObservation/__generated__/compiledHooks_RefetchableFragment.graphql.mjs +0 -0
  74. package/lib/storeObservation/__generated__/compiledHooks_RefetchableFragment.graphql.mjs.map +7 -0
  75. package/lib/storeObservation/__generated__/compiledHooks_RefetchableFragment_RefetchQuery.graphql.d.ts +16 -0
  76. package/lib/storeObservation/__generated__/compiledHooks_RefetchableFragment_RefetchQuery.graphql.d.ts.map +1 -0
  77. package/lib/storeObservation/__generated__/compiledHooks_RefetchableFragment_RefetchQuery.graphql.js +381 -0
  78. package/lib/storeObservation/__generated__/compiledHooks_RefetchableFragment_RefetchQuery.graphql.js.map +7 -0
  79. package/lib/storeObservation/__generated__/compiledHooks_RefetchableFragment_RefetchQuery.graphql.mjs +374 -0
  80. package/lib/storeObservation/__generated__/compiledHooks_RefetchableFragment_RefetchQuery.graphql.mjs.map +7 -0
  81. package/lib/storeObservation/__generated__/compiledHooks_Root_executionQuery.graphql.d.ts +20 -0
  82. package/lib/storeObservation/__generated__/compiledHooks_Root_executionQuery.graphql.d.ts.map +1 -0
  83. package/lib/storeObservation/__generated__/compiledHooks_Root_executionQuery.graphql.js +871 -0
  84. package/lib/storeObservation/__generated__/compiledHooks_Root_executionQuery.graphql.js.map +7 -0
  85. package/lib/storeObservation/__generated__/compiledHooks_Root_executionQuery.graphql.mjs +864 -0
  86. package/lib/storeObservation/__generated__/compiledHooks_Root_executionQuery.graphql.mjs.map +7 -0
  87. package/lib/storeObservation/compiledHooks/index.d.ts +7 -0
  88. package/lib/storeObservation/compiledHooks/index.d.ts.map +1 -0
  89. package/lib/storeObservation/compiledHooks/index.js +33 -0
  90. package/lib/storeObservation/compiledHooks/index.js.map +7 -0
  91. package/lib/storeObservation/compiledHooks/index.mjs +11 -0
  92. package/lib/storeObservation/compiledHooks/index.mjs.map +7 -0
  93. package/lib/storeObservation/compiledHooks/types.d.ts +15 -0
  94. package/lib/storeObservation/compiledHooks/types.d.ts.map +1 -0
  95. package/lib/storeObservation/compiledHooks/types.js +3 -0
  96. package/lib/storeObservation/compiledHooks/types.js.map +7 -0
  97. package/lib/storeObservation/compiledHooks/types.mjs +0 -0
  98. package/lib/storeObservation/compiledHooks/types.mjs.map +7 -0
  99. package/lib/storeObservation/compiledHooks/useCompiledFragment.d.ts +9 -0
  100. package/lib/storeObservation/compiledHooks/useCompiledFragment.d.ts.map +1 -0
  101. package/lib/storeObservation/compiledHooks/useCompiledFragment.js +80 -0
  102. package/lib/storeObservation/compiledHooks/useCompiledFragment.js.map +7 -0
  103. package/lib/storeObservation/compiledHooks/useCompiledFragment.mjs +61 -0
  104. package/lib/storeObservation/compiledHooks/useCompiledFragment.mjs.map +7 -0
  105. package/lib/storeObservation/compiledHooks/useCompiledLazyLoadQuery.d.ts +16 -0
  106. package/lib/storeObservation/compiledHooks/useCompiledLazyLoadQuery.d.ts.map +1 -0
  107. package/lib/storeObservation/compiledHooks/useCompiledLazyLoadQuery.js +92 -0
  108. package/lib/storeObservation/compiledHooks/useCompiledLazyLoadQuery.js.map +7 -0
  109. package/lib/storeObservation/compiledHooks/useCompiledLazyLoadQuery.mjs +73 -0
  110. package/lib/storeObservation/compiledHooks/useCompiledLazyLoadQuery.mjs.map +7 -0
  111. package/lib/storeObservation/compiledHooks/useCompiledPaginationFragment.d.ts +15 -0
  112. package/lib/storeObservation/compiledHooks/useCompiledPaginationFragment.d.ts.map +1 -0
  113. package/lib/storeObservation/compiledHooks/useCompiledPaginationFragment.js +180 -0
  114. package/lib/storeObservation/compiledHooks/useCompiledPaginationFragment.js.map +7 -0
  115. package/lib/storeObservation/compiledHooks/useCompiledPaginationFragment.mjs +163 -0
  116. package/lib/storeObservation/compiledHooks/useCompiledPaginationFragment.mjs.map +7 -0
  117. package/lib/storeObservation/compiledHooks/useCompiledRefetchableFragment.d.ts +23 -0
  118. package/lib/storeObservation/compiledHooks/useCompiledRefetchableFragment.d.ts.map +1 -0
  119. package/lib/storeObservation/compiledHooks/useCompiledRefetchableFragment.js +131 -0
  120. package/lib/storeObservation/compiledHooks/useCompiledRefetchableFragment.js.map +7 -0
  121. package/lib/storeObservation/compiledHooks/useCompiledRefetchableFragment.mjs +112 -0
  122. package/lib/storeObservation/compiledHooks/useCompiledRefetchableFragment.mjs.map +7 -0
  123. package/lib/storeObservation/compiledHooks/useDeepCompareMemoize.d.ts +12 -0
  124. package/lib/storeObservation/compiledHooks/useDeepCompareMemoize.d.ts.map +1 -0
  125. package/lib/storeObservation/compiledHooks/useDeepCompareMemoize.js +37 -0
  126. package/lib/storeObservation/compiledHooks/useDeepCompareMemoize.js.map +7 -0
  127. package/lib/storeObservation/compiledHooks/useDeepCompareMemoize.mjs +15 -0
  128. package/lib/storeObservation/compiledHooks/useDeepCompareMemoize.mjs.map +7 -0
  129. package/lib/storeObservation/compiledHooks/useForceUpdate.d.ts +3 -0
  130. package/lib/storeObservation/compiledHooks/useForceUpdate.d.ts.map +1 -0
  131. package/lib/storeObservation/compiledHooks/useForceUpdate.js +31 -0
  132. package/lib/storeObservation/compiledHooks/useForceUpdate.js.map +7 -0
  133. package/lib/storeObservation/compiledHooks/useForceUpdate.mjs +9 -0
  134. package/lib/storeObservation/compiledHooks/useForceUpdate.mjs.map +7 -0
  135. package/lib/storeObservation/compiledHooks.test.d.ts +2 -0
  136. package/lib/storeObservation/compiledHooks.test.d.ts.map +1 -0
  137. package/lib/storeObservation/compiledHooks.test.js +827 -0
  138. package/lib/storeObservation/compiledHooks.test.js.map +7 -0
  139. package/lib/storeObservation/compiledHooks.test.mjs +835 -0
  140. package/lib/storeObservation/compiledHooks.test.mjs.map +7 -0
  141. package/lib/storeObservation/createImportDocumentsTransform.d.ts +9 -0
  142. package/lib/storeObservation/createImportDocumentsTransform.d.ts.map +1 -0
  143. package/lib/storeObservation/createImportDocumentsTransform.js +107 -0
  144. package/lib/storeObservation/createImportDocumentsTransform.js.map +7 -0
  145. package/lib/storeObservation/createImportDocumentsTransform.mjs +99 -0
  146. package/lib/storeObservation/createImportDocumentsTransform.mjs.map +7 -0
  147. package/lib/storeObservation/createImportDocumentsTransform.test.d.ts +2 -0
  148. package/lib/storeObservation/createImportDocumentsTransform.test.d.ts.map +1 -0
  149. package/lib/storeObservation/createImportDocumentsTransform.test.js +62 -0
  150. package/lib/storeObservation/createImportDocumentsTransform.test.js.map +7 -0
  151. package/lib/storeObservation/createImportDocumentsTransform.test.mjs +50 -0
  152. package/lib/storeObservation/createImportDocumentsTransform.test.mjs.map +7 -0
  153. package/lib/storeObservation/fragmentReferencesFieldPolicy.d.ts +3 -0
  154. package/lib/storeObservation/fragmentReferencesFieldPolicy.d.ts.map +1 -0
  155. package/lib/storeObservation/fragmentReferencesFieldPolicy.js +13 -0
  156. package/lib/storeObservation/fragmentReferencesFieldPolicy.js.map +7 -0
  157. package/lib/storeObservation/fragmentReferencesFieldPolicy.mjs +7 -0
  158. package/lib/storeObservation/fragmentReferencesFieldPolicy.mjs.map +7 -0
  159. package/lib/storeObservation/fragmentReferencesFieldPolicy.test.d.ts +2 -0
  160. package/lib/storeObservation/fragmentReferencesFieldPolicy.test.d.ts.map +1 -0
  161. package/lib/storeObservation/fragmentReferencesFieldPolicy.test.js +123 -0
  162. package/lib/storeObservation/fragmentReferencesFieldPolicy.test.js.map +7 -0
  163. package/lib/storeObservation/fragmentReferencesFieldPolicy.test.mjs +109 -0
  164. package/lib/storeObservation/fragmentReferencesFieldPolicy.test.mjs.map +7 -0
  165. package/lib/storeObservation/index.d.ts +5 -0
  166. package/lib/storeObservation/index.d.ts.map +1 -0
  167. package/lib/storeObservation/index.js +23 -0
  168. package/lib/storeObservation/index.js.map +7 -0
  169. package/lib/storeObservation/index.mjs +5 -0
  170. package/lib/storeObservation/index.mjs.map +7 -0
  171. package/lib/storeObservation/nodeFromCacheFieldPolicy.d.ts +39 -0
  172. package/lib/storeObservation/nodeFromCacheFieldPolicy.d.ts.map +1 -0
  173. package/lib/storeObservation/nodeFromCacheFieldPolicy.js +47 -0
  174. package/lib/storeObservation/nodeFromCacheFieldPolicy.js.map +7 -0
  175. package/lib/storeObservation/nodeFromCacheFieldPolicy.mjs +25 -0
  176. package/lib/storeObservation/nodeFromCacheFieldPolicy.mjs.map +7 -0
  177. package/lib/storeObservation/nodeFromCacheFieldPolicy.test.d.ts +2 -0
  178. package/lib/storeObservation/nodeFromCacheFieldPolicy.test.d.ts.map +1 -0
  179. package/lib/storeObservation/nodeFromCacheFieldPolicy.test.js +147 -0
  180. package/lib/storeObservation/nodeFromCacheFieldPolicy.test.js.map +7 -0
  181. package/lib/storeObservation/nodeFromCacheFieldPolicy.test.mjs +138 -0
  182. package/lib/storeObservation/nodeFromCacheFieldPolicy.test.mjs.map +7 -0
  183. package/lib/storeObservation/shallowCompareFragmentReferences.d.ts +23 -0
  184. package/lib/storeObservation/shallowCompareFragmentReferences.d.ts.map +1 -0
  185. package/lib/storeObservation/shallowCompareFragmentReferences.js +50 -0
  186. package/lib/storeObservation/shallowCompareFragmentReferences.js.map +7 -0
  187. package/lib/storeObservation/shallowCompareFragmentReferences.mjs +28 -0
  188. package/lib/storeObservation/shallowCompareFragmentReferences.mjs.map +7 -0
  189. package/lib/storeObservation/typePolicies.d.ts +4 -0
  190. package/lib/storeObservation/typePolicies.d.ts.map +1 -0
  191. package/lib/storeObservation/typePolicies.js +52 -0
  192. package/lib/storeObservation/typePolicies.js.map +7 -0
  193. package/lib/storeObservation/typePolicies.mjs +33 -0
  194. package/lib/storeObservation/typePolicies.mjs.map +7 -0
  195. package/lib/types.d.ts +41 -0
  196. package/lib/types.d.ts.map +1 -0
  197. package/lib/types.js +3 -0
  198. package/lib/types.js.map +7 -0
  199. package/lib/types.mjs +0 -0
  200. package/lib/types.mjs.map +7 -0
  201. package/package.json +13 -7
  202. package/graphitation-apollo-react-relay-duct-tape-0.5.0-store-observation.8.tgz +0 -0
package/.eslintcache ADDED
@@ -0,0 +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/convertFetchPolicy.ts":"7","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/hooks.ts":"8","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/index.ts":"9","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/__generated__/compiledHooks_BackwardPaginationFragment.graphql.ts":"10","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/__generated__/compiledHooks_BackwardPaginationFragment_PaginationQuery.graphql.ts":"11","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/__generated__/compiledHooks_ChildFragment.graphql.ts":"12","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/__generated__/compiledHooks_ChildWatchNodeQuery.graphql.ts":"13","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/__generated__/compiledHooks_ForwardPaginationFragment.graphql.ts":"14","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/__generated__/compiledHooks_ForwardPaginationFragment_PaginationQuery.graphql.ts":"15","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/__generated__/compiledHooks_QueryTypeFragment.graphql.ts":"16","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/__generated__/compiledHooks_QueryTypeWatchNodeQuery.graphql.ts":"17","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/__generated__/compiledHooks_RefetchableFragment.graphql.ts":"18","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/__generated__/compiledHooks_RefetchableFragment_RefetchQuery.graphql.ts":"19","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/__generated__/compiledHooks_Root_executionQuery.graphql.ts":"20","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/compiledHooks/index.ts":"21","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/compiledHooks/types.ts":"22","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/compiledHooks/useCompiledFragment.ts":"23","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/compiledHooks/useCompiledLazyLoadQuery.ts":"24","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/compiledHooks/useCompiledPaginationFragment.ts":"25","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/compiledHooks/useCompiledRefetchableFragment.ts":"26","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/compiledHooks/useDeepCompareMemoize.ts":"27","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/compiledHooks/useForceUpdate.ts":"28","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/compiledHooks.test.tsx":"29","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/createImportDocumentsTransform.test.ts":"30","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/createImportDocumentsTransform.ts":"31","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/fragmentReferencesFieldPolicy.test.ts":"32","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/fragmentReferencesFieldPolicy.ts":"33","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/index.ts":"34","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/nodeFromCacheFieldPolicy.test.ts":"35","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/nodeFromCacheFieldPolicy.ts":"36","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/shallowCompareFragmentReferences.ts":"37","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/storeObservation/typePolicies.ts":"38","/mnt/vss/_work/1/s/packages/apollo-react-relay-duct-tape/src/types.ts":"39"},{"size":527,"mtime":1649353124691,"results":"40","hashOfConfig":"41"},{"size":8845,"mtime":1649353124691,"results":"42","hashOfConfig":"41"},{"size":6838,"mtime":1649353124691,"results":"43","hashOfConfig":"41"},{"size":6980,"mtime":1649353124691,"results":"44","hashOfConfig":"41"},{"size":4869,"mtime":1649353124691,"results":"45","hashOfConfig":"41"},{"size":9970,"mtime":1649353124691,"results":"46","hashOfConfig":"41"},{"size":689,"mtime":1649353124691,"results":"47","hashOfConfig":"41"},{"size":8678,"mtime":1649353124691,"results":"48","hashOfConfig":"41"},{"size":86,"mtime":1649353124691,"results":"49","hashOfConfig":"41"},{"size":795,"mtime":1649353124691,"results":"50","hashOfConfig":"41"},{"size":21245,"mtime":1649353124691,"results":"51","hashOfConfig":"41"},{"size":542,"mtime":1649353124691,"results":"52","hashOfConfig":"41"},{"size":4762,"mtime":1649353124691,"results":"53","hashOfConfig":"41"},{"size":957,"mtime":1649353124691,"results":"54","hashOfConfig":"41"},{"size":34594,"mtime":1649353124691,"results":"55","hashOfConfig":"41"},{"size":607,"mtime":1649353124691,"results":"56","hashOfConfig":"41"},{"size":2420,"mtime":1649353124691,"results":"57","hashOfConfig":"41"},{"size":641,"mtime":1649353124691,"results":"58","hashOfConfig":"41"},{"size":11175,"mtime":1649353124691,"results":"59","hashOfConfig":"41"},{"size":27253,"mtime":1649353124691,"results":"60","hashOfConfig":"41"},{"size":445,"mtime":1649353124691,"results":"61","hashOfConfig":"41"},{"size":518,"mtime":1649353124691,"results":"62","hashOfConfig":"41"},{"size":2329,"mtime":1649353124691,"results":"63","hashOfConfig":"41"},{"size":3332,"mtime":1649353124691,"results":"64","hashOfConfig":"41"},{"size":8799,"mtime":1649353124691,"results":"65","hashOfConfig":"41"},{"size":5149,"mtime":1649353124691,"results":"66","hashOfConfig":"41"},{"size":843,"mtime":1649353124691,"results":"67","hashOfConfig":"41"},{"size":152,"mtime":1649353124691,"results":"68","hashOfConfig":"41"},{"size":33457,"mtime":1649353124691,"results":"69","hashOfConfig":"41"},{"size":1686,"mtime":1649353124691,"results":"70","hashOfConfig":"41"},{"size":5349,"mtime":1649353124691,"results":"71","hashOfConfig":"41"},{"size":1838,"mtime":1649353124695,"results":"72","hashOfConfig":"41"},{"size":285,"mtime":1649353124695,"results":"73","hashOfConfig":"41"},{"size":342,"mtime":1649353124695,"results":"74","hashOfConfig":"41"},{"size":3040,"mtime":1649353124695,"results":"75","hashOfConfig":"41"},{"size":2765,"mtime":1649353124695,"results":"76","hashOfConfig":"41"},{"size":2092,"mtime":1649353124695,"results":"77","hashOfConfig":"41"},{"size":1102,"mtime":1649353124695,"results":"78","hashOfConfig":"41"},{"size":1674,"mtime":1649353124695,"results":"79","hashOfConfig":"41"},{"filePath":"80","messages":"81","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"1lwegyw",{"filePath":"82","messages":"83","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"84","messages":"85","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"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},"/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/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",[]]
package/CHANGELOG.md CHANGED
@@ -1,20 +1,25 @@
1
1
  # Change Log - @graphitation/apollo-react-relay-duct-tape
2
2
 
3
- This log was last generated on Tue, 01 Feb 2022 12:17:19 GMT and should not be manually modified.
3
+ This log was last generated on Thu, 07 Apr 2022 17:44:09 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
- ## 1.0.0
7
+ ## 1.0.1-alpha.3
8
8
 
9
- Tue, 01 Feb 2022 12:17:19 GMT
9
+ Thu, 07 Apr 2022 17:44:09 GMT
10
10
 
11
- ### Patches
11
+ ### Changes
12
+
13
+ - [object Object] (eloy.de.enige@gmail.com)
14
+
15
+ ## 1.0.1-alpha.2
12
16
 
13
- - Bump relay-compiler-language-graphitation to v1.0.0-alpha.2
17
+ Fri, 01 Apr 2022 14:32:44 GMT
14
18
 
15
19
  ### Changes
16
20
 
17
- - Various changes (eloy.de.enige@gmail.com)
21
+ - Support strict Global Object Identification setup (eloy.de.enige@gmail.com)
22
+ - Bump relay-compiler-language-graphitation to v1.0.0-alpha.3
18
23
 
19
24
  ## 0.7.4
20
25
 
@@ -0,0 +1,9 @@
1
+ import type { WatchQueryFetchPolicy as ApolloWatchQueryFetchPolicy } from "@apollo/client";
2
+ import type { FetchPolicy } from "./types";
3
+ /**
4
+ * This is for internal use only.
5
+ */
6
+ declare type PrivateFetchPolicy = FetchPolicy | "no-cache";
7
+ export declare function convertFetchPolicy(fetchPolicy: PrivateFetchPolicy | undefined): ApolloWatchQueryFetchPolicy | undefined;
8
+ export {};
9
+ //# sourceMappingURL=convertFetchPolicy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convertFetchPolicy.d.ts","sourceRoot":"","sources":["../src/convertFetchPolicy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,IAAI,2BAA2B,EAAE,MAAM,gBAAgB,CAAC;AAC3F,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C;;GAEG;AACH,aAAK,kBAAkB,GAAG,WAAW,GAAG,UAAU,CAAC;AAanD,wBAAgB,kBAAkB,CAChC,WAAW,EAAE,kBAAkB,GAAG,SAAS,GAC1C,2BAA2B,GAAG,SAAS,CAEzC"}
@@ -0,0 +1,20 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
3
+ var __export = (target, all) => {
4
+ for (var name in all)
5
+ __defProp(target, name, {get: all[name], enumerable: true});
6
+ };
7
+ __markAsModule(exports);
8
+ __export(exports, {
9
+ convertFetchPolicy: () => convertFetchPolicy
10
+ });
11
+ const FETCH_POLICY_MAPPING = {
12
+ "store-or-network": "cache-first",
13
+ "store-and-network": "cache-and-network",
14
+ "network-only": "network-only",
15
+ "store-only": "cache-only",
16
+ "no-cache": "no-cache"
17
+ };
18
+ function convertFetchPolicy(fetchPolicy) {
19
+ return fetchPolicy && FETCH_POLICY_MAPPING[fetchPolicy];
20
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/convertFetchPolicy.ts"],
4
+ "sourcesContent": ["import type { WatchQueryFetchPolicy as ApolloWatchQueryFetchPolicy } from \"@apollo/client\";\nimport type { FetchPolicy } from \"./types\";\n\n/**\n * This is for internal use only.\n */\ntype PrivateFetchPolicy = FetchPolicy | \"no-cache\";\n\nconst FETCH_POLICY_MAPPING: Record<\n PrivateFetchPolicy,\n ApolloWatchQueryFetchPolicy\n> = {\n \"store-or-network\": \"cache-first\",\n \"store-and-network\": \"cache-and-network\",\n \"network-only\": \"network-only\",\n \"store-only\": \"cache-only\",\n \"no-cache\": \"no-cache\",\n};\n\nexport function convertFetchPolicy(\n fetchPolicy: PrivateFetchPolicy | undefined\n): ApolloWatchQueryFetchPolicy | undefined {\n return fetchPolicy && FETCH_POLICY_MAPPING[fetchPolicy];\n}\n"],
5
+ "mappings": ";;;;;;AAAA;AAAA;AAAA;AAAA;AAQA,MAAM,uBAGF;AAAA,EACF,oBAAoB;AAAA,EACpB,qBAAqB;AAAA,EACrB,gBAAgB;AAAA,EAChB,cAAc;AAAA,EACd,YAAY;AAAA;AAGP,4BACL,aACyC;AACzC,SAAO,eAAe,qBAAqB;AAAA;",
6
+ "names": []
7
+ }
@@ -0,0 +1,14 @@
1
+ // src/convertFetchPolicy.ts
2
+ var FETCH_POLICY_MAPPING = {
3
+ "store-or-network": "cache-first",
4
+ "store-and-network": "cache-and-network",
5
+ "network-only": "network-only",
6
+ "store-only": "cache-only",
7
+ "no-cache": "no-cache"
8
+ };
9
+ function convertFetchPolicy(fetchPolicy) {
10
+ return fetchPolicy && FETCH_POLICY_MAPPING[fetchPolicy];
11
+ }
12
+ export {
13
+ convertFetchPolicy
14
+ };
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/convertFetchPolicy.ts"],
4
+ "sourcesContent": ["import type { WatchQueryFetchPolicy as ApolloWatchQueryFetchPolicy } from \"@apollo/client\";\nimport type { FetchPolicy } from \"./types\";\n\n/**\n * This is for internal use only.\n */\ntype PrivateFetchPolicy = FetchPolicy | \"no-cache\";\n\nconst FETCH_POLICY_MAPPING: Record<\n PrivateFetchPolicy,\n ApolloWatchQueryFetchPolicy\n> = {\n \"store-or-network\": \"cache-first\",\n \"store-and-network\": \"cache-and-network\",\n \"network-only\": \"network-only\",\n \"store-only\": \"cache-only\",\n \"no-cache\": \"no-cache\",\n};\n\nexport function convertFetchPolicy(\n fetchPolicy: PrivateFetchPolicy | undefined\n): ApolloWatchQueryFetchPolicy | undefined {\n return fetchPolicy && FETCH_POLICY_MAPPING[fetchPolicy];\n}\n"],
5
+ "mappings": ";AAQA,IAAM,uBAGF;AAAA,EACF,oBAAoB;AAAA,EACpB,qBAAqB;AAAA,EACrB,gBAAgB;AAAA,EAChB,cAAc;AAAA,EACd,YAAY;AAAA;AAGP,4BACL,aACyC;AACzC,SAAO,eAAe,qBAAqB;AAAA;",
6
+ "names": []
7
+ }
package/lib/hooks.d.ts ADDED
@@ -0,0 +1,106 @@
1
+ import { FetchPolicy, GraphQLTaggedNode, KeyType, KeyTypeData, OperationType } from "./types";
2
+ import { RefetchFn, PaginationFn } from "./storeObservation/compiledHooks";
3
+ /**
4
+ * Executes a GraphQL query.
5
+ *
6
+ * This hook is called 'lazy' as it is used to fetch a GraphQL query _during_ render. This hook can trigger multiple
7
+ * round trips, one for loading and one for resolving.
8
+ *
9
+ * @see {@link https://microsoft.github.io/graphitation/docs/apollo-react-relay-duct-tape/use-lazy-load-query}
10
+ *
11
+ * @param query The query operation to perform.
12
+ * @param variables Object containing the variable values to fetch the query. These variables need to match GraphQL
13
+ * variables declared inside the query.
14
+ * @param options Options passed on to the underlying implementation.
15
+ * @returns An object with either an error, the result data, or neither while loading.
16
+ */
17
+ export declare function useLazyLoadQuery<TQuery extends OperationType>(query: GraphQLTaggedNode, variables: TQuery["variables"], options?: {
18
+ fetchPolicy?: FetchPolicy;
19
+ }): {
20
+ error?: Error;
21
+ data?: TQuery["response"];
22
+ };
23
+ /**
24
+ * A first-class way for an individual component to express its direct data requirements using GraphQL. The fragment
25
+ * should select all the fields that the component directly uses in its rendering or needs to pass to external
26
+ * functions. It should *not* select data that its children need, unless those children are intended to remain their
27
+ * pure React props as data inputs.
28
+ *
29
+ * For children that *do* have their own data requirements expressed using GraphQL, the fragment should ensure to
30
+ * spread in the child's fragment.
31
+ *
32
+ * @see {@link https://microsoft.github.io/graphitation/docs/apollo-react-relay-duct-tape/use-fragment}
33
+ *
34
+ * @note For now, the fragment objects should be exported such that parent's can interpolate them into their own
35
+ * GraphQL documents. This may change in the future when/if we entirely switch to static compilation and will
36
+ * allow us to also move the usage of the graphql tagged template function inline at the `useFragment` call-site.
37
+ *
38
+ * @param fragmentInput The GraphQL fragment document created using the `graphql` tagged template function.
39
+ * @param fragmentRef The opaque fragment reference passed in by a parent component that has spread in this component's
40
+ * fragment.
41
+ * @returns The data corresponding to the field selections.
42
+ */
43
+ export declare function useFragment<TKey extends KeyType>(fragmentInput: GraphQLTaggedNode, fragmentRef: TKey): KeyTypeData<TKey>;
44
+ /**
45
+ * Equivalent to `useFragment`, but allows refetching of its subtree of the overall query.
46
+ *
47
+ * @see {@link https://microsoft.github.io/graphitation/docs/apollo-react-relay-duct-tape/use-refetchable-fragment}
48
+ *
49
+ * @param fragmentInput The GraphQL fragment document created using the `graphql` tagged template function.
50
+ * @param fragmentRef The opaque fragment reference passed in by a parent component that has spread in this component's
51
+ * fragment.
52
+ * @returns The data corresponding to the field selections and a function to perform the refetch.
53
+ */
54
+ export declare function useRefetchableFragment<TQuery extends OperationType, TKey extends KeyType>(fragmentInput: GraphQLTaggedNode, fragmentRef: TKey): [data: KeyTypeData<TKey>, refetch: RefetchFn<TQuery["variables"]>];
55
+ /**
56
+ * Equivalent to `useFragment`, but allows pagination of its subtree of the overall query.
57
+ *
58
+ * @see {@link https://microsoft.github.io/graphitation/docs/apollo-react-relay-duct-tape/use-pagination-fragment}
59
+ *
60
+ * @param fragmentInput The GraphQL fragment document created using the `graphql` tagged template function.
61
+ * @param fragmentRef The opaque fragment reference passed in by a parent component that has spread in this component's
62
+ * fragment.
63
+ * @returns The data corresponding to the field selections and functions to deal with pagination.
64
+ */
65
+ export declare function usePaginationFragment<TQuery extends OperationType, TKey extends KeyType>(fragmentInput: GraphQLTaggedNode, fragmentRef: TKey): {
66
+ data: KeyTypeData<TKey>;
67
+ loadNext: PaginationFn;
68
+ loadPrevious: PaginationFn;
69
+ hasNext: boolean;
70
+ hasPrevious: boolean;
71
+ isLoadingNext: boolean;
72
+ isLoadingPrevious: boolean;
73
+ refetch: RefetchFn<TQuery["variables"]>;
74
+ };
75
+ interface GraphQLSubscriptionConfig<TSubscriptionPayload extends OperationType> {
76
+ subscription: GraphQLTaggedNode;
77
+ variables: TSubscriptionPayload["variables"];
78
+ /**
79
+ * Should response be nullable?
80
+ */
81
+ onNext?: (response: TSubscriptionPayload["response"]) => void;
82
+ onError?: (error: Error) => void;
83
+ }
84
+ /**
85
+ * @see {@link https://microsoft.github.io/graphitation/docs/apollo-react-relay-duct-tape/use-subscription}
86
+ *
87
+ * @param config
88
+ */
89
+ export declare function useSubscription<TSubscriptionPayload extends OperationType>(config: GraphQLSubscriptionConfig<TSubscriptionPayload>): void;
90
+ interface IMutationCommitterOptions<TMutationPayload extends OperationType> {
91
+ variables: TMutationPayload["variables"];
92
+ optimisticResponse?: Partial<TMutationPayload["response"]> | null;
93
+ }
94
+ declare type MutationCommiter<TMutationPayload extends OperationType> = (options: IMutationCommitterOptions<TMutationPayload>) => Promise<{
95
+ errors?: Error[];
96
+ data?: TMutationPayload["response"];
97
+ }>;
98
+ /**
99
+ * @see {@link https://microsoft.github.io/graphitation/docs/apollo-react-relay-duct-tape/use-mutation}
100
+ *
101
+ * @param mutation
102
+ * @returns
103
+ */
104
+ export declare function useMutation<TMutationPayload extends OperationType>(mutation: GraphQLTaggedNode): [MutationCommiter<TMutationPayload>, boolean];
105
+ export {};
106
+ //# sourceMappingURL=hooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,OAAO,EACP,WAAW,EACX,aAAa,EACd,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,SAAS,EACT,YAAY,EAKb,MAAM,kCAAkC,CAAC;AAG1C;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,SAAS,aAAa,EAC3D,KAAK,EAAE,iBAAiB,EACxB,SAAS,EAAE,MAAM,CAAC,WAAW,CAAC,EAC9B,OAAO,CAAC,EAAE;IAAE,WAAW,CAAC,EAAE,WAAW,CAAA;CAAE,GACtC;IAAE,KAAK,CAAC,EAAE,KAAK,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC,CAAA;CAAE,CAa9C;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,WAAW,CAAC,IAAI,SAAS,OAAO,EAC9C,aAAa,EAAE,iBAAiB,EAChC,WAAW,EAAE,IAAI,GAChB,WAAW,CAAC,IAAI,CAAC,CAMnB;AAED;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,SAAS,aAAa,EAC5B,IAAI,SAAS,OAAO,EAEpB,aAAa,EAAE,iBAAiB,EAChC,WAAW,EAAE,IAAI,GAChB,CAAC,IAAI,EAAE,WAAW,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,SAAS,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,CASpE;AAED;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,SAAS,aAAa,EAC5B,IAAI,SAAS,OAAO,EAEpB,aAAa,EAAE,iBAAiB,EAChC,WAAW,EAAE,IAAI,GAChB;IACD,IAAI,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC;IACxB,QAAQ,EAAE,YAAY,CAAC;IACvB,YAAY,EAAE,YAAY,CAAC;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,OAAO,CAAC;IACrB,aAAa,EAAE,OAAO,CAAC;IACvB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,OAAO,EAAE,SAAS,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC;CACzC,CASA;AAGD,UAAU,yBAAyB,CACjC,oBAAoB,SAAS,aAAa;IAE1C,YAAY,EAAE,iBAAiB,CAAC;IAChC,SAAS,EAAE,oBAAoB,CAAC,WAAW,CAAC,CAAC;IAC7C;;OAEG;IACH,MAAM,CAAC,EAAE,CAAC,QAAQ,EAAE,oBAAoB,CAAC,UAAU,CAAC,KAAK,IAAI,CAAC;IAC9D,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,oBAAoB,SAAS,aAAa,EACxE,MAAM,EAAE,yBAAyB,CAAC,oBAAoB,CAAC,GACtD,IAAI,CA4BN;AAED,UAAU,yBAAyB,CAAC,gBAAgB,SAAS,aAAa;IACxE,SAAS,EAAE,gBAAgB,CAAC,WAAW,CAAC,CAAC;IACzC,kBAAkB,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC,GAAG,IAAI,CAAC;CACnE;AAED,aAAK,gBAAgB,CAAC,gBAAgB,SAAS,aAAa,IAAI,CAC9D,OAAO,EAAE,yBAAyB,CAAC,gBAAgB,CAAC,KACjD,OAAO,CAAC;IAAE,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC;IAAC,IAAI,CAAC,EAAE,gBAAgB,CAAC,UAAU,CAAC,CAAA;CAAE,CAAC,CAAC;AAExE;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,gBAAgB,SAAS,aAAa,EAChE,QAAQ,EAAE,iBAAiB,GAC1B,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,EAAE,OAAO,CAAC,CAwB/C"}
package/lib/hooks.js ADDED
@@ -0,0 +1,135 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getProtoOf = Object.getPrototypeOf;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
9
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {enumerable: true, configurable: true, writable: true, value}) : obj[key] = value;
10
+ var __objSpread = (a, b) => {
11
+ for (var prop in b || (b = {}))
12
+ if (__hasOwnProp.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ if (__getOwnPropSymbols)
15
+ for (var prop of __getOwnPropSymbols(b)) {
16
+ if (__propIsEnum.call(b, prop))
17
+ __defNormalProp(a, prop, b[prop]);
18
+ }
19
+ return a;
20
+ };
21
+ var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
22
+ var __export = (target, all) => {
23
+ for (var name in all)
24
+ __defProp(target, name, {get: all[name], enumerable: true});
25
+ };
26
+ var __reExport = (target, module2, desc) => {
27
+ if (module2 && typeof module2 === "object" || typeof module2 === "function") {
28
+ for (let key of __getOwnPropNames(module2))
29
+ if (!__hasOwnProp.call(target, key) && key !== "default")
30
+ __defProp(target, key, {get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable});
31
+ }
32
+ return target;
33
+ };
34
+ var __toModule = (module2) => {
35
+ return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? {get: () => module2.default, enumerable: true} : {value: module2, enumerable: true})), module2);
36
+ };
37
+ var __async = (__this, __arguments, generator) => {
38
+ return new Promise((resolve, reject) => {
39
+ var fulfilled = (value) => {
40
+ try {
41
+ step(generator.next(value));
42
+ } catch (e) {
43
+ reject(e);
44
+ }
45
+ };
46
+ var rejected = (value) => {
47
+ try {
48
+ step(generator.throw(value));
49
+ } catch (e) {
50
+ reject(e);
51
+ }
52
+ };
53
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
54
+ step((generator = generator.apply(__this, __arguments)).next());
55
+ });
56
+ };
57
+ __markAsModule(exports);
58
+ __export(exports, {
59
+ useFragment: () => useFragment,
60
+ useLazyLoadQuery: () => useLazyLoadQuery,
61
+ useMutation: () => useMutation,
62
+ usePaginationFragment: () => usePaginationFragment,
63
+ useRefetchableFragment: () => useRefetchableFragment,
64
+ useSubscription: () => useSubscription
65
+ });
66
+ var import_invariant = __toModule(require("invariant"));
67
+ var import_client = __toModule(require("@apollo/client"));
68
+ var import_compiledHooks = __toModule(require("./storeObservation/compiledHooks"));
69
+ var import_convertFetchPolicy = __toModule(require("./convertFetchPolicy"));
70
+ function useLazyLoadQuery(query, variables, options) {
71
+ const apolloOptions = options && __objSpread(__objSpread({}, options), {
72
+ fetchPolicy: (0, import_convertFetchPolicy.convertFetchPolicy)(options.fetchPolicy)
73
+ });
74
+ if (query.watchQueryDocument) {
75
+ return (0, import_compiledHooks.useCompiledLazyLoadQuery)(query, __objSpread({
76
+ variables
77
+ }, apolloOptions));
78
+ } else {
79
+ return (0, import_client.useQuery)(query, __objSpread({variables}, apolloOptions));
80
+ }
81
+ }
82
+ function useFragment(fragmentInput, fragmentRef) {
83
+ if (fragmentInput.watchQueryDocument) {
84
+ return (0, import_compiledHooks.useCompiledFragment)(fragmentInput, fragmentRef);
85
+ } else {
86
+ return fragmentRef;
87
+ }
88
+ }
89
+ function useRefetchableFragment(fragmentInput, fragmentRef) {
90
+ (0, import_invariant.default)(!!fragmentInput.watchQueryDocument, "useRefetchableFragment is only supported at this time when using compilation");
91
+ return (0, import_compiledHooks.useCompiledRefetchableFragment)(fragmentInput, fragmentRef);
92
+ }
93
+ function usePaginationFragment(fragmentInput, fragmentRef) {
94
+ (0, import_invariant.default)(!!fragmentInput.watchQueryDocument, "usePaginationFragment is only supported at this time when using compilation");
95
+ return (0, import_compiledHooks.useCompiledPaginationFragment)(fragmentInput, fragmentRef);
96
+ }
97
+ function useSubscription(config) {
98
+ const {error} = (0, import_client.useSubscription)(config.subscription, {
99
+ variables: config.variables,
100
+ onSubscriptionData: ({subscriptionData}) => {
101
+ (0, import_invariant.default)(!subscriptionData.error, "Did not expect to receive an error here");
102
+ if (subscriptionData.data && config.onNext) {
103
+ config.onNext(subscriptionData.data);
104
+ }
105
+ }
106
+ });
107
+ if (error) {
108
+ if (config.onError) {
109
+ config.onError(error);
110
+ } else {
111
+ console.warn(`An unhandled GraphQL subscription error occurred: ${error.message}`);
112
+ }
113
+ }
114
+ }
115
+ function useMutation(mutation) {
116
+ const [apolloUpdater, {loading: mutationLoading}] = (0, import_client.useMutation)(mutation);
117
+ return [
118
+ (options) => __async(this, null, function* () {
119
+ const apolloResult = yield apolloUpdater({
120
+ variables: options.variables || {},
121
+ optimisticResponse: options.optimisticResponse
122
+ });
123
+ if (apolloResult.errors) {
124
+ return {
125
+ errors: Array.from(Object.values(apolloResult.errors)),
126
+ data: apolloResult.data
127
+ };
128
+ }
129
+ return {
130
+ data: apolloResult.data
131
+ };
132
+ }),
133
+ mutationLoading
134
+ ];
135
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/hooks.ts"],
4
+ "sourcesContent": ["import { DocumentNode } from \"graphql\";\nimport invariant from \"invariant\";\nimport {\n useSubscription as useApolloSubscription,\n useQuery as useApolloQuery,\n useMutation as useApolloMutation,\n} from \"@apollo/client\";\n\nimport {\n FetchPolicy,\n GraphQLTaggedNode,\n KeyType,\n KeyTypeData,\n OperationType,\n} from \"./types\";\nimport {\n RefetchFn,\n PaginationFn,\n useCompiledLazyLoadQuery,\n useCompiledFragment,\n useCompiledRefetchableFragment,\n useCompiledPaginationFragment,\n} from \"./storeObservation/compiledHooks\";\nimport { convertFetchPolicy } from \"./convertFetchPolicy\";\n\n/**\n * Executes a GraphQL query.\n *\n * This hook is called 'lazy' as it is used to fetch a GraphQL query _during_ render. This hook can trigger multiple\n * round trips, one for loading and one for resolving.\n *\n * @see {@link https://microsoft.github.io/graphitation/docs/apollo-react-relay-duct-tape/use-lazy-load-query}\n *\n * @param query The query operation to perform.\n * @param variables Object containing the variable values to fetch the query. These variables need to match GraphQL\n * variables declared inside the query.\n * @param options Options passed on to the underlying implementation.\n * @returns An object with either an error, the result data, or neither while loading.\n */\nexport function useLazyLoadQuery<TQuery extends OperationType>(\n query: GraphQLTaggedNode,\n variables: TQuery[\"variables\"],\n options?: { fetchPolicy?: FetchPolicy }\n): { error?: Error; data?: TQuery[\"response\"] } {\n const apolloOptions = options && {\n ...options,\n fetchPolicy: convertFetchPolicy(options.fetchPolicy),\n };\n if (query.watchQueryDocument) {\n return useCompiledLazyLoadQuery(query as any, {\n variables,\n ...apolloOptions,\n });\n } else {\n return useApolloQuery(query, { variables, ...apolloOptions });\n }\n}\n\n/**\n * A first-class way for an individual component to express its direct data requirements using GraphQL. The fragment\n * should select all the fields that the component directly uses in its rendering or needs to pass to external\n * functions. It should *not* select data that its children need, unless those children are intended to remain their\n * pure React props as data inputs.\n *\n * For children that *do* have their own data requirements expressed using GraphQL, the fragment should ensure to\n * spread in the child's fragment.\n *\n * @see {@link https://microsoft.github.io/graphitation/docs/apollo-react-relay-duct-tape/use-fragment}\n *\n * @note For now, the fragment objects should be exported such that parent's can interpolate them into their own\n * GraphQL documents. This may change in the future when/if we entirely switch to static compilation and will\n * allow us to also move the usage of the graphql tagged template function inline at the `useFragment` call-site.\n *\n * @param fragmentInput The GraphQL fragment document created using the `graphql` tagged template function.\n * @param fragmentRef The opaque fragment reference passed in by a parent component that has spread in this component's\n * fragment.\n * @returns The data corresponding to the field selections.\n */\nexport function useFragment<TKey extends KeyType>(\n fragmentInput: GraphQLTaggedNode,\n fragmentRef: TKey\n): KeyTypeData<TKey> {\n if (fragmentInput.watchQueryDocument) {\n return useCompiledFragment(fragmentInput, fragmentRef as any);\n } else {\n return fragmentRef as unknown;\n }\n}\n\n/**\n * Equivalent to `useFragment`, but allows refetching of its subtree of the overall query.\n *\n * @see {@link https://microsoft.github.io/graphitation/docs/apollo-react-relay-duct-tape/use-refetchable-fragment}\n *\n * @param fragmentInput The GraphQL fragment document created using the `graphql` tagged template function.\n * @param fragmentRef The opaque fragment reference passed in by a parent component that has spread in this component's\n * fragment.\n * @returns The data corresponding to the field selections and a function to perform the refetch.\n */\nexport function useRefetchableFragment<\n TQuery extends OperationType,\n TKey extends KeyType\n>(\n fragmentInput: GraphQLTaggedNode,\n fragmentRef: TKey\n): [data: KeyTypeData<TKey>, refetch: RefetchFn<TQuery[\"variables\"]>] {\n invariant(\n !!fragmentInput.watchQueryDocument,\n \"useRefetchableFragment is only supported at this time when using compilation\"\n );\n return useCompiledRefetchableFragment(\n fragmentInput as any,\n fragmentRef as any\n );\n}\n\n/**\n * Equivalent to `useFragment`, but allows pagination of its subtree of the overall query.\n *\n * @see {@link https://microsoft.github.io/graphitation/docs/apollo-react-relay-duct-tape/use-pagination-fragment}\n *\n * @param fragmentInput The GraphQL fragment document created using the `graphql` tagged template function.\n * @param fragmentRef The opaque fragment reference passed in by a parent component that has spread in this component's\n * fragment.\n * @returns The data corresponding to the field selections and functions to deal with pagination.\n */\nexport function usePaginationFragment<\n TQuery extends OperationType,\n TKey extends KeyType\n>(\n fragmentInput: GraphQLTaggedNode,\n fragmentRef: TKey\n): {\n data: KeyTypeData<TKey>;\n loadNext: PaginationFn;\n loadPrevious: PaginationFn;\n hasNext: boolean;\n hasPrevious: boolean;\n isLoadingNext: boolean;\n isLoadingPrevious: boolean;\n refetch: RefetchFn<TQuery[\"variables\"]>;\n} {\n invariant(\n !!fragmentInput.watchQueryDocument,\n \"usePaginationFragment is only supported at this time when using compilation\"\n );\n return useCompiledPaginationFragment(\n fragmentInput as any,\n fragmentRef as any\n );\n}\n\n// https://github.com/facebook/relay/blob/master/website/docs/api-reference/types/GraphQLSubscriptionConfig.md\ninterface GraphQLSubscriptionConfig<\n TSubscriptionPayload extends OperationType\n> {\n subscription: GraphQLTaggedNode;\n variables: TSubscriptionPayload[\"variables\"];\n /**\n * Should response be nullable?\n */\n onNext?: (response: TSubscriptionPayload[\"response\"]) => void;\n onError?: (error: Error) => void;\n}\n\n/**\n * @see {@link https://microsoft.github.io/graphitation/docs/apollo-react-relay-duct-tape/use-subscription}\n *\n * @param config\n */\nexport function useSubscription<TSubscriptionPayload extends OperationType>(\n config: GraphQLSubscriptionConfig<TSubscriptionPayload>\n): void {\n const { error } = useApolloSubscription(\n // TODO: Right now we don't replace mutation documents with imported artefacts.\n config.subscription as DocumentNode,\n {\n variables: config.variables,\n onSubscriptionData: ({ subscriptionData }) => {\n // Supposedly this never gets triggered for an error by design:\n // https://github.com/apollographql/react-apollo/issues/3177#issuecomment-506758144\n invariant(\n !subscriptionData.error,\n \"Did not expect to receive an error here\"\n );\n if (subscriptionData.data && config.onNext) {\n config.onNext(subscriptionData.data);\n }\n },\n }\n );\n if (error) {\n if (config.onError) {\n config.onError(error);\n } else {\n console.warn(\n `An unhandled GraphQL subscription error occurred: ${error.message}`\n );\n }\n }\n}\n\ninterface IMutationCommitterOptions<TMutationPayload extends OperationType> {\n variables: TMutationPayload[\"variables\"];\n optimisticResponse?: Partial<TMutationPayload[\"response\"]> | null;\n}\n\ntype MutationCommiter<TMutationPayload extends OperationType> = (\n options: IMutationCommitterOptions<TMutationPayload>\n) => Promise<{ errors?: Error[]; data?: TMutationPayload[\"response\"] }>;\n\n/**\n * @see {@link https://microsoft.github.io/graphitation/docs/apollo-react-relay-duct-tape/use-mutation}\n *\n * @param mutation\n * @returns\n */\nexport function useMutation<TMutationPayload extends OperationType>(\n mutation: GraphQLTaggedNode\n): [MutationCommiter<TMutationPayload>, boolean] {\n const [apolloUpdater, { loading: mutationLoading }] = useApolloMutation(\n // TODO: Right now we don't replace mutation documents with imported artefacts.\n mutation as DocumentNode\n );\n\n return [\n async (options: IMutationCommitterOptions<TMutationPayload>) => {\n const apolloResult = await apolloUpdater({\n variables: options.variables || {},\n optimisticResponse: options.optimisticResponse,\n });\n if (apolloResult.errors) {\n return {\n errors: Array.from(Object.values(apolloResult.errors)),\n data: apolloResult.data,\n };\n }\n return {\n data: apolloResult.data,\n };\n },\n mutationLoading,\n ];\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,uBAAsB;AACtB,oBAIO;AASP,2BAOO;AACP,gCAAmC;AAgB5B,0BACL,OACA,WACA,SAC8C;AAC9C,QAAM,gBAAgB,WAAW,4BAC5B,UAD4B;AAAA,IAE/B,aAAa,kDAAmB,QAAQ;AAAA;AAE1C,MAAI,MAAM,oBAAoB;AAC5B,WAAO,mDAAyB,OAAc;AAAA,MAC5C;AAAA,OACG;AAAA,SAEA;AACL,WAAO,4BAAe,OAAO,aAAE,YAAc;AAAA;AAAA;AAwB1C,qBACL,eACA,aACmB;AACnB,MAAI,cAAc,oBAAoB;AACpC,WAAO,8CAAoB,eAAe;AAAA,SACrC;AACL,WAAO;AAAA;AAAA;AAcJ,gCAIL,eACA,aACoE;AACpE,gCACE,CAAC,CAAC,cAAc,oBAChB;AAEF,SAAO,yDACL,eACA;AAAA;AAcG,+BAIL,eACA,aAUA;AACA,gCACE,CAAC,CAAC,cAAc,oBAChB;AAEF,SAAO,wDACL,eACA;AAAA;AAsBG,yBACL,QACM;AACN,QAAM,CAAE,SAAU,mCAEhB,OAAO,cACP;AAAA,IACE,WAAW,OAAO;AAAA,IAClB,oBAAoB,CAAC,CAAE,sBAAuB;AAG5C,oCACE,CAAC,iBAAiB,OAClB;AAEF,UAAI,iBAAiB,QAAQ,OAAO,QAAQ;AAC1C,eAAO,OAAO,iBAAiB;AAAA;AAAA;AAAA;AAKvC,MAAI,OAAO;AACT,QAAI,OAAO,SAAS;AAClB,aAAO,QAAQ;AAAA,WACV;AACL,cAAQ,KACN,qDAAqD,MAAM;AAAA;AAAA;AAAA;AAqB5D,qBACL,UAC+C;AAC/C,QAAM,CAAC,eAAe,CAAE,SAAS,oBAAqB,+BAEpD;AAGF,SAAO;AAAA,IACL,CAAO,YAAyD;AAC9D,YAAM,eAAe,MAAM,cAAc;AAAA,QACvC,WAAW,QAAQ,aAAa;AAAA,QAChC,oBAAoB,QAAQ;AAAA;AAE9B,UAAI,aAAa,QAAQ;AACvB,eAAO;AAAA,UACL,QAAQ,MAAM,KAAK,OAAO,OAAO,aAAa;AAAA,UAC9C,MAAM,aAAa;AAAA;AAAA;AAGvB,aAAO;AAAA,QACL,MAAM,aAAa;AAAA;AAAA;AAAA,IAGvB;AAAA;AAAA;",
6
+ "names": []
7
+ }
package/lib/hooks.mjs ADDED
@@ -0,0 +1,125 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
3
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
4
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {enumerable: true, configurable: true, writable: true, value}) : obj[key] = value;
6
+ var __objSpread = (a, b) => {
7
+ for (var prop in b || (b = {}))
8
+ if (__hasOwnProp.call(b, prop))
9
+ __defNormalProp(a, prop, b[prop]);
10
+ if (__getOwnPropSymbols)
11
+ for (var prop of __getOwnPropSymbols(b)) {
12
+ if (__propIsEnum.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ }
15
+ return a;
16
+ };
17
+ var __async = (__this, __arguments, generator) => {
18
+ return new Promise((resolve, reject) => {
19
+ var fulfilled = (value) => {
20
+ try {
21
+ step(generator.next(value));
22
+ } catch (e) {
23
+ reject(e);
24
+ }
25
+ };
26
+ var rejected = (value) => {
27
+ try {
28
+ step(generator.throw(value));
29
+ } catch (e) {
30
+ reject(e);
31
+ }
32
+ };
33
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
34
+ step((generator = generator.apply(__this, __arguments)).next());
35
+ });
36
+ };
37
+
38
+ // src/hooks.ts
39
+ import invariant from "invariant";
40
+ import {
41
+ useSubscription as useApolloSubscription,
42
+ useQuery as useApolloQuery,
43
+ useMutation as useApolloMutation
44
+ } from "@apollo/client";
45
+ import {
46
+ useCompiledLazyLoadQuery,
47
+ useCompiledFragment,
48
+ useCompiledRefetchableFragment,
49
+ useCompiledPaginationFragment
50
+ } from "./storeObservation/compiledHooks/index.mjs";
51
+ import {convertFetchPolicy} from "./convertFetchPolicy.mjs";
52
+ function useLazyLoadQuery(query, variables, options) {
53
+ const apolloOptions = options && __objSpread(__objSpread({}, options), {
54
+ fetchPolicy: convertFetchPolicy(options.fetchPolicy)
55
+ });
56
+ if (query.watchQueryDocument) {
57
+ return useCompiledLazyLoadQuery(query, __objSpread({
58
+ variables
59
+ }, apolloOptions));
60
+ } else {
61
+ return useApolloQuery(query, __objSpread({variables}, apolloOptions));
62
+ }
63
+ }
64
+ function useFragment(fragmentInput, fragmentRef) {
65
+ if (fragmentInput.watchQueryDocument) {
66
+ return useCompiledFragment(fragmentInput, fragmentRef);
67
+ } else {
68
+ return fragmentRef;
69
+ }
70
+ }
71
+ function useRefetchableFragment(fragmentInput, fragmentRef) {
72
+ invariant(!!fragmentInput.watchQueryDocument, "useRefetchableFragment is only supported at this time when using compilation");
73
+ return useCompiledRefetchableFragment(fragmentInput, fragmentRef);
74
+ }
75
+ function usePaginationFragment(fragmentInput, fragmentRef) {
76
+ invariant(!!fragmentInput.watchQueryDocument, "usePaginationFragment is only supported at this time when using compilation");
77
+ return useCompiledPaginationFragment(fragmentInput, fragmentRef);
78
+ }
79
+ function useSubscription(config) {
80
+ const {error} = useApolloSubscription(config.subscription, {
81
+ variables: config.variables,
82
+ onSubscriptionData: ({subscriptionData}) => {
83
+ invariant(!subscriptionData.error, "Did not expect to receive an error here");
84
+ if (subscriptionData.data && config.onNext) {
85
+ config.onNext(subscriptionData.data);
86
+ }
87
+ }
88
+ });
89
+ if (error) {
90
+ if (config.onError) {
91
+ config.onError(error);
92
+ } else {
93
+ console.warn(`An unhandled GraphQL subscription error occurred: ${error.message}`);
94
+ }
95
+ }
96
+ }
97
+ function useMutation(mutation) {
98
+ const [apolloUpdater, {loading: mutationLoading}] = useApolloMutation(mutation);
99
+ return [
100
+ (options) => __async(this, null, function* () {
101
+ const apolloResult = yield apolloUpdater({
102
+ variables: options.variables || {},
103
+ optimisticResponse: options.optimisticResponse
104
+ });
105
+ if (apolloResult.errors) {
106
+ return {
107
+ errors: Array.from(Object.values(apolloResult.errors)),
108
+ data: apolloResult.data
109
+ };
110
+ }
111
+ return {
112
+ data: apolloResult.data
113
+ };
114
+ }),
115
+ mutationLoading
116
+ ];
117
+ }
118
+ export {
119
+ useFragment,
120
+ useLazyLoadQuery,
121
+ useMutation,
122
+ usePaginationFragment,
123
+ useRefetchableFragment,
124
+ useSubscription
125
+ };
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/hooks.ts"],
4
+ "sourcesContent": ["import { DocumentNode } from \"graphql\";\nimport invariant from \"invariant\";\nimport {\n useSubscription as useApolloSubscription,\n useQuery as useApolloQuery,\n useMutation as useApolloMutation,\n} from \"@apollo/client\";\n\nimport {\n FetchPolicy,\n GraphQLTaggedNode,\n KeyType,\n KeyTypeData,\n OperationType,\n} from \"./types\";\nimport {\n RefetchFn,\n PaginationFn,\n useCompiledLazyLoadQuery,\n useCompiledFragment,\n useCompiledRefetchableFragment,\n useCompiledPaginationFragment,\n} from \"./storeObservation/compiledHooks\";\nimport { convertFetchPolicy } from \"./convertFetchPolicy\";\n\n/**\n * Executes a GraphQL query.\n *\n * This hook is called 'lazy' as it is used to fetch a GraphQL query _during_ render. This hook can trigger multiple\n * round trips, one for loading and one for resolving.\n *\n * @see {@link https://microsoft.github.io/graphitation/docs/apollo-react-relay-duct-tape/use-lazy-load-query}\n *\n * @param query The query operation to perform.\n * @param variables Object containing the variable values to fetch the query. These variables need to match GraphQL\n * variables declared inside the query.\n * @param options Options passed on to the underlying implementation.\n * @returns An object with either an error, the result data, or neither while loading.\n */\nexport function useLazyLoadQuery<TQuery extends OperationType>(\n query: GraphQLTaggedNode,\n variables: TQuery[\"variables\"],\n options?: { fetchPolicy?: FetchPolicy }\n): { error?: Error; data?: TQuery[\"response\"] } {\n const apolloOptions = options && {\n ...options,\n fetchPolicy: convertFetchPolicy(options.fetchPolicy),\n };\n if (query.watchQueryDocument) {\n return useCompiledLazyLoadQuery(query as any, {\n variables,\n ...apolloOptions,\n });\n } else {\n return useApolloQuery(query, { variables, ...apolloOptions });\n }\n}\n\n/**\n * A first-class way for an individual component to express its direct data requirements using GraphQL. The fragment\n * should select all the fields that the component directly uses in its rendering or needs to pass to external\n * functions. It should *not* select data that its children need, unless those children are intended to remain their\n * pure React props as data inputs.\n *\n * For children that *do* have their own data requirements expressed using GraphQL, the fragment should ensure to\n * spread in the child's fragment.\n *\n * @see {@link https://microsoft.github.io/graphitation/docs/apollo-react-relay-duct-tape/use-fragment}\n *\n * @note For now, the fragment objects should be exported such that parent's can interpolate them into their own\n * GraphQL documents. This may change in the future when/if we entirely switch to static compilation and will\n * allow us to also move the usage of the graphql tagged template function inline at the `useFragment` call-site.\n *\n * @param fragmentInput The GraphQL fragment document created using the `graphql` tagged template function.\n * @param fragmentRef The opaque fragment reference passed in by a parent component that has spread in this component's\n * fragment.\n * @returns The data corresponding to the field selections.\n */\nexport function useFragment<TKey extends KeyType>(\n fragmentInput: GraphQLTaggedNode,\n fragmentRef: TKey\n): KeyTypeData<TKey> {\n if (fragmentInput.watchQueryDocument) {\n return useCompiledFragment(fragmentInput, fragmentRef as any);\n } else {\n return fragmentRef as unknown;\n }\n}\n\n/**\n * Equivalent to `useFragment`, but allows refetching of its subtree of the overall query.\n *\n * @see {@link https://microsoft.github.io/graphitation/docs/apollo-react-relay-duct-tape/use-refetchable-fragment}\n *\n * @param fragmentInput The GraphQL fragment document created using the `graphql` tagged template function.\n * @param fragmentRef The opaque fragment reference passed in by a parent component that has spread in this component's\n * fragment.\n * @returns The data corresponding to the field selections and a function to perform the refetch.\n */\nexport function useRefetchableFragment<\n TQuery extends OperationType,\n TKey extends KeyType\n>(\n fragmentInput: GraphQLTaggedNode,\n fragmentRef: TKey\n): [data: KeyTypeData<TKey>, refetch: RefetchFn<TQuery[\"variables\"]>] {\n invariant(\n !!fragmentInput.watchQueryDocument,\n \"useRefetchableFragment is only supported at this time when using compilation\"\n );\n return useCompiledRefetchableFragment(\n fragmentInput as any,\n fragmentRef as any\n );\n}\n\n/**\n * Equivalent to `useFragment`, but allows pagination of its subtree of the overall query.\n *\n * @see {@link https://microsoft.github.io/graphitation/docs/apollo-react-relay-duct-tape/use-pagination-fragment}\n *\n * @param fragmentInput The GraphQL fragment document created using the `graphql` tagged template function.\n * @param fragmentRef The opaque fragment reference passed in by a parent component that has spread in this component's\n * fragment.\n * @returns The data corresponding to the field selections and functions to deal with pagination.\n */\nexport function usePaginationFragment<\n TQuery extends OperationType,\n TKey extends KeyType\n>(\n fragmentInput: GraphQLTaggedNode,\n fragmentRef: TKey\n): {\n data: KeyTypeData<TKey>;\n loadNext: PaginationFn;\n loadPrevious: PaginationFn;\n hasNext: boolean;\n hasPrevious: boolean;\n isLoadingNext: boolean;\n isLoadingPrevious: boolean;\n refetch: RefetchFn<TQuery[\"variables\"]>;\n} {\n invariant(\n !!fragmentInput.watchQueryDocument,\n \"usePaginationFragment is only supported at this time when using compilation\"\n );\n return useCompiledPaginationFragment(\n fragmentInput as any,\n fragmentRef as any\n );\n}\n\n// https://github.com/facebook/relay/blob/master/website/docs/api-reference/types/GraphQLSubscriptionConfig.md\ninterface GraphQLSubscriptionConfig<\n TSubscriptionPayload extends OperationType\n> {\n subscription: GraphQLTaggedNode;\n variables: TSubscriptionPayload[\"variables\"];\n /**\n * Should response be nullable?\n */\n onNext?: (response: TSubscriptionPayload[\"response\"]) => void;\n onError?: (error: Error) => void;\n}\n\n/**\n * @see {@link https://microsoft.github.io/graphitation/docs/apollo-react-relay-duct-tape/use-subscription}\n *\n * @param config\n */\nexport function useSubscription<TSubscriptionPayload extends OperationType>(\n config: GraphQLSubscriptionConfig<TSubscriptionPayload>\n): void {\n const { error } = useApolloSubscription(\n // TODO: Right now we don't replace mutation documents with imported artefacts.\n config.subscription as DocumentNode,\n {\n variables: config.variables,\n onSubscriptionData: ({ subscriptionData }) => {\n // Supposedly this never gets triggered for an error by design:\n // https://github.com/apollographql/react-apollo/issues/3177#issuecomment-506758144\n invariant(\n !subscriptionData.error,\n \"Did not expect to receive an error here\"\n );\n if (subscriptionData.data && config.onNext) {\n config.onNext(subscriptionData.data);\n }\n },\n }\n );\n if (error) {\n if (config.onError) {\n config.onError(error);\n } else {\n console.warn(\n `An unhandled GraphQL subscription error occurred: ${error.message}`\n );\n }\n }\n}\n\ninterface IMutationCommitterOptions<TMutationPayload extends OperationType> {\n variables: TMutationPayload[\"variables\"];\n optimisticResponse?: Partial<TMutationPayload[\"response\"]> | null;\n}\n\ntype MutationCommiter<TMutationPayload extends OperationType> = (\n options: IMutationCommitterOptions<TMutationPayload>\n) => Promise<{ errors?: Error[]; data?: TMutationPayload[\"response\"] }>;\n\n/**\n * @see {@link https://microsoft.github.io/graphitation/docs/apollo-react-relay-duct-tape/use-mutation}\n *\n * @param mutation\n * @returns\n */\nexport function useMutation<TMutationPayload extends OperationType>(\n mutation: GraphQLTaggedNode\n): [MutationCommiter<TMutationPayload>, boolean] {\n const [apolloUpdater, { loading: mutationLoading }] = useApolloMutation(\n // TODO: Right now we don't replace mutation documents with imported artefacts.\n mutation as DocumentNode\n );\n\n return [\n async (options: IMutationCommitterOptions<TMutationPayload>) => {\n const apolloResult = await apolloUpdater({\n variables: options.variables || {},\n optimisticResponse: options.optimisticResponse,\n });\n if (apolloResult.errors) {\n return {\n errors: Array.from(Object.values(apolloResult.errors)),\n data: apolloResult.data,\n };\n }\n return {\n data: apolloResult.data,\n };\n },\n mutationLoading,\n ];\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAaA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA;AAgBO,0BACL,OACA,WACA,SAC8C;AAC9C,QAAM,gBAAgB,WAAW,4BAC5B,UAD4B;AAAA,IAE/B,aAAa,mBAAmB,QAAQ;AAAA;AAE1C,MAAI,MAAM,oBAAoB;AAC5B,WAAO,yBAAyB,OAAc;AAAA,MAC5C;AAAA,OACG;AAAA,SAEA;AACL,WAAO,eAAe,OAAO,aAAE,YAAc;AAAA;AAAA;AAwB1C,qBACL,eACA,aACmB;AACnB,MAAI,cAAc,oBAAoB;AACpC,WAAO,oBAAoB,eAAe;AAAA,SACrC;AACL,WAAO;AAAA;AAAA;AAcJ,gCAIL,eACA,aACoE;AACpE,YACE,CAAC,CAAC,cAAc,oBAChB;AAEF,SAAO,+BACL,eACA;AAAA;AAcG,+BAIL,eACA,aAUA;AACA,YACE,CAAC,CAAC,cAAc,oBAChB;AAEF,SAAO,8BACL,eACA;AAAA;AAsBG,yBACL,QACM;AACN,QAAM,CAAE,SAAU,sBAEhB,OAAO,cACP;AAAA,IACE,WAAW,OAAO;AAAA,IAClB,oBAAoB,CAAC,CAAE,sBAAuB;AAG5C,gBACE,CAAC,iBAAiB,OAClB;AAEF,UAAI,iBAAiB,QAAQ,OAAO,QAAQ;AAC1C,eAAO,OAAO,iBAAiB;AAAA;AAAA;AAAA;AAKvC,MAAI,OAAO;AACT,QAAI,OAAO,SAAS;AAClB,aAAO,QAAQ;AAAA,WACV;AACL,cAAQ,KACN,qDAAqD,MAAM;AAAA;AAAA;AAAA;AAqB5D,qBACL,UAC+C;AAC/C,QAAM,CAAC,eAAe,CAAE,SAAS,oBAAqB,kBAEpD;AAGF,SAAO;AAAA,IACL,CAAO,YAAyD;AAC9D,YAAM,eAAe,MAAM,cAAc;AAAA,QACvC,WAAW,QAAQ,aAAa;AAAA,QAChC,oBAAoB,QAAQ;AAAA;AAE9B,UAAI,aAAa,QAAQ;AACvB,eAAO;AAAA,UACL,QAAQ,MAAM,KAAK,OAAO,OAAO,aAAa;AAAA,UAC9C,MAAM,aAAa;AAAA;AAAA;AAGvB,aAAO;AAAA,QACL,MAAM,aAAa;AAAA;AAAA;AAAA,IAGvB;AAAA;AAAA;",
6
+ "names": []
7
+ }
package/lib/index.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ export * from "./hooks";
2
+ export * from "./types";
3
+ export * from "./storeObservation";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,oBAAoB,CAAC"}
package/lib/index.js ADDED
@@ -0,0 +1,22 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getProtoOf = Object.getPrototypeOf;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
+ var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
8
+ var __reExport = (target, module2, desc) => {
9
+ if (module2 && typeof module2 === "object" || typeof module2 === "function") {
10
+ for (let key of __getOwnPropNames(module2))
11
+ if (!__hasOwnProp.call(target, key) && key !== "default")
12
+ __defProp(target, key, {get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable});
13
+ }
14
+ return target;
15
+ };
16
+ var __toModule = (module2) => {
17
+ return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? {get: () => module2.default, enumerable: true} : {value: module2, enumerable: true})), module2);
18
+ };
19
+ __markAsModule(exports);
20
+ __reExport(exports, __toModule(require("./hooks")));
21
+ __reExport(exports, __toModule(require("./types")));
22
+ __reExport(exports, __toModule(require("./storeObservation")));