relay-runtime 20.1.1 → 21.0.1

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 (334) hide show
  1. package/experimental.d.ts +34 -0
  2. package/experimental.js +1 -1
  3. package/experimental.js.flow +11 -11
  4. package/handlers/RelayDefaultHandlerProvider.d.ts +12 -0
  5. package/handlers/connection/ConnectionHandler.d.ts +51 -0
  6. package/handlers/connection/ConnectionHandler.js.flow +5 -5
  7. package/handlers/connection/ConnectionInterface.d.ts +40 -0
  8. package/handlers/connection/ConnectionInterface.js.flow +1 -1
  9. package/handlers/connection/MutationHandlers.d.ts +17 -0
  10. package/index.d.ts +274 -0
  11. package/index.js +1 -1
  12. package/index.js.flow +125 -62
  13. package/lib/experimental.js +3 -3
  14. package/lib/index.js +105 -57
  15. package/lib/multi-actor-environment/ActorIdentifier.js +2 -2
  16. package/lib/multi-actor-environment/MultiActorEnvironment.js +3 -1
  17. package/lib/mutations/commitMutation.js +8 -8
  18. package/lib/mutations/validateMutation.js +4 -4
  19. package/lib/query/GraphQLTag.js +3 -3
  20. package/lib/query/fetchQuery.js +15 -3
  21. package/lib/store/DataChecker.js +38 -4
  22. package/lib/store/NormalizationEngine.js +373 -0
  23. package/lib/store/OperationExecutor.js +172 -113
  24. package/lib/store/RelayConcreteVariables.js +1 -1
  25. package/lib/store/RelayErrorTrie.js +2 -2
  26. package/lib/store/RelayExperimentalGraphResponseTransform.js +8 -8
  27. package/lib/store/RelayModernEnvironment.js +26 -19
  28. package/lib/store/RelayModernRecord.js +18 -8
  29. package/lib/store/RelayModernSelector.js +9 -9
  30. package/lib/store/RelayModernStore.js +152 -43
  31. package/lib/store/RelayPublishQueue.js +1 -1
  32. package/lib/store/RelayReader.js +76 -38
  33. package/lib/store/RelayRecordSource.js +6 -0
  34. package/lib/store/RelayReferenceMarker.js +2 -1
  35. package/lib/store/RelayResponseNormalizer.js +88 -55
  36. package/lib/store/RelayStoreSubscriptions.js +34 -10
  37. package/lib/store/RelayStoreUtils.js +8 -1
  38. package/lib/store/ResolverFragments.js +2 -2
  39. package/lib/store/live-resolvers/LiveResolverCache.js +25 -9
  40. package/lib/store/observeFragmentExperimental.js +17 -1
  41. package/lib/store/observeQueryExperimental.js +2 -2
  42. package/lib/subscription/requestSubscription.js +3 -3
  43. package/lib/util/RelayError.js +3 -0
  44. package/lib/util/RelayFeatureFlags.js +6 -2
  45. package/lib/util/RelayReplaySubject.js +4 -4
  46. package/lib/util/handlePotentialSnapshotErrors.js +2 -2
  47. package/lib/util/stableCopy.js +2 -2
  48. package/llm-docs/api-reference/entrypoint-apis/entrypoint-container.mdx +38 -0
  49. package/llm-docs/api-reference/entrypoint-apis/load-entrypoint.mdx +77 -0
  50. package/llm-docs/api-reference/entrypoint-apis/use-entrypoint-loader.mdx +99 -0
  51. package/llm-docs/api-reference/graphql/graphql-directives.mdx +378 -0
  52. package/llm-docs/api-reference/hooks/_use-lazy-load-query-extra.mdx +16 -0
  53. package/llm-docs/api-reference/hooks/load-query.mdx +84 -0
  54. package/llm-docs/api-reference/hooks/relay-environment-provider.mdx +78 -0
  55. package/llm-docs/api-reference/hooks/use-client-query.mdx +65 -0
  56. package/llm-docs/api-reference/hooks/use-fragment.mdx +69 -0
  57. package/llm-docs/api-reference/hooks/use-lazy-load-query.mdx +62 -0
  58. package/llm-docs/api-reference/hooks/use-mutation.mdx +94 -0
  59. package/llm-docs/api-reference/hooks/use-pagination-fragment.mdx +166 -0
  60. package/llm-docs/api-reference/hooks/use-prefetchable-forward-pagination-fragment.mdx +134 -0
  61. package/llm-docs/api-reference/hooks/use-preloaded-query.mdx +84 -0
  62. package/llm-docs/api-reference/hooks/use-query-loader.mdx +95 -0
  63. package/llm-docs/api-reference/hooks/use-refetchable-fragment.mdx +122 -0
  64. package/llm-docs/api-reference/hooks/use-relay-environment.mdx +37 -0
  65. package/llm-docs/api-reference/hooks/use-subscription.mdx +66 -0
  66. package/llm-docs/api-reference/relay-resolvers/docblock-format.mdx +321 -0
  67. package/llm-docs/api-reference/relay-resolvers/runtime-functions.mdx +94 -0
  68. package/llm-docs/api-reference/relay-runtime/commit-mutation.mdx +65 -0
  69. package/llm-docs/api-reference/relay-runtime/fetch-query.mdx +118 -0
  70. package/llm-docs/api-reference/relay-runtime/field-logger.mdx +170 -0
  71. package/llm-docs/api-reference/relay-runtime/observe-fragment.mdx +92 -0
  72. package/llm-docs/api-reference/relay-runtime/relay-environment.mdx +53 -0
  73. package/llm-docs/api-reference/relay-runtime/request-subscription.mdx +54 -0
  74. package/llm-docs/api-reference/relay-runtime/runtime-configuration.mdx +52 -0
  75. package/llm-docs/api-reference/relay-runtime/store.mdx +734 -0
  76. package/llm-docs/api-reference/relay-runtime/wait-for-fragment-data.mdx +89 -0
  77. package/llm-docs/api-reference/types/CacheConfig.mdx +8 -0
  78. package/llm-docs/api-reference/types/Disposable.mdx +4 -0
  79. package/llm-docs/api-reference/types/GraphQLSubscriptionConfig.mdx +17 -0
  80. package/llm-docs/api-reference/types/MutationConfig.mdx +31 -0
  81. package/llm-docs/api-reference/types/SelectorStoreUpdater.mdx +6 -0
  82. package/llm-docs/api-reference/types/UploadableMap.mdx +3 -0
  83. package/llm-docs/community/learning-resources.mdx +64 -0
  84. package/llm-docs/debugging/declarative-mutation-directives.mdx +34 -0
  85. package/llm-docs/debugging/disallowed-id-types-error.mdx +43 -0
  86. package/llm-docs/debugging/inconsistent-typename-error.mdx +47 -0
  87. package/llm-docs/debugging/relay-devtools.mdx +73 -0
  88. package/llm-docs/debugging/why-null.mdx +116 -0
  89. package/llm-docs/editor-support.mdx +55 -0
  90. package/llm-docs/error-reference/unknown-field.mdx +36 -0
  91. package/llm-docs/getting-started/babel-plugin.mdx +31 -0
  92. package/llm-docs/getting-started/compiler-config.mdx +25 -0
  93. package/llm-docs/getting-started/compiler.mdx +98 -0
  94. package/llm-docs/getting-started/lint-rules.mdx +87 -0
  95. package/llm-docs/getting-started/production.mdx +30 -0
  96. package/llm-docs/getting-started/quick-start.mdx +216 -0
  97. package/llm-docs/glossary/glossary.mdx +1040 -0
  98. package/llm-docs/guided-tour/list-data/advanced-pagination.mdx +157 -0
  99. package/llm-docs/guided-tour/list-data/connections.mdx +81 -0
  100. package/llm-docs/guided-tour/list-data/pagination.mdx +193 -0
  101. package/llm-docs/guided-tour/list-data/rendering-connections.mdx +112 -0
  102. package/llm-docs/guided-tour/list-data/streaming-pagination.mdx +87 -0
  103. package/llm-docs/guided-tour/managing-data-outside-react/retaining-queries.mdx +51 -0
  104. package/llm-docs/guided-tour/refetching/refetching-queries-with-different-data.mdx +337 -0
  105. package/llm-docs/guided-tour/refetching/refreshing-queries.mdx +350 -0
  106. package/llm-docs/guided-tour/rendering/environment.mdx +59 -0
  107. package/llm-docs/guided-tour/rendering/error-states.mdx +295 -0
  108. package/llm-docs/guided-tour/rendering/fragments.mdx +354 -0
  109. package/llm-docs/guided-tour/rendering/loading-states.mdx +245 -0
  110. package/llm-docs/guided-tour/rendering/queries.mdx +261 -0
  111. package/llm-docs/guided-tour/rendering/variables.mdx +233 -0
  112. package/llm-docs/guided-tour/reusing-cached-data/fetch-policies.mdx +56 -0
  113. package/llm-docs/guided-tour/reusing-cached-data/filling-in-missing-data.mdx +102 -0
  114. package/llm-docs/guided-tour/reusing-cached-data/introduction.mdx +22 -0
  115. package/llm-docs/guided-tour/reusing-cached-data/presence-of-data.mdx +93 -0
  116. package/llm-docs/guided-tour/reusing-cached-data/rendering-partially-cached-data.mdx +175 -0
  117. package/llm-docs/guided-tour/reusing-cached-data/staleness-of-data.mdx +116 -0
  118. package/llm-docs/guided-tour/updating-data/client-only-data.mdx +115 -0
  119. package/llm-docs/guided-tour/updating-data/graphql-mutations.mdx +334 -0
  120. package/llm-docs/guided-tour/updating-data/graphql-subscriptions.mdx +279 -0
  121. package/llm-docs/guided-tour/updating-data/imperatively-modifying-linked-fields.mdx +511 -0
  122. package/llm-docs/guided-tour/updating-data/imperatively-modifying-store-data-legacy.mdx +142 -0
  123. package/llm-docs/guided-tour/updating-data/imperatively-modifying-store-data.mdx +275 -0
  124. package/llm-docs/guided-tour/updating-data/introduction.mdx +25 -0
  125. package/llm-docs/guided-tour/updating-data/local-data-updates.mdx +71 -0
  126. package/llm-docs/guided-tour/updating-data/typesafe-updaters-faq.mdx +83 -0
  127. package/llm-docs/guided-tour/updating-data/updating-connections.mdx +592 -0
  128. package/llm-docs/guides/alias-directive.mdx +160 -0
  129. package/llm-docs/guides/catch-directive.mdx +167 -0
  130. package/llm-docs/guides/client-schema-extensions.mdx +208 -0
  131. package/llm-docs/guides/codemods.mdx +79 -0
  132. package/llm-docs/guides/data-driven-dependencies/client-3d.mdx +255 -0
  133. package/llm-docs/guides/data-driven-dependencies/configuration.mdx +127 -0
  134. package/llm-docs/guides/data-driven-dependencies/introduction.mdx +39 -0
  135. package/llm-docs/guides/data-driven-dependencies/server-3d.mdx +664 -0
  136. package/llm-docs/guides/document-comparison.mdx +106 -0
  137. package/llm-docs/guides/graphql-server-specification.mdx +453 -0
  138. package/llm-docs/guides/network-layer.mdx +69 -0
  139. package/llm-docs/guides/persisted-queries.mdx +328 -0
  140. package/llm-docs/guides/relay-resolvers/context.mdx +99 -0
  141. package/llm-docs/guides/relay-resolvers/defining-fields.mdx +151 -0
  142. package/llm-docs/guides/relay-resolvers/defining-types.mdx +164 -0
  143. package/llm-docs/guides/relay-resolvers/deprecated.mdx +27 -0
  144. package/llm-docs/guides/relay-resolvers/derived-fields.mdx +127 -0
  145. package/llm-docs/guides/relay-resolvers/descriptions.mdx +44 -0
  146. package/llm-docs/guides/relay-resolvers/enabling.mdx +41 -0
  147. package/llm-docs/guides/relay-resolvers/errors.mdx +64 -0
  148. package/llm-docs/guides/relay-resolvers/field-arguments.mdx +63 -0
  149. package/llm-docs/guides/relay-resolvers/introduction.mdx +62 -0
  150. package/llm-docs/guides/relay-resolvers/limitations.mdx +30 -0
  151. package/llm-docs/guides/relay-resolvers/live-fields.mdx +164 -0
  152. package/llm-docs/guides/relay-resolvers/return-types.mdx +161 -0
  153. package/llm-docs/guides/relay-resolvers/suspense.mdx +41 -0
  154. package/llm-docs/guides/required-directive.mdx +240 -0
  155. package/llm-docs/guides/semantic-nullability.mdx +93 -0
  156. package/llm-docs/guides/testing-relay-components.mdx +642 -0
  157. package/llm-docs/guides/testing-relay-with-preloaded-queries.mdx +160 -0
  158. package/llm-docs/guides/throw-on-field-error-directive.mdx +58 -0
  159. package/llm-docs/guides/type-emission.mdx +414 -0
  160. package/llm-docs/home.mdx +32 -0
  161. package/llm-docs/principles-and-architecture/architecture-overview.mdx +24 -0
  162. package/llm-docs/principles-and-architecture/compiler-architecture.mdx +106 -0
  163. package/llm-docs/principles-and-architecture/runtime-architecture.mdx +249 -0
  164. package/llm-docs/principles-and-architecture/thinking-in-graphql.mdx +309 -0
  165. package/llm-docs/principles-and-architecture/thinking-in-relay.mdx +104 -0
  166. package/llm-docs/principles-and-architecture/videos.mdx +50 -0
  167. package/llm-docs/tutorial/arrays-lists.mdx +126 -0
  168. package/llm-docs/tutorial/fragments-1.mdx +487 -0
  169. package/llm-docs/tutorial/graphql.mdx +172 -0
  170. package/llm-docs/tutorial/interfaces-polymorphism.mdx +161 -0
  171. package/llm-docs/tutorial/intro.mdx +58 -0
  172. package/llm-docs/tutorial/mutations-updates.mdx +624 -0
  173. package/llm-docs/tutorial/organizing-mutations-queries-and-subscriptions.mdx +13 -0
  174. package/llm-docs/tutorial/queries-1.mdx +267 -0
  175. package/llm-docs/tutorial/queries-2.mdx +389 -0
  176. package/llm-docs/tutorial/refetchable-fragments.mdx +352 -0
  177. package/multi-actor-environment/ActorIdentifier.d.ts +17 -0
  178. package/multi-actor-environment/ActorIdentifier.js.flow +2 -2
  179. package/multi-actor-environment/ActorSpecificEnvironment.js.flow +15 -15
  180. package/multi-actor-environment/ActorUtils.js.flow +1 -1
  181. package/multi-actor-environment/MultiActorEnvironment.d.ts +123 -0
  182. package/multi-actor-environment/MultiActorEnvironment.js.flow +32 -24
  183. package/multi-actor-environment/MultiActorEnvironmentTypes.d.ts +225 -0
  184. package/multi-actor-environment/MultiActorEnvironmentTypes.js.flow +6 -6
  185. package/multi-actor-environment/index.d.ts +14 -0
  186. package/multi-actor-environment.d.ts +8 -0
  187. package/mutations/RelayDeclarativeMutationConfig.d.ts +70 -0
  188. package/mutations/RelayDeclarativeMutationConfig.js.flow +9 -9
  189. package/mutations/RelayRecordProxy.js.flow +8 -11
  190. package/mutations/RelayRecordSourceMutator.js.flow +4 -4
  191. package/mutations/RelayRecordSourceProxy.js.flow +4 -4
  192. package/mutations/RelayRecordSourceSelectorProxy.js.flow +6 -6
  193. package/mutations/applyOptimisticMutation.d.ts +25 -0
  194. package/mutations/applyOptimisticMutation.js.flow +2 -2
  195. package/mutations/commitLocalUpdate.d.ts +10 -0
  196. package/mutations/commitMutation.d.ts +48 -0
  197. package/mutations/commitMutation.js.flow +21 -17
  198. package/mutations/createUpdatableProxy.js.flow +19 -19
  199. package/mutations/readUpdatableFragment.js.flow +3 -3
  200. package/mutations/readUpdatableQuery.js.flow +3 -3
  201. package/mutations/validateMutation.js.flow +7 -7
  202. package/network/RelayNetwork.d.ts +12 -0
  203. package/network/RelayNetworkTypes.d.ts +145 -0
  204. package/network/RelayNetworkTypes.js.flow +18 -18
  205. package/network/RelayObservable.d.ts +197 -0
  206. package/network/RelayObservable.js.flow +32 -30
  207. package/network/RelayQueryResponseCache.d.ts +16 -0
  208. package/network/RelayQueryResponseCache.js.flow +3 -3
  209. package/network/wrapNetworkWithLogObserver.js.flow +1 -1
  210. package/package.json +2 -1
  211. package/query/GraphQLTag.d.ts +45 -0
  212. package/query/GraphQLTag.js.flow +22 -10
  213. package/query/fetchQuery.d.ts +21 -0
  214. package/query/fetchQuery.js.flow +23 -10
  215. package/query/fetchQueryInternal.d.ts +26 -0
  216. package/query/fetchQueryInternal.js.flow +4 -4
  217. package/query/fetchQuery_DEPRECATED.d.ts +17 -0
  218. package/query/fetchQuery_DEPRECATED.js.flow +1 -1
  219. package/store/ClientID.d.ts +14 -0
  220. package/store/DataChecker.js.flow +51 -15
  221. package/store/NormalizationEngine.js.flow +782 -0
  222. package/store/OperationExecutor.d.ts +51 -0
  223. package/store/OperationExecutor.js.flow +204 -98
  224. package/store/RelayConcreteVariables.js.flow +5 -5
  225. package/store/RelayErrorTrie.js.flow +12 -12
  226. package/store/RelayExperimentalGraphResponseHandler.js.flow +3 -3
  227. package/store/RelayExperimentalGraphResponseTransform.js.flow +10 -10
  228. package/store/RelayModernEnvironment.d.ts +97 -0
  229. package/store/RelayModernEnvironment.js.flow +58 -43
  230. package/store/RelayModernFragmentSpecResolver.js.flow +1 -1
  231. package/store/RelayModernOperationDescriptor.d.ts +28 -0
  232. package/store/RelayModernOperationDescriptor.js.flow +1 -1
  233. package/store/RelayModernRecord.d.ts +92 -0
  234. package/store/RelayModernRecord.js.flow +44 -20
  235. package/store/RelayModernSelector.d.ts +123 -0
  236. package/store/RelayModernSelector.js.flow +21 -21
  237. package/store/RelayModernStore.d.ts +57 -0
  238. package/store/RelayModernStore.js.flow +219 -58
  239. package/store/RelayOperationTracker.d.ts +29 -0
  240. package/store/RelayOperationTracker.js.flow +2 -2
  241. package/store/RelayOptimisticRecordSource.js.flow +2 -2
  242. package/store/RelayPublishQueue.js.flow +29 -20
  243. package/store/RelayReader.js.flow +129 -57
  244. package/store/RelayRecordSource.d.ts +26 -0
  245. package/store/RelayRecordSource.js.flow +10 -0
  246. package/store/RelayRecordState.d.ts +28 -0
  247. package/store/RelayRecordState.js.flow +1 -1
  248. package/store/RelayReferenceMarker.js.flow +5 -4
  249. package/store/RelayResponseNormalizer.d.ts +28 -0
  250. package/store/RelayResponseNormalizer.js.flow +130 -62
  251. package/store/RelayStoreSubscriptions.js.flow +52 -8
  252. package/store/RelayStoreTypes.d.ts +1327 -0
  253. package/store/RelayStoreTypes.js.flow +371 -278
  254. package/store/RelayStoreUtils.d.ts +86 -0
  255. package/store/RelayStoreUtils.js.flow +16 -8
  256. package/store/ResolverCache.js.flow +2 -2
  257. package/store/ResolverFragments.d.ts +43 -0
  258. package/store/ResolverFragments.js.flow +22 -14
  259. package/store/StoreInspector.js.flow +7 -8
  260. package/store/ViewerPattern.d.ts +11 -0
  261. package/store/cloneRelayHandleSourceField.js.flow +1 -1
  262. package/store/cloneRelayScalarHandleSourceField.js.flow +1 -1
  263. package/store/createFragmentSpecResolver.d.ts +16 -0
  264. package/store/createRelayContext.js.flow +1 -1
  265. package/store/createRelayLoggingContext.js.flow +4 -4
  266. package/store/defaultGetDataID.js.flow +2 -2
  267. package/store/isRelayModernEnvironment.d.ts +8 -0
  268. package/store/isRelayModernEnvironment.js.flow +4 -2
  269. package/store/live-resolvers/LiveResolverCache.js.flow +55 -20
  270. package/store/live-resolvers/LiveResolverSuspenseSentinel.js.flow +3 -3
  271. package/store/live-resolvers/getOutputTypeRecordIDs.js.flow +1 -1
  272. package/store/live-resolvers/isLiveStateValue.js.flow +2 -2
  273. package/store/live-resolvers/resolverDataInjector.d.ts +27 -0
  274. package/store/live-resolvers/resolverDataInjector.js.flow +8 -5
  275. package/store/observeFragmentExperimental.d.ts +46 -0
  276. package/store/observeFragmentExperimental.js.flow +50 -21
  277. package/store/observeQueryExperimental.d.ts +30 -0
  278. package/store/observeQueryExperimental.js.flow +5 -5
  279. package/store/readInlineData.d.ts +19 -0
  280. package/store/readInlineData.js.flow +5 -5
  281. package/store/waitForFragmentExperimental.d.ts +49 -0
  282. package/store/waitForFragmentExperimental.js.flow +3 -3
  283. package/subscription/requestSubscription.d.ts +27 -0
  284. package/subscription/requestSubscription.js.flow +10 -10
  285. package/util/JSResourceTypes.flow.js.flow +4 -4
  286. package/util/NormalizationNode.d.ts +235 -0
  287. package/util/NormalizationNode.js.flow +127 -123
  288. package/util/ReaderNode.d.ts +264 -0
  289. package/util/ReaderNode.js.flow +156 -151
  290. package/util/RelayConcreteNode.d.ts +120 -0
  291. package/util/RelayConcreteNode.js.flow +32 -32
  292. package/util/RelayError.d.ts +13 -0
  293. package/util/RelayError.js.flow +4 -1
  294. package/util/RelayFeatureFlags.d.ts +40 -0
  295. package/util/RelayFeatureFlags.js.flow +21 -1
  296. package/util/RelayProfiler.d.ts +121 -0
  297. package/util/RelayProfiler.js.flow +1 -1
  298. package/util/RelayReplaySubject.d.ts +25 -0
  299. package/util/RelayReplaySubject.js.flow +3 -3
  300. package/util/RelayRuntimeTypes.d.ts +59 -0
  301. package/util/RelayRuntimeTypes.js.flow +36 -33
  302. package/util/createPayloadFor3DField.d.ts +17 -0
  303. package/util/createPayloadFor3DField.js.flow +9 -5
  304. package/util/deepFreeze.d.ts +8 -0
  305. package/util/deepFreeze.js.flow +2 -2
  306. package/util/getFragmentIdentifier.d.ts +10 -0
  307. package/util/getFragmentIdentifier.js.flow +1 -1
  308. package/util/getPaginationMetadata.d.ts +20 -0
  309. package/util/getPaginationMetadata.js.flow +1 -1
  310. package/util/getPaginationVariables.d.ts +20 -0
  311. package/util/getPaginationVariables.js.flow +1 -1
  312. package/util/getPendingOperationsForFragment.d.ts +18 -0
  313. package/util/getPendingOperationsForFragment.js.flow +2 -2
  314. package/util/getRefetchMetadata.d.ts +19 -0
  315. package/util/getRefetchMetadata.js.flow +6 -5
  316. package/util/getRelayHandleKey.d.ts +8 -0
  317. package/util/getRequestIdentifier.d.ts +17 -0
  318. package/util/getValueAtPath.d.ts +8 -0
  319. package/util/getValueAtPath.js.flow +3 -3
  320. package/util/handlePotentialSnapshotErrors.d.ts +14 -0
  321. package/util/handlePotentialSnapshotErrors.js.flow +5 -5
  322. package/util/isEmptyObject.js.flow +1 -1
  323. package/util/isPromise.d.ts +8 -0
  324. package/util/isPromise.js.flow +2 -2
  325. package/util/isScalarAndEqual.d.ts +8 -0
  326. package/util/isScalarAndEqual.js.flow +1 -1
  327. package/util/recycleNodesInto.d.ts +8 -0
  328. package/util/recycleNodesInto.js.flow +2 -2
  329. package/util/registerEnvironmentWithDevTools.js.flow +1 -1
  330. package/util/shallowFreeze.js.flow +1 -1
  331. package/util/stableCopy.d.ts +8 -0
  332. package/util/stableCopy.js.flow +5 -5
  333. package/util/withProvidedVariables.d.ts +19 -0
  334. package/util/withProvidedVariables.js.flow +14 -10
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ declare const RelayError: {
9
+ create(name: string, messageFormat: string, ...messageParams: Array<string | number | boolean>): Error;
10
+ createWarning(name: string, messageFormat: string, ...messageParams: Array<string | number | boolean>): Error;
11
+ };
12
+
13
+ export default RelayError;
@@ -25,12 +25,15 @@ function createError(
25
25
  String(messageParams[index++]),
26
26
  );
27
27
  const err = new Error(message);
28
+ // messageParams[2] is the operation name
29
+ const operation = messageParams[2] ?? null;
28
30
  // $FlowFixMe[unsafe-object-assign]
29
- const error = Object.assign((err: any), {
31
+ const error = Object.assign(err as any, {
30
32
  name,
31
33
  messageFormat,
32
34
  messageParams,
33
35
  type,
36
+ operation,
34
37
  taalOpcodes: [2, 2], // skip frame (code=2) twice
35
38
  });
36
39
  // In V8, Error objects keep the closure scope chain alive until the
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ import { Disposable } from './RelayRuntimeTypes';
9
+
10
+ export interface FeatureFlags {
11
+ ENABLE_VARIABLE_CONNECTION_KEY: boolean;
12
+ ENABLE_RELAY_RESOLVERS: boolean;
13
+ ENABLE_GETFRAGMENTIDENTIFIER_OPTIMIZATION: boolean;
14
+ ENABLE_FRIENDLY_QUERY_NAME_GQL_URL: boolean;
15
+ ENABLE_DO_NOT_WRAP_LIVE_QUERY: boolean;
16
+ ENABLE_NOTIFY_SUBSCRIPTION: boolean;
17
+ BATCH_ASYNC_MODULE_UPDATES_FN: null | undefined | ((callback: () => void) => Disposable);
18
+ ENABLE_CONTAINERS_SUBSCRIBE_ON_COMMIT: boolean;
19
+ MAX_DATA_ID_LENGTH: number | null | undefined;
20
+ STRING_INTERN_LEVEL: number;
21
+ LOG_MISSING_RECORDS_IN_PROD: boolean;
22
+ ENABLE_RELAY_OPERATION_TRACKER_SUSPENSE: boolean;
23
+ ENABLE_UI_CONTEXT_ON_RELAY_LOGGER: boolean;
24
+ ENABLE_NONCOMPLIANT_ERROR_HANDLING_ON_LISTS: boolean;
25
+ ENABLE_LOOSE_SUBSCRIPTION_ATTRIBUTION: boolean;
26
+ ENABLE_OPERATION_TRACKER_OPTIMISTIC_UPDATES: boolean;
27
+ PROCESS_OPTIMISTIC_UPDATE_BEFORE_SUBSCRIPTION: boolean;
28
+ MARK_RESOLVER_VALUES_AS_CLEAN_AFTER_FRAGMENT_REREAD: boolean;
29
+ ENABLE_CYLE_DETECTION_IN_VARIABLES: boolean;
30
+ ENABLE_ACTIVITY_COMPATIBILITY: boolean;
31
+ ENABLE_READ_TIME_RESOLVER_STORAGE_KEY_PREFIX: boolean;
32
+ ENABLE_USE_PAGINATION_IS_LOADING_FIX: boolean;
33
+ ENABLE_STORE_ID_COLLISION_LOGGING: boolean;
34
+ DISALLOW_NESTED_UPDATES: boolean;
35
+ ENABLE_TYPENAME_PREFIXED_DATA_ID: boolean;
36
+ CHECK_ALL_FRAGMENTS_FOR_MISSING_CLIENT_EDGES: boolean;
37
+ ENABLE_READER_FRAGMENTS_LOGGING: boolean;
38
+ }
39
+
40
+ export const RelayFeatureFlags: FeatureFlags;
@@ -80,6 +80,22 @@ export type FeatureFlags = {
80
80
  //
81
81
  // See https://github.com/facebook/relay/issues/4882
82
82
  CHECK_ALL_FRAGMENTS_FOR_MISSING_CLIENT_EDGES: boolean,
83
+
84
+ // When enabled, records created for Relay Resolvers will be filtered out
85
+ // from the store when serializing to JSON.
86
+ FILTER_OUT_RELAY_RESOLVER_RECORDS: boolean,
87
+
88
+ // Reduce the work on store.notify
89
+ OPTIMIZE_NOTIFY: boolean,
90
+
91
+ // Enable per-field subscription granularity on specific records (e.g. client:root).
92
+ // When enabled, subscriptions reading a field-granular record are only notified
93
+ // when the specific fields they read have changed, rather than on any change
94
+ // to the record.
95
+ ENABLE_FIELD_GRANULAR_NOTIFICATIONS: boolean,
96
+
97
+ // Enable logging for reader reading fragment spreads and fragments. Useful for logging unused fragments.
98
+ ENABLE_READER_FRAGMENTS_LOGGING: boolean,
83
99
  };
84
100
 
85
101
  const RelayFeatureFlags: FeatureFlags = {
@@ -102,13 +118,17 @@ const RelayFeatureFlags: FeatureFlags = {
102
118
  PROCESS_OPTIMISTIC_UPDATE_BEFORE_SUBSCRIPTION: false,
103
119
  MARK_RESOLVER_VALUES_AS_CLEAN_AFTER_FRAGMENT_REREAD: false,
104
120
  ENABLE_CYLE_DETECTION_IN_VARIABLES: false,
105
- ENABLE_ACTIVITY_COMPATIBILITY: false,
121
+ ENABLE_ACTIVITY_COMPATIBILITY: true,
106
122
  ENABLE_READ_TIME_RESOLVER_STORAGE_KEY_PREFIX: true,
107
123
  ENABLE_USE_PAGINATION_IS_LOADING_FIX: false,
108
124
  DISALLOW_NESTED_UPDATES: false,
109
125
  ENABLE_TYPENAME_PREFIXED_DATA_ID: false,
110
126
  ENABLE_UI_CONTEXT_ON_RELAY_LOGGER: false,
111
127
  CHECK_ALL_FRAGMENTS_FOR_MISSING_CLIENT_EDGES: false,
128
+ FILTER_OUT_RELAY_RESOLVER_RECORDS: false,
129
+ OPTIMIZE_NOTIFY: false,
130
+ ENABLE_FIELD_GRANULAR_NOTIFICATIONS: false,
131
+ ENABLE_READER_FRAGMENTS_LOGGING: false,
112
132
  };
113
133
 
114
134
  module.exports = RelayFeatureFlags;
@@ -0,0 +1,121 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ export type Handler = (name: string, callback: () => void) => void;
9
+ export type ProfileHandler = (name: string, state?: any) => (error?: Error) => void;
10
+
11
+ /**
12
+ * Instruments methods to allow profiling various parts of Relay. Profiling code
13
+ * in Relay consists of three steps:
14
+ *
15
+ * - Instrument the function to be profiled.
16
+ * - Attach handlers to the instrumented function.
17
+ * - Run the code which triggers the handlers.
18
+ *
19
+ * Handlers attached to instrumented methods are called with an instrumentation
20
+ * name and a callback that must be synchronously executed:
21
+ *
22
+ * instrumentedMethod.attachHandler(function(name, callback) {
23
+ * const start = performance.now();
24
+ * callback();
25
+ * console.log('Duration', performance.now() - start);
26
+ * });
27
+ *
28
+ * Handlers for profiles are callbacks that return a stop method:
29
+ *
30
+ * RelayProfiler.attachProfileHandler('profileName', (name, state) => {
31
+ * const start = performance.now();
32
+ * return function stop(name, state) {
33
+ * console.log(`Duration (${name})`, performance.now() - start);
34
+ * }
35
+ * });
36
+ *
37
+ * In order to reduce the impact on performance in production, instrumented
38
+ * methods and profilers with names that begin with `@` will only be measured
39
+ * if `__DEV__` is true. This should be used for very hot functions.
40
+ */
41
+
42
+ export const RelayProfiler: {
43
+ /**
44
+ * Instruments methods on a class or object. This re-assigns the method in
45
+ * order to preserve function names in stack traces (which are detected by
46
+ * modern debuggers via heuristics). Example usage:
47
+ *
48
+ * const RelayStore = { primeCache: function() {...} };
49
+ * RelayProfiler.instrumentMethods(RelayStore, {
50
+ * primeCache: 'RelayStore.primeCache'
51
+ * });
52
+ *
53
+ * RelayStore.primeCache.attachHandler(...);
54
+ *
55
+ * As a result, the methods will be replaced by wrappers that provide the
56
+ * `attachHandler` and `detachHandler` methods.
57
+ */
58
+ instrumentMethods(object: () => void | object, names: { [key: string]: string }): void;
59
+
60
+ /**
61
+ * Wraps the supplied function with one that provides the `attachHandler` and
62
+ * `detachHandler` methods. Example usage:
63
+ *
64
+ * const printRelayQuery =
65
+ * RelayProfiler.instrument('printRelayQuery', printRelayQuery);
66
+ *
67
+ * printRelayQuery.attachHandler(...);
68
+ *
69
+ * NOTE: The instrumentation assumes that no handlers are attached or detached
70
+ * in the course of executing another handler.
71
+ */
72
+ instrument<T extends () => void>(name: string, originalFunction: T): T;
73
+
74
+ /**
75
+ * Attaches a handler to all methods instrumented with the supplied name.
76
+ *
77
+ * function createRenderer() {
78
+ * return RelayProfiler.instrument('render', function() {...});
79
+ * }
80
+ * const renderA = createRenderer();
81
+ * const renderB = createRenderer();
82
+ *
83
+ * // Only profiles `renderA`.
84
+ * renderA.attachHandler(...);
85
+ *
86
+ * // Profiles both `renderA` and `renderB`.
87
+ * RelayProfiler.attachAggregateHandler('render', ...);
88
+ */
89
+ attachAggregateHandler(name: string, handler: Handler): void;
90
+
91
+ /**
92
+ * Detaches a handler attached via `attachAggregateHandler`.
93
+ */
94
+ detachAggregateHandler(name: string, handler: Handler): void;
95
+
96
+ /**
97
+ * Instruments profiling for arbitrarily asynchronous code by a name.
98
+ *
99
+ * const timerProfiler = RelayProfiler.profile('timeout');
100
+ * setTimeout(function() {
101
+ * timerProfiler.stop();
102
+ * }, 1000);
103
+ *
104
+ * RelayProfiler.attachProfileHandler('timeout', ...);
105
+ *
106
+ * Arbitrary state can also be passed into `profile` as a second argument. The
107
+ * attached profile handlers will receive this as the second argument.
108
+ */
109
+ profile(name: string, state?: any): { stop: (error?: Error) => void };
110
+
111
+ /**
112
+ * Attaches a handler to profiles with the supplied name. You can also
113
+ * attach to the special name '*' which is a catch all.
114
+ */
115
+ attachProfileHandler(name: string, handler: ProfileHandler): void;
116
+
117
+ /**
118
+ * Detaches a handler attached via `attachProfileHandler`.
119
+ */
120
+ detachProfileHandler(name: string, handler: ProfileHandler): void;
121
+ };
@@ -18,7 +18,7 @@ const profileHandlersByName: {
18
18
  [name: EventName]: Array<ProfileHandler>,
19
19
  } = {};
20
20
 
21
- const defaultProfiler = {
21
+ const defaultProfiler: {stop: (error?: Error) => void, ...} = {
22
22
  stop() {},
23
23
  };
24
24
 
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ import type {Observer, Sink, Subscription} from '../network/RelayObservable';
9
+
10
+ export type Event<T> = { kind: 'next'; data: T } | { kind: 'error'; error: Error } | { kind: 'complete' };
11
+
12
+ /**
13
+ * An implementation of a `ReplaySubject` for Relay Observables.
14
+ *
15
+ * Records events provided and synchronously plays them back to new subscribers,
16
+ * as well as forwarding new asynchronous events.
17
+ */
18
+ export class RelayReplaySubject<T> {
19
+ complete(): void;
20
+ error(error: Error): void;
21
+ next(data: T): void;
22
+ subscribe(observer: Observer<T> | Sink<T>): Subscription;
23
+ unsubscribe(): void;
24
+ getObserverCount(): number;
25
+ }
@@ -64,7 +64,7 @@ class RelayReplaySubject<T> {
64
64
  sink.next(event.data);
65
65
  break;
66
66
  default:
67
- (event.kind: empty);
67
+ event.kind as empty;
68
68
  invariant(
69
69
  false,
70
70
  'RelayReplaySubject: Unknown event kind `%s`.',
@@ -96,8 +96,8 @@ class RelayReplaySubject<T> {
96
96
  }
97
97
  this._complete = true;
98
98
  this._events.push({
99
- kind: 'error',
100
99
  error,
100
+ kind: 'error',
101
101
  });
102
102
  this._sinks.forEach(sink => sink.error(error));
103
103
  }
@@ -107,8 +107,8 @@ class RelayReplaySubject<T> {
107
107
  return;
108
108
  }
109
109
  this._events.push({
110
- kind: 'next',
111
110
  data,
111
+ kind: 'next',
112
112
  });
113
113
  this._sinks.forEach(sink => sink.next(data));
114
114
  }
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ /**
9
+ * Represents any resource that must be explicitly disposed of. The most common
10
+ * use-case is as a return value for subscriptions, where calling `dispose()`
11
+ * would cancel the subscription.
12
+ */
13
+ export interface Disposable {
14
+ dispose: DisposeFn;
15
+ }
16
+
17
+ export type DataID = string;
18
+
19
+ export interface Variables {
20
+ [name: string]: any;
21
+ }
22
+
23
+ export interface OperationType {
24
+ readonly variables: Variables;
25
+ readonly response: unknown;
26
+ readonly rawResponse?: unknown | undefined;
27
+ }
28
+
29
+ export type VariablesOf<TQuery extends OperationType> = TQuery['variables'];
30
+
31
+ export type DisposeFn = () => void;
32
+
33
+ /**
34
+ * Settings for how a query response may be cached.
35
+ *
36
+ * - `force`: causes a query to be issued unconditionally, irrespective of the
37
+ * state of any configured response cache.
38
+ * - `poll`: causes a query to live update by polling at the specified interval
39
+ * in milliseconds. (This value will be passed to setTimeout.)
40
+ * - `liveConfigId`: causes a query to live update by calling GraphQLLiveQuery,
41
+ * it represents a configuration of gateway when doing live query
42
+ * - `metadata`: user-supplied metadata.
43
+ * - `transactionId`: a user-supplied value, intended for use as a unique id for
44
+ * a given instance of executing an operation.
45
+ */
46
+ export interface CacheConfig {
47
+ force?: boolean | null | undefined;
48
+ poll?: number | null | undefined;
49
+ liveConfigId?: string | null | undefined;
50
+ metadata?: { [key: string]: unknown } | undefined;
51
+ transactionId?: string | null | undefined;
52
+ }
53
+
54
+ /**
55
+ * Experimental
56
+ */
57
+ export type FetchQueryFetchPolicy = 'store-or-network' | 'network-only';
58
+ export type FetchPolicy = FetchQueryFetchPolicy | 'store-and-network' | 'store-only';
59
+ export type RenderPolicy = 'full' | 'partial';
@@ -32,19 +32,19 @@ export type Disposable = interface {dispose(): void};
32
32
  export type DataID = string;
33
33
 
34
34
  // Variables
35
- export type Variables = {+[string]: $FlowFixMe};
35
+ export type Variables = {readonly [string]: $FlowFixMe};
36
36
 
37
37
  /**
38
38
  * Generated operation flow types are subtypes of this.
39
39
  */
40
40
  export type OperationType = {
41
41
  // TODO(T33395812) Make this an open object type
42
- +variables: Variables,
43
- +response: mixed,
44
- +rawResponse?: {...},
42
+ readonly variables: Variables,
43
+ readonly response: unknown,
44
+ readonly rawResponse?: {...},
45
45
  };
46
46
 
47
- export type VariablesOf<T: OperationType> = T['variables'];
47
+ export type VariablesOf<T extends OperationType> = T['variables'];
48
48
 
49
49
  /**
50
50
  * Settings for how a query response may be cached.
@@ -62,14 +62,17 @@ export type VariablesOf<T: OperationType> = T['variables'];
62
62
  * a given instance of executing an operation.
63
63
  */
64
64
  export type CacheConfig = {
65
- +force?: ?boolean,
66
- +poll?: ?number,
67
- +liveConfigId?: ?string,
68
- +onSubscribe?: () => void,
69
- +onResume?: (pauseTimeMs: number) => void,
70
- +onPause?: (mqttConnectionIsOk: boolean, internetIsOk: boolean) => void,
71
- +metadata?: {+[key: string]: mixed, ...},
72
- +transactionId?: ?string,
65
+ readonly force?: ?boolean,
66
+ readonly poll?: ?number,
67
+ readonly liveConfigId?: ?string,
68
+ readonly onSubscribe?: () => void,
69
+ readonly onResume?: (pauseTimeMs: number) => void,
70
+ readonly onPause?: (
71
+ mqttConnectionIsOk: boolean,
72
+ internetIsOk: boolean,
73
+ ) => void,
74
+ readonly metadata?: {readonly [key: string]: unknown, ...},
75
+ readonly transactionId?: ?string,
73
76
  };
74
77
 
75
78
  export type FetchQueryFetchPolicy = 'store-or-network' | 'network-only';
@@ -86,8 +89,8 @@ export type RenderPolicy = 'full' | 'partial';
86
89
  * Return type of graphql tag literals for all operations.
87
90
  */
88
91
  declare export opaque type Operation<
89
- -TVariables: Variables,
90
- +TData,
92
+ in TVariables extends Variables,
93
+ out TData,
91
94
  TRawResponse,
92
95
  >: ConcreteRequest;
93
96
 
@@ -95,8 +98,8 @@ declare export opaque type Operation<
95
98
  * Return type of graphql tag literals for updatable queries.
96
99
  */
97
100
  declare export opaque type UpdatableQuery<
98
- -TVariables: Variables,
99
- +TData,
101
+ in TVariables extends Variables,
102
+ out TData,
100
103
  >: ConcreteUpdatableQuery;
101
104
 
102
105
  /**
@@ -104,15 +107,15 @@ declare export opaque type UpdatableQuery<
104
107
  */
105
108
  declare export opaque type UpdatableFragment<
106
109
  TFragmentType,
107
- +TData,
110
+ out TData,
108
111
  >: ReaderFragment;
109
112
 
110
113
  /**
111
114
  * Return type of graphql tag literals for queries.
112
115
  */
113
116
  declare export opaque type Query<
114
- -TVariables: Variables,
115
- +TData,
117
+ in TVariables extends Variables,
118
+ out TData,
116
119
  TRawResponse = void,
117
120
  >: Operation<TVariables, TData, TRawResponse>;
118
121
 
@@ -120,8 +123,8 @@ declare export opaque type Query<
120
123
  * Return type of graphql tag literals for client-only queries.
121
124
  */
122
125
  declare export opaque type ClientQuery<
123
- -TVariables: Variables,
124
- +TData,
126
+ in TVariables extends Variables,
127
+ out TData,
125
128
  TRawResponse = void,
126
129
  >: ClientRequest;
127
130
 
@@ -129,8 +132,8 @@ declare export opaque type ClientQuery<
129
132
  * Return type of graphql tag literals for mutations.
130
133
  */
131
134
  declare export opaque type Mutation<
132
- -TVariables: Variables,
133
- +TData,
135
+ in TVariables extends Variables,
136
+ out TData,
134
137
  TRawResponse = {...},
135
138
  >: Operation<TVariables, TData, TRawResponse>;
136
139
 
@@ -141,8 +144,8 @@ declare export opaque type Mutation<
141
144
  * `RelayObservable`'s `Subscription` type.
142
145
  */
143
146
  declare export opaque type GraphQLSubscription<
144
- -TVariables: Variables,
145
- +TData,
147
+ in TVariables extends Variables,
148
+ out TData,
146
149
  TRawResponse = void,
147
150
  >: Operation<TVariables, TData, TRawResponse>;
148
151
 
@@ -151,22 +154,22 @@ declare export opaque type GraphQLSubscription<
151
154
  */
152
155
  declare export opaque type InlineFragment<
153
156
  TFragmentType,
154
- +TData,
157
+ out TData,
155
158
  >: ReaderInlineDataFragment;
156
159
 
157
160
  /**
158
161
  * Return type of graphql tag literals for fragments, except `@inline`
159
162
  * fragments.
160
163
  */
161
- declare export opaque type Fragment<TFragmentType, +TData>: ReaderFragment;
164
+ declare export opaque type Fragment<TFragmentType, out TData>: ReaderFragment;
162
165
 
163
166
  /**
164
167
  * Return type of graphql tag literals for `@refetchable` fragments.
165
168
  */
166
169
  declare export opaque type RefetchableFragment<
167
170
  TFragmentType,
168
- +TData,
169
- TVariables: Variables,
171
+ out TData,
172
+ TVariables extends Variables,
170
173
  >: Fragment<TFragmentType, TData>;
171
174
 
172
175
  /**
@@ -175,7 +178,7 @@ declare export opaque type RefetchableFragment<
175
178
  */
176
179
  declare export opaque type PrefetchableRefetchableFragment<
177
180
  TFragmentType,
178
- +TData,
179
- +TEdgeData,
180
- TVariables: Variables,
181
+ out TData,
182
+ out TEdgeData,
183
+ TVariables extends Variables,
181
184
  >: Fragment<TFragmentType, TData>;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ import type {JSResourceReference, NormalizationSplitOperation} from './NormalizationNode';
9
+
10
+ export type Local3DPayload<_DocumentName extends string, Response extends Record<string, unknown>> = Response;
11
+
12
+ export default function createPayloadFor3DField<DocumentName extends string, Response extends Record<string, unknown>>(
13
+ name: DocumentName,
14
+ operation: JSResourceReference<NormalizationSplitOperation>,
15
+ component: JSResourceReference<unknown>,
16
+ response: Response,
17
+ ): Local3DPayload<DocumentName, Response>;
@@ -21,15 +21,19 @@ const {
21
21
 
22
22
  export opaque type Local3DPayload<
23
23
  // eslint-disable-next-line no-unused-vars
24
- +DocumentName: string,
25
- +Response: {...},
24
+ out DocumentName extends string,
25
+ out Response extends {...},
26
26
  > = Response;
27
27
 
28
- // $FlowFixMe[unsupported-variance-annotation]
29
- function createPayloadFor3DField<+DocumentName: string, +Response: {...}>(
28
+ function createPayloadFor3DField<
29
+ // $FlowFixMe[unsupported-variance-annotation]
30
+ out DocumentName extends string,
31
+ // $FlowFixMe[unsupported-variance-annotation]
32
+ out Response extends {...},
33
+ >(
30
34
  name: DocumentName,
31
35
  operation: JSResourceReference<NormalizationSplitOperation>,
32
- component: JSResourceReference<mixed>,
36
+ component: JSResourceReference<unknown>,
33
37
  response: Response,
34
38
  ): Local3DPayload<DocumentName, Response> {
35
39
  const data = {
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ export default function deepFreeze<T extends object>(value: T): T;
@@ -17,7 +17,7 @@
17
17
  * For convenience, and for consistency with the behavior of `Object.freeze`,
18
18
  * returns the now-frozen original object.
19
19
  */
20
- function deepFreeze<T: {...}>(object: T): T {
20
+ function deepFreeze<T extends {...}>(object: T): T {
21
21
  if (!shouldBeFrozen(object)) {
22
22
  return object;
23
23
  }
@@ -35,7 +35,7 @@ function deepFreeze<T: {...}>(object: T): T {
35
35
  return object;
36
36
  }
37
37
 
38
- function shouldBeFrozen(value: mixed): boolean {
38
+ function shouldBeFrozen(value: unknown): boolean {
39
39
  // Only freeze plain JS arrays and objects
40
40
  return (
41
41
  value != null &&
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ import { ReaderFragment } from './ReaderNode';
9
+
10
+ export default function getFragmentIdentifier(fragmentNode: ReaderFragment, fragmentRef: any): string;
@@ -25,7 +25,7 @@ const {intern} = require('./StringInterner');
25
25
 
26
26
  function getFragmentIdentifier(
27
27
  fragmentNode: ReaderFragment,
28
- fragmentRef: mixed,
28
+ fragmentRef: unknown,
29
29
  ): string {
30
30
  const selector = getSelector(fragmentNode, fragmentRef);
31
31
  const fragmentOwnerIdentifier =
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ import {ReaderFragment, ReaderPaginationMetadata} from './ReaderNode';
9
+ import { ConcreteRequest } from './RelayConcreteNode';
10
+
11
+ export default function getPaginationMetadata(
12
+ fragmentNode: ReaderFragment,
13
+ componentDisplayName: string,
14
+ ): {
15
+ connectionPathInFragmentData: ReadonlyArray<string | number>;
16
+ identifierField: string | null | undefined;
17
+ paginationRequest: ConcreteRequest;
18
+ paginationMetadata: ReaderPaginationMetadata;
19
+ stream: boolean;
20
+ };
@@ -21,7 +21,7 @@ function getPaginationMetadata(
21
21
  fragmentNode: ReaderFragment,
22
22
  componentDisplayName: string,
23
23
  ): {
24
- connectionPathInFragmentData: $ReadOnlyArray<string | number>,
24
+ connectionPathInFragmentData: ReadonlyArray<string | number>,
25
25
  identifierField: ?string,
26
26
  paginationRequest: ConcreteRequest,
27
27
  paginationMetadata: ReaderPaginationMetadata,
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ import { ReaderPaginationMetadata } from './ReaderNode';
9
+ import { Variables } from './RelayRuntimeTypes';
10
+
11
+ export type Direction = 'forward' | 'backward';
12
+
13
+ export default function getPaginationVariables(
14
+ direction: Direction,
15
+ count: number,
16
+ cursor: string | null | undefined,
17
+ baseVariables: Variables,
18
+ extraVariables: Variables,
19
+ paginationMetadata: ReaderPaginationMetadata,
20
+ ): { [key: string]: any };