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.
- package/experimental.d.ts +34 -0
- package/experimental.js +1 -1
- package/experimental.js.flow +11 -11
- package/handlers/RelayDefaultHandlerProvider.d.ts +12 -0
- package/handlers/connection/ConnectionHandler.d.ts +51 -0
- package/handlers/connection/ConnectionHandler.js.flow +5 -5
- package/handlers/connection/ConnectionInterface.d.ts +40 -0
- package/handlers/connection/ConnectionInterface.js.flow +1 -1
- package/handlers/connection/MutationHandlers.d.ts +17 -0
- package/index.d.ts +274 -0
- package/index.js +1 -1
- package/index.js.flow +125 -62
- package/lib/experimental.js +3 -3
- package/lib/index.js +105 -57
- package/lib/multi-actor-environment/ActorIdentifier.js +2 -2
- package/lib/multi-actor-environment/MultiActorEnvironment.js +3 -1
- package/lib/mutations/commitMutation.js +8 -8
- package/lib/mutations/validateMutation.js +4 -4
- package/lib/query/GraphQLTag.js +3 -3
- package/lib/query/fetchQuery.js +15 -3
- package/lib/store/DataChecker.js +38 -4
- package/lib/store/NormalizationEngine.js +373 -0
- package/lib/store/OperationExecutor.js +172 -113
- package/lib/store/RelayConcreteVariables.js +1 -1
- package/lib/store/RelayErrorTrie.js +2 -2
- package/lib/store/RelayExperimentalGraphResponseTransform.js +8 -8
- package/lib/store/RelayModernEnvironment.js +26 -19
- package/lib/store/RelayModernRecord.js +18 -8
- package/lib/store/RelayModernSelector.js +9 -9
- package/lib/store/RelayModernStore.js +152 -43
- package/lib/store/RelayPublishQueue.js +1 -1
- package/lib/store/RelayReader.js +76 -38
- package/lib/store/RelayRecordSource.js +6 -0
- package/lib/store/RelayReferenceMarker.js +2 -1
- package/lib/store/RelayResponseNormalizer.js +88 -55
- package/lib/store/RelayStoreSubscriptions.js +34 -10
- package/lib/store/RelayStoreUtils.js +8 -1
- package/lib/store/ResolverFragments.js +2 -2
- package/lib/store/live-resolvers/LiveResolverCache.js +25 -9
- package/lib/store/observeFragmentExperimental.js +17 -1
- package/lib/store/observeQueryExperimental.js +2 -2
- package/lib/subscription/requestSubscription.js +3 -3
- package/lib/util/RelayError.js +3 -0
- package/lib/util/RelayFeatureFlags.js +6 -2
- package/lib/util/RelayReplaySubject.js +4 -4
- package/lib/util/handlePotentialSnapshotErrors.js +2 -2
- package/lib/util/stableCopy.js +2 -2
- package/llm-docs/api-reference/entrypoint-apis/entrypoint-container.mdx +38 -0
- package/llm-docs/api-reference/entrypoint-apis/load-entrypoint.mdx +77 -0
- package/llm-docs/api-reference/entrypoint-apis/use-entrypoint-loader.mdx +99 -0
- package/llm-docs/api-reference/graphql/graphql-directives.mdx +378 -0
- package/llm-docs/api-reference/hooks/_use-lazy-load-query-extra.mdx +16 -0
- package/llm-docs/api-reference/hooks/load-query.mdx +84 -0
- package/llm-docs/api-reference/hooks/relay-environment-provider.mdx +78 -0
- package/llm-docs/api-reference/hooks/use-client-query.mdx +65 -0
- package/llm-docs/api-reference/hooks/use-fragment.mdx +69 -0
- package/llm-docs/api-reference/hooks/use-lazy-load-query.mdx +62 -0
- package/llm-docs/api-reference/hooks/use-mutation.mdx +94 -0
- package/llm-docs/api-reference/hooks/use-pagination-fragment.mdx +166 -0
- package/llm-docs/api-reference/hooks/use-prefetchable-forward-pagination-fragment.mdx +134 -0
- package/llm-docs/api-reference/hooks/use-preloaded-query.mdx +84 -0
- package/llm-docs/api-reference/hooks/use-query-loader.mdx +95 -0
- package/llm-docs/api-reference/hooks/use-refetchable-fragment.mdx +122 -0
- package/llm-docs/api-reference/hooks/use-relay-environment.mdx +37 -0
- package/llm-docs/api-reference/hooks/use-subscription.mdx +66 -0
- package/llm-docs/api-reference/relay-resolvers/docblock-format.mdx +321 -0
- package/llm-docs/api-reference/relay-resolvers/runtime-functions.mdx +94 -0
- package/llm-docs/api-reference/relay-runtime/commit-mutation.mdx +65 -0
- package/llm-docs/api-reference/relay-runtime/fetch-query.mdx +118 -0
- package/llm-docs/api-reference/relay-runtime/field-logger.mdx +170 -0
- package/llm-docs/api-reference/relay-runtime/observe-fragment.mdx +92 -0
- package/llm-docs/api-reference/relay-runtime/relay-environment.mdx +53 -0
- package/llm-docs/api-reference/relay-runtime/request-subscription.mdx +54 -0
- package/llm-docs/api-reference/relay-runtime/runtime-configuration.mdx +52 -0
- package/llm-docs/api-reference/relay-runtime/store.mdx +734 -0
- package/llm-docs/api-reference/relay-runtime/wait-for-fragment-data.mdx +89 -0
- package/llm-docs/api-reference/types/CacheConfig.mdx +8 -0
- package/llm-docs/api-reference/types/Disposable.mdx +4 -0
- package/llm-docs/api-reference/types/GraphQLSubscriptionConfig.mdx +17 -0
- package/llm-docs/api-reference/types/MutationConfig.mdx +31 -0
- package/llm-docs/api-reference/types/SelectorStoreUpdater.mdx +6 -0
- package/llm-docs/api-reference/types/UploadableMap.mdx +3 -0
- package/llm-docs/community/learning-resources.mdx +64 -0
- package/llm-docs/debugging/declarative-mutation-directives.mdx +34 -0
- package/llm-docs/debugging/disallowed-id-types-error.mdx +43 -0
- package/llm-docs/debugging/inconsistent-typename-error.mdx +47 -0
- package/llm-docs/debugging/relay-devtools.mdx +73 -0
- package/llm-docs/debugging/why-null.mdx +116 -0
- package/llm-docs/editor-support.mdx +55 -0
- package/llm-docs/error-reference/unknown-field.mdx +36 -0
- package/llm-docs/getting-started/babel-plugin.mdx +31 -0
- package/llm-docs/getting-started/compiler-config.mdx +25 -0
- package/llm-docs/getting-started/compiler.mdx +98 -0
- package/llm-docs/getting-started/lint-rules.mdx +87 -0
- package/llm-docs/getting-started/production.mdx +30 -0
- package/llm-docs/getting-started/quick-start.mdx +216 -0
- package/llm-docs/glossary/glossary.mdx +1040 -0
- package/llm-docs/guided-tour/list-data/advanced-pagination.mdx +157 -0
- package/llm-docs/guided-tour/list-data/connections.mdx +81 -0
- package/llm-docs/guided-tour/list-data/pagination.mdx +193 -0
- package/llm-docs/guided-tour/list-data/rendering-connections.mdx +112 -0
- package/llm-docs/guided-tour/list-data/streaming-pagination.mdx +87 -0
- package/llm-docs/guided-tour/managing-data-outside-react/retaining-queries.mdx +51 -0
- package/llm-docs/guided-tour/refetching/refetching-queries-with-different-data.mdx +337 -0
- package/llm-docs/guided-tour/refetching/refreshing-queries.mdx +350 -0
- package/llm-docs/guided-tour/rendering/environment.mdx +59 -0
- package/llm-docs/guided-tour/rendering/error-states.mdx +295 -0
- package/llm-docs/guided-tour/rendering/fragments.mdx +354 -0
- package/llm-docs/guided-tour/rendering/loading-states.mdx +245 -0
- package/llm-docs/guided-tour/rendering/queries.mdx +261 -0
- package/llm-docs/guided-tour/rendering/variables.mdx +233 -0
- package/llm-docs/guided-tour/reusing-cached-data/fetch-policies.mdx +56 -0
- package/llm-docs/guided-tour/reusing-cached-data/filling-in-missing-data.mdx +102 -0
- package/llm-docs/guided-tour/reusing-cached-data/introduction.mdx +22 -0
- package/llm-docs/guided-tour/reusing-cached-data/presence-of-data.mdx +93 -0
- package/llm-docs/guided-tour/reusing-cached-data/rendering-partially-cached-data.mdx +175 -0
- package/llm-docs/guided-tour/reusing-cached-data/staleness-of-data.mdx +116 -0
- package/llm-docs/guided-tour/updating-data/client-only-data.mdx +115 -0
- package/llm-docs/guided-tour/updating-data/graphql-mutations.mdx +334 -0
- package/llm-docs/guided-tour/updating-data/graphql-subscriptions.mdx +279 -0
- package/llm-docs/guided-tour/updating-data/imperatively-modifying-linked-fields.mdx +511 -0
- package/llm-docs/guided-tour/updating-data/imperatively-modifying-store-data-legacy.mdx +142 -0
- package/llm-docs/guided-tour/updating-data/imperatively-modifying-store-data.mdx +275 -0
- package/llm-docs/guided-tour/updating-data/introduction.mdx +25 -0
- package/llm-docs/guided-tour/updating-data/local-data-updates.mdx +71 -0
- package/llm-docs/guided-tour/updating-data/typesafe-updaters-faq.mdx +83 -0
- package/llm-docs/guided-tour/updating-data/updating-connections.mdx +592 -0
- package/llm-docs/guides/alias-directive.mdx +160 -0
- package/llm-docs/guides/catch-directive.mdx +167 -0
- package/llm-docs/guides/client-schema-extensions.mdx +208 -0
- package/llm-docs/guides/codemods.mdx +79 -0
- package/llm-docs/guides/data-driven-dependencies/client-3d.mdx +255 -0
- package/llm-docs/guides/data-driven-dependencies/configuration.mdx +127 -0
- package/llm-docs/guides/data-driven-dependencies/introduction.mdx +39 -0
- package/llm-docs/guides/data-driven-dependencies/server-3d.mdx +664 -0
- package/llm-docs/guides/document-comparison.mdx +106 -0
- package/llm-docs/guides/graphql-server-specification.mdx +453 -0
- package/llm-docs/guides/network-layer.mdx +69 -0
- package/llm-docs/guides/persisted-queries.mdx +328 -0
- package/llm-docs/guides/relay-resolvers/context.mdx +99 -0
- package/llm-docs/guides/relay-resolvers/defining-fields.mdx +151 -0
- package/llm-docs/guides/relay-resolvers/defining-types.mdx +164 -0
- package/llm-docs/guides/relay-resolvers/deprecated.mdx +27 -0
- package/llm-docs/guides/relay-resolvers/derived-fields.mdx +127 -0
- package/llm-docs/guides/relay-resolvers/descriptions.mdx +44 -0
- package/llm-docs/guides/relay-resolvers/enabling.mdx +41 -0
- package/llm-docs/guides/relay-resolvers/errors.mdx +64 -0
- package/llm-docs/guides/relay-resolvers/field-arguments.mdx +63 -0
- package/llm-docs/guides/relay-resolvers/introduction.mdx +62 -0
- package/llm-docs/guides/relay-resolvers/limitations.mdx +30 -0
- package/llm-docs/guides/relay-resolvers/live-fields.mdx +164 -0
- package/llm-docs/guides/relay-resolvers/return-types.mdx +161 -0
- package/llm-docs/guides/relay-resolvers/suspense.mdx +41 -0
- package/llm-docs/guides/required-directive.mdx +240 -0
- package/llm-docs/guides/semantic-nullability.mdx +93 -0
- package/llm-docs/guides/testing-relay-components.mdx +642 -0
- package/llm-docs/guides/testing-relay-with-preloaded-queries.mdx +160 -0
- package/llm-docs/guides/throw-on-field-error-directive.mdx +58 -0
- package/llm-docs/guides/type-emission.mdx +414 -0
- package/llm-docs/home.mdx +32 -0
- package/llm-docs/principles-and-architecture/architecture-overview.mdx +24 -0
- package/llm-docs/principles-and-architecture/compiler-architecture.mdx +106 -0
- package/llm-docs/principles-and-architecture/runtime-architecture.mdx +249 -0
- package/llm-docs/principles-and-architecture/thinking-in-graphql.mdx +309 -0
- package/llm-docs/principles-and-architecture/thinking-in-relay.mdx +104 -0
- package/llm-docs/principles-and-architecture/videos.mdx +50 -0
- package/llm-docs/tutorial/arrays-lists.mdx +126 -0
- package/llm-docs/tutorial/fragments-1.mdx +487 -0
- package/llm-docs/tutorial/graphql.mdx +172 -0
- package/llm-docs/tutorial/interfaces-polymorphism.mdx +161 -0
- package/llm-docs/tutorial/intro.mdx +58 -0
- package/llm-docs/tutorial/mutations-updates.mdx +624 -0
- package/llm-docs/tutorial/organizing-mutations-queries-and-subscriptions.mdx +13 -0
- package/llm-docs/tutorial/queries-1.mdx +267 -0
- package/llm-docs/tutorial/queries-2.mdx +389 -0
- package/llm-docs/tutorial/refetchable-fragments.mdx +352 -0
- package/multi-actor-environment/ActorIdentifier.d.ts +17 -0
- package/multi-actor-environment/ActorIdentifier.js.flow +2 -2
- package/multi-actor-environment/ActorSpecificEnvironment.js.flow +15 -15
- package/multi-actor-environment/ActorUtils.js.flow +1 -1
- package/multi-actor-environment/MultiActorEnvironment.d.ts +123 -0
- package/multi-actor-environment/MultiActorEnvironment.js.flow +32 -24
- package/multi-actor-environment/MultiActorEnvironmentTypes.d.ts +225 -0
- package/multi-actor-environment/MultiActorEnvironmentTypes.js.flow +6 -6
- package/multi-actor-environment/index.d.ts +14 -0
- package/multi-actor-environment.d.ts +8 -0
- package/mutations/RelayDeclarativeMutationConfig.d.ts +70 -0
- package/mutations/RelayDeclarativeMutationConfig.js.flow +9 -9
- package/mutations/RelayRecordProxy.js.flow +8 -11
- package/mutations/RelayRecordSourceMutator.js.flow +4 -4
- package/mutations/RelayRecordSourceProxy.js.flow +4 -4
- package/mutations/RelayRecordSourceSelectorProxy.js.flow +6 -6
- package/mutations/applyOptimisticMutation.d.ts +25 -0
- package/mutations/applyOptimisticMutation.js.flow +2 -2
- package/mutations/commitLocalUpdate.d.ts +10 -0
- package/mutations/commitMutation.d.ts +48 -0
- package/mutations/commitMutation.js.flow +21 -17
- package/mutations/createUpdatableProxy.js.flow +19 -19
- package/mutations/readUpdatableFragment.js.flow +3 -3
- package/mutations/readUpdatableQuery.js.flow +3 -3
- package/mutations/validateMutation.js.flow +7 -7
- package/network/RelayNetwork.d.ts +12 -0
- package/network/RelayNetworkTypes.d.ts +145 -0
- package/network/RelayNetworkTypes.js.flow +18 -18
- package/network/RelayObservable.d.ts +197 -0
- package/network/RelayObservable.js.flow +32 -30
- package/network/RelayQueryResponseCache.d.ts +16 -0
- package/network/RelayQueryResponseCache.js.flow +3 -3
- package/network/wrapNetworkWithLogObserver.js.flow +1 -1
- package/package.json +2 -1
- package/query/GraphQLTag.d.ts +45 -0
- package/query/GraphQLTag.js.flow +22 -10
- package/query/fetchQuery.d.ts +21 -0
- package/query/fetchQuery.js.flow +23 -10
- package/query/fetchQueryInternal.d.ts +26 -0
- package/query/fetchQueryInternal.js.flow +4 -4
- package/query/fetchQuery_DEPRECATED.d.ts +17 -0
- package/query/fetchQuery_DEPRECATED.js.flow +1 -1
- package/store/ClientID.d.ts +14 -0
- package/store/DataChecker.js.flow +51 -15
- package/store/NormalizationEngine.js.flow +782 -0
- package/store/OperationExecutor.d.ts +51 -0
- package/store/OperationExecutor.js.flow +204 -98
- package/store/RelayConcreteVariables.js.flow +5 -5
- package/store/RelayErrorTrie.js.flow +12 -12
- package/store/RelayExperimentalGraphResponseHandler.js.flow +3 -3
- package/store/RelayExperimentalGraphResponseTransform.js.flow +10 -10
- package/store/RelayModernEnvironment.d.ts +97 -0
- package/store/RelayModernEnvironment.js.flow +58 -43
- package/store/RelayModernFragmentSpecResolver.js.flow +1 -1
- package/store/RelayModernOperationDescriptor.d.ts +28 -0
- package/store/RelayModernOperationDescriptor.js.flow +1 -1
- package/store/RelayModernRecord.d.ts +92 -0
- package/store/RelayModernRecord.js.flow +44 -20
- package/store/RelayModernSelector.d.ts +123 -0
- package/store/RelayModernSelector.js.flow +21 -21
- package/store/RelayModernStore.d.ts +57 -0
- package/store/RelayModernStore.js.flow +219 -58
- package/store/RelayOperationTracker.d.ts +29 -0
- package/store/RelayOperationTracker.js.flow +2 -2
- package/store/RelayOptimisticRecordSource.js.flow +2 -2
- package/store/RelayPublishQueue.js.flow +29 -20
- package/store/RelayReader.js.flow +129 -57
- package/store/RelayRecordSource.d.ts +26 -0
- package/store/RelayRecordSource.js.flow +10 -0
- package/store/RelayRecordState.d.ts +28 -0
- package/store/RelayRecordState.js.flow +1 -1
- package/store/RelayReferenceMarker.js.flow +5 -4
- package/store/RelayResponseNormalizer.d.ts +28 -0
- package/store/RelayResponseNormalizer.js.flow +130 -62
- package/store/RelayStoreSubscriptions.js.flow +52 -8
- package/store/RelayStoreTypes.d.ts +1327 -0
- package/store/RelayStoreTypes.js.flow +371 -278
- package/store/RelayStoreUtils.d.ts +86 -0
- package/store/RelayStoreUtils.js.flow +16 -8
- package/store/ResolverCache.js.flow +2 -2
- package/store/ResolverFragments.d.ts +43 -0
- package/store/ResolverFragments.js.flow +22 -14
- package/store/StoreInspector.js.flow +7 -8
- package/store/ViewerPattern.d.ts +11 -0
- package/store/cloneRelayHandleSourceField.js.flow +1 -1
- package/store/cloneRelayScalarHandleSourceField.js.flow +1 -1
- package/store/createFragmentSpecResolver.d.ts +16 -0
- package/store/createRelayContext.js.flow +1 -1
- package/store/createRelayLoggingContext.js.flow +4 -4
- package/store/defaultGetDataID.js.flow +2 -2
- package/store/isRelayModernEnvironment.d.ts +8 -0
- package/store/isRelayModernEnvironment.js.flow +4 -2
- package/store/live-resolvers/LiveResolverCache.js.flow +55 -20
- package/store/live-resolvers/LiveResolverSuspenseSentinel.js.flow +3 -3
- package/store/live-resolvers/getOutputTypeRecordIDs.js.flow +1 -1
- package/store/live-resolvers/isLiveStateValue.js.flow +2 -2
- package/store/live-resolvers/resolverDataInjector.d.ts +27 -0
- package/store/live-resolvers/resolverDataInjector.js.flow +8 -5
- package/store/observeFragmentExperimental.d.ts +46 -0
- package/store/observeFragmentExperimental.js.flow +50 -21
- package/store/observeQueryExperimental.d.ts +30 -0
- package/store/observeQueryExperimental.js.flow +5 -5
- package/store/readInlineData.d.ts +19 -0
- package/store/readInlineData.js.flow +5 -5
- package/store/waitForFragmentExperimental.d.ts +49 -0
- package/store/waitForFragmentExperimental.js.flow +3 -3
- package/subscription/requestSubscription.d.ts +27 -0
- package/subscription/requestSubscription.js.flow +10 -10
- package/util/JSResourceTypes.flow.js.flow +4 -4
- package/util/NormalizationNode.d.ts +235 -0
- package/util/NormalizationNode.js.flow +127 -123
- package/util/ReaderNode.d.ts +264 -0
- package/util/ReaderNode.js.flow +156 -151
- package/util/RelayConcreteNode.d.ts +120 -0
- package/util/RelayConcreteNode.js.flow +32 -32
- package/util/RelayError.d.ts +13 -0
- package/util/RelayError.js.flow +4 -1
- package/util/RelayFeatureFlags.d.ts +40 -0
- package/util/RelayFeatureFlags.js.flow +21 -1
- package/util/RelayProfiler.d.ts +121 -0
- package/util/RelayProfiler.js.flow +1 -1
- package/util/RelayReplaySubject.d.ts +25 -0
- package/util/RelayReplaySubject.js.flow +3 -3
- package/util/RelayRuntimeTypes.d.ts +59 -0
- package/util/RelayRuntimeTypes.js.flow +36 -33
- package/util/createPayloadFor3DField.d.ts +17 -0
- package/util/createPayloadFor3DField.js.flow +9 -5
- package/util/deepFreeze.d.ts +8 -0
- package/util/deepFreeze.js.flow +2 -2
- package/util/getFragmentIdentifier.d.ts +10 -0
- package/util/getFragmentIdentifier.js.flow +1 -1
- package/util/getPaginationMetadata.d.ts +20 -0
- package/util/getPaginationMetadata.js.flow +1 -1
- package/util/getPaginationVariables.d.ts +20 -0
- package/util/getPaginationVariables.js.flow +1 -1
- package/util/getPendingOperationsForFragment.d.ts +18 -0
- package/util/getPendingOperationsForFragment.js.flow +2 -2
- package/util/getRefetchMetadata.d.ts +19 -0
- package/util/getRefetchMetadata.js.flow +6 -5
- package/util/getRelayHandleKey.d.ts +8 -0
- package/util/getRequestIdentifier.d.ts +17 -0
- package/util/getValueAtPath.d.ts +8 -0
- package/util/getValueAtPath.js.flow +3 -3
- package/util/handlePotentialSnapshotErrors.d.ts +14 -0
- package/util/handlePotentialSnapshotErrors.js.flow +5 -5
- package/util/isEmptyObject.js.flow +1 -1
- package/util/isPromise.d.ts +8 -0
- package/util/isPromise.js.flow +2 -2
- package/util/isScalarAndEqual.d.ts +8 -0
- package/util/isScalarAndEqual.js.flow +1 -1
- package/util/recycleNodesInto.d.ts +8 -0
- package/util/recycleNodesInto.js.flow +2 -2
- package/util/registerEnvironmentWithDevTools.js.flow +1 -1
- package/util/shallowFreeze.js.flow +1 -1
- package/util/stableCopy.d.ts +8 -0
- package/util/stableCopy.js.flow +5 -5
- package/util/withProvidedVariables.d.ts +19 -0
- package/util/withProvidedVariables.js.flow +14 -10
|
@@ -120,6 +120,6 @@ function getNestedErrorTrieByKey(trie, key) {
|
|
|
120
120
|
module.exports = {
|
|
121
121
|
SELF: SELF,
|
|
122
122
|
buildErrorTrie: buildErrorTrie,
|
|
123
|
-
|
|
124
|
-
|
|
123
|
+
getErrorsByKey: getErrorsByKey,
|
|
124
|
+
getNestedErrorTrieByKey: getNestedErrorTrieByKey
|
|
125
125
|
};
|
|
@@ -89,10 +89,10 @@ var GraphModeNormalizer = /*#__PURE__*/function () {
|
|
|
89
89
|
yield* this._traverseSelections(node, data, rootFields, dataID, new Set());
|
|
90
90
|
var $streamID = this._getStreamID();
|
|
91
91
|
yield (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, rootFields), {}, {
|
|
92
|
-
$kind: 'Record',
|
|
93
|
-
$streamID: $streamID,
|
|
94
92
|
__id: dataID,
|
|
95
|
-
__typename: ROOT_TYPE
|
|
93
|
+
__typename: ROOT_TYPE,
|
|
94
|
+
$kind: 'Record',
|
|
95
|
+
$streamID: $streamID
|
|
96
96
|
});
|
|
97
97
|
yield {
|
|
98
98
|
$kind: 'Complete'
|
|
@@ -104,9 +104,9 @@ var GraphModeNormalizer = /*#__PURE__*/function () {
|
|
|
104
104
|
if (maybeStreamID == null) {
|
|
105
105
|
this._cacheKeyToStreamID.set(cacheKey, $streamID);
|
|
106
106
|
yield (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, fields), {}, {
|
|
107
|
-
$kind: 'Record',
|
|
108
|
-
__typename: typename,
|
|
109
107
|
__id: cacheKey,
|
|
108
|
+
__typename: typename,
|
|
109
|
+
$kind: 'Record',
|
|
110
110
|
$streamID: $streamID
|
|
111
111
|
});
|
|
112
112
|
} else if (Object.keys(fields).length > 0) {
|
|
@@ -190,13 +190,13 @@ var GraphModeNormalizer = /*#__PURE__*/function () {
|
|
|
190
190
|
yield* this._traverseSelections(selection, data, parentFields, parentID, sentFields);
|
|
191
191
|
} else {
|
|
192
192
|
this._incrementalPlaceholders.push({
|
|
193
|
-
|
|
193
|
+
actorIdentifier: this._actorIdentifier,
|
|
194
194
|
data: data,
|
|
195
|
+
kind: 'defer',
|
|
195
196
|
label: selection.label,
|
|
196
197
|
path: (0, _toConsumableArray2["default"])(this._path),
|
|
197
198
|
selector: createNormalizationSelector(selection, parentID, this._variables),
|
|
198
|
-
typeName: this._getObjectType(data)
|
|
199
|
-
actorIdentifier: this._actorIdentifier
|
|
199
|
+
typeName: this._getObjectType(data)
|
|
200
200
|
});
|
|
201
201
|
}
|
|
202
202
|
break;
|
|
@@ -24,6 +24,7 @@ var RelayModernEnvironment = /*#__PURE__*/function () {
|
|
|
24
24
|
var _config$store, _config$log, _config$relayFieldLog, _config$UNSTABLE_defa, _config$getDataID, _config$missingFieldH, _config$handlerProvid, _config$scheduler, _config$isServer, _config$normalizeResp, _config$operationTrac;
|
|
25
25
|
this.configName = config.configName;
|
|
26
26
|
this._treatMissingFieldsAsNull = config.treatMissingFieldsAsNull === true;
|
|
27
|
+
this._deferDeduplicatedFields = config.deferDeduplicatedFields === true;
|
|
27
28
|
var operationLoader = config.operationLoader;
|
|
28
29
|
if (process.env.NODE_ENV !== "production") {
|
|
29
30
|
if (operationLoader != null) {
|
|
@@ -31,9 +32,9 @@ var RelayModernEnvironment = /*#__PURE__*/function () {
|
|
|
31
32
|
}
|
|
32
33
|
}
|
|
33
34
|
var store = (_config$store = config.store) !== null && _config$store !== void 0 ? _config$store : new RelayModernStore(new RelayRecordSource(), {
|
|
35
|
+
getDataID: config.getDataID,
|
|
34
36
|
log: config.log,
|
|
35
37
|
operationLoader: config.operationLoader,
|
|
36
|
-
getDataID: config.getDataID,
|
|
37
38
|
shouldProcessClientComponents: config.shouldProcessClientComponents
|
|
38
39
|
});
|
|
39
40
|
this.__log = (_config$log = config.log) !== null && _config$log !== void 0 ? _config$log : emptyFunction;
|
|
@@ -166,6 +167,11 @@ var RelayModernEnvironment = /*#__PURE__*/function () {
|
|
|
166
167
|
_proto.retain = function retain(operation) {
|
|
167
168
|
return this._store.retain(operation);
|
|
168
169
|
};
|
|
170
|
+
_proto.experimental_batchUpdates = function experimental_batchUpdates(callback) {
|
|
171
|
+
var batchFn = this._store.experimental_batchUpdates;
|
|
172
|
+
!(typeof batchFn === 'function') ? process.env.NODE_ENV !== "production" ? invariant(false, 'RelayModernEnvironment: The current store does not support experimental_batchUpdates.') : invariant(false) : void 0;
|
|
173
|
+
batchFn.call(this._store, callback);
|
|
174
|
+
};
|
|
169
175
|
_proto.isServer = function isServer() {
|
|
170
176
|
return this._isServer;
|
|
171
177
|
};
|
|
@@ -174,7 +180,6 @@ var RelayModernEnvironment = /*#__PURE__*/function () {
|
|
|
174
180
|
var target = RelayRecordSource.create();
|
|
175
181
|
var source = this._store.getSource();
|
|
176
182
|
var result = this._store.check(operation, {
|
|
177
|
-
handlers: handlers,
|
|
178
183
|
defaultActorIdentifier: INTERNAL_ACTOR_IDENTIFIER_DO_NOT_USE,
|
|
179
184
|
getSourceForActor: function getSourceForActor(actorIdentifier) {
|
|
180
185
|
assertInternalActorIdentifier(actorIdentifier);
|
|
@@ -183,7 +188,8 @@ var RelayModernEnvironment = /*#__PURE__*/function () {
|
|
|
183
188
|
getTargetForActor: function getTargetForActor(actorIdentifier) {
|
|
184
189
|
assertInternalActorIdentifier(actorIdentifier);
|
|
185
190
|
return target;
|
|
186
|
-
}
|
|
191
|
+
},
|
|
192
|
+
handlers: handlers
|
|
187
193
|
});
|
|
188
194
|
if (target.size() > 0) {
|
|
189
195
|
this._scheduleUpdates(function () {
|
|
@@ -275,7 +281,7 @@ var RelayModernEnvironment = /*#__PURE__*/function () {
|
|
|
275
281
|
return "RelayModernEnvironment(".concat((_this$configName = this.configName) !== null && _this$configName !== void 0 ? _this$configName : '', ")");
|
|
276
282
|
};
|
|
277
283
|
_proto._execute = function _execute(_ref5) {
|
|
278
|
-
var
|
|
284
|
+
var _this0 = this;
|
|
279
285
|
var createSource = _ref5.createSource,
|
|
280
286
|
isClientPayload = _ref5.isClientPayload,
|
|
281
287
|
operation = _ref5.operation,
|
|
@@ -286,29 +292,30 @@ var RelayModernEnvironment = /*#__PURE__*/function () {
|
|
|
286
292
|
return RelayObservable.create(function (sink) {
|
|
287
293
|
var executor = OperationExecutor.execute({
|
|
288
294
|
actorIdentifier: INTERNAL_ACTOR_IDENTIFIER_DO_NOT_USE,
|
|
289
|
-
getDataID:
|
|
290
|
-
isClientPayload: isClientPayload,
|
|
291
|
-
log: _this10.__log,
|
|
292
|
-
operation: operation,
|
|
293
|
-
operationExecutions: _this10._operationExecutions,
|
|
294
|
-
operationLoader: _this10._operationLoader,
|
|
295
|
-
operationTracker: _this10._operationTracker,
|
|
296
|
-
optimisticConfig: optimisticConfig,
|
|
295
|
+
getDataID: _this0._getDataID,
|
|
297
296
|
getPublishQueue: function getPublishQueue(actorIdentifier) {
|
|
298
297
|
assertInternalActorIdentifier(actorIdentifier);
|
|
299
298
|
return publishQueue;
|
|
300
299
|
},
|
|
301
|
-
scheduler: _this10._scheduler,
|
|
302
|
-
shouldProcessClientComponents: _this10._shouldProcessClientComponents,
|
|
303
|
-
sink: sink,
|
|
304
|
-
source: createSource(),
|
|
305
300
|
getStore: function getStore(actorIdentifier) {
|
|
306
301
|
assertInternalActorIdentifier(actorIdentifier);
|
|
307
302
|
return store;
|
|
308
303
|
},
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
normalizeResponse:
|
|
304
|
+
isClientPayload: isClientPayload,
|
|
305
|
+
log: _this0.__log,
|
|
306
|
+
normalizeResponse: _this0._normalizeResponse,
|
|
307
|
+
operation: operation,
|
|
308
|
+
operationExecutions: _this0._operationExecutions,
|
|
309
|
+
operationLoader: _this0._operationLoader,
|
|
310
|
+
operationTracker: _this0._operationTracker,
|
|
311
|
+
optimisticConfig: optimisticConfig,
|
|
312
|
+
scheduler: _this0._scheduler,
|
|
313
|
+
shouldProcessClientComponents: _this0._shouldProcessClientComponents,
|
|
314
|
+
sink: sink,
|
|
315
|
+
source: createSource(),
|
|
316
|
+
treatMissingFieldsAsNull: _this0._treatMissingFieldsAsNull,
|
|
317
|
+
deferDeduplicatedFields: _this0._deferDeduplicatedFields,
|
|
318
|
+
updater: updater
|
|
312
319
|
});
|
|
313
320
|
return function () {
|
|
314
321
|
return executor.cancel();
|
|
@@ -292,6 +292,15 @@ function getResolverLinkedRecordIDs(record, typeName) {
|
|
|
292
292
|
return generateClientObjectClientID(typeName, id);
|
|
293
293
|
});
|
|
294
294
|
}
|
|
295
|
+
function hasFieldChanged(prevRecord, nextRecord, storageKey) {
|
|
296
|
+
var _prevRecord$ERRORS_KE, _nextRecord$ERRORS_KE;
|
|
297
|
+
if (!areEqual(prevRecord[storageKey], nextRecord[storageKey])) {
|
|
298
|
+
return true;
|
|
299
|
+
}
|
|
300
|
+
var prevErrors = (_prevRecord$ERRORS_KE = prevRecord[ERRORS_KEY]) === null || _prevRecord$ERRORS_KE === void 0 ? void 0 : _prevRecord$ERRORS_KE[storageKey];
|
|
301
|
+
var nextErrors = (_nextRecord$ERRORS_KE = nextRecord[ERRORS_KEY]) === null || _nextRecord$ERRORS_KE === void 0 ? void 0 : _nextRecord$ERRORS_KE[storageKey];
|
|
302
|
+
return !areEqual(prevErrors, nextErrors);
|
|
303
|
+
}
|
|
295
304
|
function toJSON(record) {
|
|
296
305
|
return record;
|
|
297
306
|
}
|
|
@@ -301,26 +310,27 @@ module.exports = {
|
|
|
301
310
|
create: create,
|
|
302
311
|
freeze: freeze,
|
|
303
312
|
fromObject: fromObject,
|
|
313
|
+
getActorLinkedRecordID: getActorLinkedRecordID,
|
|
304
314
|
getDataID: getDataID,
|
|
305
315
|
getErrors: getErrors,
|
|
306
316
|
getFields: getFields,
|
|
307
317
|
getInvalidationEpoch: getInvalidationEpoch,
|
|
308
318
|
getLinkedRecordID: getLinkedRecordID,
|
|
309
319
|
getLinkedRecordIDs: getLinkedRecordIDs,
|
|
320
|
+
getResolverLinkedRecordID: getResolverLinkedRecordID,
|
|
321
|
+
getResolverLinkedRecordIDs: getResolverLinkedRecordIDs,
|
|
310
322
|
getType: getType,
|
|
311
323
|
getValue: getValue,
|
|
312
|
-
|
|
324
|
+
hasFieldChanged: hasFieldChanged,
|
|
313
325
|
hasLinkedRecordID: hasLinkedRecordID,
|
|
314
326
|
hasLinkedRecordIDs: hasLinkedRecordIDs,
|
|
327
|
+
hasValue: hasValue,
|
|
315
328
|
merge: merge,
|
|
329
|
+
setActorLinkedRecordID: setActorLinkedRecordID,
|
|
316
330
|
setErrors: setErrors,
|
|
317
|
-
setValue: setValue,
|
|
318
331
|
setLinkedRecordID: setLinkedRecordID,
|
|
319
332
|
setLinkedRecordIDs: setLinkedRecordIDs,
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
getResolverLinkedRecordID: getResolverLinkedRecordID,
|
|
324
|
-
getResolverLinkedRecordIDs: getResolverLinkedRecordIDs,
|
|
325
|
-
toJSON: toJSON
|
|
333
|
+
setValue: setValue,
|
|
334
|
+
toJSON: toJSON,
|
|
335
|
+
update: update
|
|
326
336
|
};
|
|
@@ -210,13 +210,13 @@ function createReaderSelector(fragment, dataID, variables, request) {
|
|
|
210
210
|
var isWithinUnmatchedTypeRefinement = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
211
211
|
var clientEdgeTraversalPath = arguments.length > 5 ? arguments[5] : undefined;
|
|
212
212
|
return {
|
|
213
|
-
|
|
213
|
+
clientEdgeTraversalPath: clientEdgeTraversalPath !== null && clientEdgeTraversalPath !== void 0 ? clientEdgeTraversalPath : null,
|
|
214
214
|
dataID: dataID,
|
|
215
215
|
isWithinUnmatchedTypeRefinement: isWithinUnmatchedTypeRefinement,
|
|
216
|
-
|
|
216
|
+
kind: 'SingularReaderSelector',
|
|
217
217
|
node: fragment,
|
|
218
|
-
|
|
219
|
-
|
|
218
|
+
owner: request,
|
|
219
|
+
variables: variables
|
|
220
220
|
};
|
|
221
221
|
}
|
|
222
222
|
function createNormalizationSelector(node, dataID, variables) {
|
|
@@ -228,16 +228,16 @@ function createNormalizationSelector(node, dataID, variables) {
|
|
|
228
228
|
}
|
|
229
229
|
module.exports = {
|
|
230
230
|
areEqualSelectors: areEqualSelectors,
|
|
231
|
-
createReaderSelector: createReaderSelector,
|
|
232
231
|
createNormalizationSelector: createNormalizationSelector,
|
|
232
|
+
createReaderSelector: createReaderSelector,
|
|
233
233
|
getDataIDsFromFragment: getDataIDsFromFragment,
|
|
234
234
|
getDataIDsFromObject: getDataIDsFromObject,
|
|
235
|
-
getSingularSelector: getSingularSelector,
|
|
236
235
|
getPluralSelector: getPluralSelector,
|
|
237
236
|
getSelector: getSelector,
|
|
238
237
|
getSelectorsFromObject: getSelectorsFromObject,
|
|
239
|
-
|
|
240
|
-
getVariablesFromPluralFragment: getVariablesFromPluralFragment,
|
|
238
|
+
getSingularSelector: getSingularSelector,
|
|
241
239
|
getVariablesFromFragment: getVariablesFromFragment,
|
|
242
|
-
getVariablesFromObject: getVariablesFromObject
|
|
240
|
+
getVariablesFromObject: getVariablesFromObject,
|
|
241
|
+
getVariablesFromPluralFragment: getVariablesFromPluralFragment,
|
|
242
|
+
getVariablesFromSingularFragment: getVariablesFromSingularFragment
|
|
243
243
|
};
|
|
@@ -7,6 +7,7 @@ var _require = require('../multi-actor-environment/ActorIdentifier'),
|
|
|
7
7
|
INTERNAL_ACTOR_IDENTIFIER_DO_NOT_USE = _require.INTERNAL_ACTOR_IDENTIFIER_DO_NOT_USE,
|
|
8
8
|
assertInternalActorIdentifier = _require.assertInternalActorIdentifier;
|
|
9
9
|
var deepFreeze = require('../util/deepFreeze');
|
|
10
|
+
var RelayFeatureFlags = require('../util/RelayFeatureFlags');
|
|
10
11
|
var resolveImmediate = require('../util/resolveImmediate');
|
|
11
12
|
var DataChecker = require('./DataChecker');
|
|
12
13
|
var defaultGetDataID = require('./defaultGetDataID');
|
|
@@ -21,14 +22,16 @@ var RelayReferenceMarker = require('./RelayReferenceMarker');
|
|
|
21
22
|
var RelayStoreSubscriptions = require('./RelayStoreSubscriptions');
|
|
22
23
|
var RelayStoreUtils = require('./RelayStoreUtils');
|
|
23
24
|
var _require3 = require('./RelayStoreUtils'),
|
|
25
|
+
FIELD_GRANULAR_NOTIFICATIONS_KEY = _require3.FIELD_GRANULAR_NOTIFICATIONS_KEY,
|
|
24
26
|
ROOT_ID = _require3.ROOT_ID,
|
|
25
|
-
ROOT_TYPE = _require3.ROOT_TYPE
|
|
27
|
+
ROOT_TYPE = _require3.ROOT_TYPE,
|
|
28
|
+
getFieldNotificationKey = _require3.getFieldNotificationKey;
|
|
26
29
|
var invariant = require('invariant');
|
|
27
30
|
var DEFAULT_RELEASE_BUFFER_SIZE = 10;
|
|
28
31
|
var RelayModernStore = /*#__PURE__*/function () {
|
|
29
32
|
function RelayModernStore(source, options) {
|
|
30
33
|
var _this = this;
|
|
31
|
-
var _options$gcReleaseBuf, _options$shouldRetain, _options$gcScheduler, _options$getDataID, _options$log, _options$operationLoa, _options$shouldProces, _options$treatMissing;
|
|
34
|
+
var _options$gcReleaseBuf, _options$shouldRetain, _options$gcScheduler, _options$getDataID, _options$log, _options$operationLoa, _options$shouldProces, _options$treatMissing, _options$deferDedupli;
|
|
32
35
|
(0, _defineProperty2["default"])(this, "_gcStep", function () {
|
|
33
36
|
if (_this._gcRun) {
|
|
34
37
|
if (_this._gcRun.next().done) {
|
|
@@ -73,7 +76,9 @@ var RelayModernStore = /*#__PURE__*/function () {
|
|
|
73
76
|
this._updatedRecordIDs = new Set();
|
|
74
77
|
this._shouldProcessClientComponents = (_options$shouldProces = options === null || options === void 0 ? void 0 : options.shouldProcessClientComponents) !== null && _options$shouldProces !== void 0 ? _options$shouldProces : false;
|
|
75
78
|
this._treatMissingFieldsAsNull = (_options$treatMissing = options === null || options === void 0 ? void 0 : options.treatMissingFieldsAsNull) !== null && _options$treatMissing !== void 0 ? _options$treatMissing : false;
|
|
79
|
+
this._deferDeduplicatedFields = (_options$deferDedupli = options === null || options === void 0 ? void 0 : options.deferDeduplicatedFields) !== null && _options$deferDedupli !== void 0 ? _options$deferDedupli : false;
|
|
76
80
|
this._actorIdentifier = options === null || options === void 0 ? void 0 : options.actorIdentifier;
|
|
81
|
+
this._batch = null;
|
|
77
82
|
initializeRecordSource(this._recordSource);
|
|
78
83
|
}
|
|
79
84
|
var _proto = RelayModernStore.prototype;
|
|
@@ -107,6 +112,65 @@ var RelayModernStore = /*#__PURE__*/function () {
|
|
|
107
112
|
}
|
|
108
113
|
}
|
|
109
114
|
};
|
|
115
|
+
_proto.experimental_batchUpdates = function experimental_batchUpdates(callback) {
|
|
116
|
+
if (this._batch != null) {
|
|
117
|
+
throw new Error('RelayModernStore: Cannot batch updates while already batching updates.');
|
|
118
|
+
}
|
|
119
|
+
var log = this.__log;
|
|
120
|
+
if (log != null) {
|
|
121
|
+
log({
|
|
122
|
+
name: 'store.batch.start'
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
var batch = {
|
|
126
|
+
sourceOperations: [],
|
|
127
|
+
invalidateStore: false
|
|
128
|
+
};
|
|
129
|
+
this._batch = batch;
|
|
130
|
+
try {
|
|
131
|
+
callback();
|
|
132
|
+
} finally {
|
|
133
|
+
this._batch = null;
|
|
134
|
+
this.notify(undefined, batch.invalidateStore);
|
|
135
|
+
var _iterator = (0, _createForOfIteratorHelper2["default"])(batch.sourceOperations),
|
|
136
|
+
_step;
|
|
137
|
+
try {
|
|
138
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
139
|
+
var sourceOperation = _step.value;
|
|
140
|
+
this._recordSourceOperation(sourceOperation);
|
|
141
|
+
}
|
|
142
|
+
} catch (err) {
|
|
143
|
+
_iterator.e(err);
|
|
144
|
+
} finally {
|
|
145
|
+
_iterator.f();
|
|
146
|
+
}
|
|
147
|
+
if (log != null) {
|
|
148
|
+
log({
|
|
149
|
+
name: 'store.batch.complete',
|
|
150
|
+
sourceOperations: batch.sourceOperations,
|
|
151
|
+
invalidateStore: batch.invalidateStore
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
_proto.batchLiveStateUpdatesWithoutNotify = function batchLiveStateUpdatesWithoutNotify(callback) {
|
|
157
|
+
if (this.__log != null) {
|
|
158
|
+
this.__log({
|
|
159
|
+
name: 'liveresolver.batch.start'
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
var hasPublished = false;
|
|
163
|
+
try {
|
|
164
|
+
hasPublished = this._resolverCache.batchLiveStateUpdatesWithoutNotify(callback);
|
|
165
|
+
} finally {
|
|
166
|
+
if (this.__log != null) {
|
|
167
|
+
this.__log({
|
|
168
|
+
name: 'liveresolver.batch.end'
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
return hasPublished;
|
|
173
|
+
};
|
|
110
174
|
_proto.check = function check(operation, options) {
|
|
111
175
|
var _ref, _operation$request$no, _operation$request$no2, _options$handlers, _options$getSourceFor, _options$getTargetFor, _options$defaultActor;
|
|
112
176
|
var selector = operation.root;
|
|
@@ -197,7 +261,7 @@ var RelayModernStore = /*#__PURE__*/function () {
|
|
|
197
261
|
});
|
|
198
262
|
}
|
|
199
263
|
var source = this.getSource();
|
|
200
|
-
var snapshot = RelayReader.read(source, selector, this._resolverCache, this._resolverContext);
|
|
264
|
+
var snapshot = RelayReader.read(source, selector, log, this._resolverCache, this._resolverContext);
|
|
201
265
|
if (process.env.NODE_ENV !== "production") {
|
|
202
266
|
deepFreeze(snapshot);
|
|
203
267
|
}
|
|
@@ -211,6 +275,16 @@ var RelayModernStore = /*#__PURE__*/function () {
|
|
|
211
275
|
};
|
|
212
276
|
_proto.notify = function notify(sourceOperation, invalidateStore) {
|
|
213
277
|
var _this3 = this;
|
|
278
|
+
var batch = this._batch;
|
|
279
|
+
if (batch != null) {
|
|
280
|
+
if (sourceOperation != null) {
|
|
281
|
+
batch.sourceOperations.push(sourceOperation);
|
|
282
|
+
}
|
|
283
|
+
if (invalidateStore === true) {
|
|
284
|
+
batch.invalidateStore = true;
|
|
285
|
+
}
|
|
286
|
+
return [];
|
|
287
|
+
}
|
|
214
288
|
var log = this.__log;
|
|
215
289
|
if (log != null) {
|
|
216
290
|
log({
|
|
@@ -218,34 +292,36 @@ var RelayModernStore = /*#__PURE__*/function () {
|
|
|
218
292
|
sourceOperation: sourceOperation
|
|
219
293
|
});
|
|
220
294
|
}
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
295
|
+
if (!RelayFeatureFlags.OPTIMIZE_NOTIFY) {
|
|
296
|
+
this._currentWriteEpoch++;
|
|
297
|
+
if (invalidateStore === true) {
|
|
298
|
+
this._globalInvalidationEpoch = this._currentWriteEpoch;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
if (!RelayFeatureFlags.OPTIMIZE_NOTIFY || this._updatedRecordIDs.size > 0) {
|
|
302
|
+
this._resolverCache.invalidateDataIDs(this._updatedRecordIDs);
|
|
224
303
|
}
|
|
225
|
-
this._resolverCache.invalidateDataIDs(this._updatedRecordIDs);
|
|
226
304
|
var source = this.getSource();
|
|
227
305
|
var updatedOwners = [];
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
if (
|
|
236
|
-
|
|
237
|
-
rootEntry.fetchTime = Date.now();
|
|
238
|
-
} else if (sourceOperation.request.node.params.operationKind === 'query' && this._gcReleaseBufferSize > 0 && this._releaseBuffer.length < this._gcReleaseBufferSize) {
|
|
239
|
-
var temporaryRootEntry = {
|
|
240
|
-
operation: sourceOperation,
|
|
241
|
-
refCount: 0,
|
|
242
|
-
epoch: this._currentWriteEpoch,
|
|
243
|
-
fetchTime: Date.now()
|
|
244
|
-
};
|
|
245
|
-
this._releaseBuffer.push(id);
|
|
246
|
-
this._roots.set(id, temporaryRootEntry);
|
|
306
|
+
if (!RelayFeatureFlags.OPTIMIZE_NOTIFY || this._updatedRecordIDs.size > 0) {
|
|
307
|
+
this._storeSubscriptions.updateSubscriptions(source, this._updatedRecordIDs, updatedOwners, sourceOperation);
|
|
308
|
+
} else {
|
|
309
|
+
this._storeSubscriptions.updateStaleSubscriptions(source, this._updatedRecordIDs, updatedOwners, sourceOperation);
|
|
310
|
+
}
|
|
311
|
+
if (RelayFeatureFlags.OPTIMIZE_NOTIFY && (this._updatedRecordIDs.size > 0 || updatedOwners.length > 0 || this._invalidatedRecordIDs.size > 0 || invalidateStore === true || this._globalInvalidationEpoch === this._currentWriteEpoch)) {
|
|
312
|
+
this._currentWriteEpoch++;
|
|
313
|
+
if (invalidateStore === true) {
|
|
314
|
+
this._globalInvalidationEpoch = this._currentWriteEpoch;
|
|
247
315
|
}
|
|
248
316
|
}
|
|
317
|
+
if (!RelayFeatureFlags.OPTIMIZE_NOTIFY || this._invalidatedRecordIDs.size > 0 || invalidateStore === true) {
|
|
318
|
+
this._invalidationSubscriptions.forEach(function (subscription) {
|
|
319
|
+
_this3._updateInvalidationSubscription(subscription, invalidateStore === true);
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
if (sourceOperation != null) {
|
|
323
|
+
this._recordSourceOperation(sourceOperation);
|
|
324
|
+
}
|
|
249
325
|
if (log != null) {
|
|
250
326
|
log({
|
|
251
327
|
name: 'store.notify.complete',
|
|
@@ -260,6 +336,23 @@ var RelayModernStore = /*#__PURE__*/function () {
|
|
|
260
336
|
this._invalidatedRecordIDs.clear();
|
|
261
337
|
return updatedOwners;
|
|
262
338
|
};
|
|
339
|
+
_proto._recordSourceOperation = function _recordSourceOperation(sourceOperation) {
|
|
340
|
+
var id = sourceOperation.request.identifier;
|
|
341
|
+
var rootEntry = this._roots.get(id);
|
|
342
|
+
if (rootEntry != null) {
|
|
343
|
+
rootEntry.epoch = this._currentWriteEpoch;
|
|
344
|
+
rootEntry.fetchTime = Date.now();
|
|
345
|
+
} else if (sourceOperation.request.node.params.operationKind === 'query' && this._gcReleaseBufferSize > 0 && this._releaseBuffer.length < this._gcReleaseBufferSize) {
|
|
346
|
+
var temporaryRootEntry = {
|
|
347
|
+
operation: sourceOperation,
|
|
348
|
+
refCount: 0,
|
|
349
|
+
epoch: this._currentWriteEpoch,
|
|
350
|
+
fetchTime: Date.now()
|
|
351
|
+
};
|
|
352
|
+
this._releaseBuffer.push(id);
|
|
353
|
+
this._roots.set(id, temporaryRootEntry);
|
|
354
|
+
}
|
|
355
|
+
};
|
|
263
356
|
_proto.publish = function publish(source, idsMarkedForInvalidation) {
|
|
264
357
|
var target = this._getMutableRecordSource();
|
|
265
358
|
updateTargetFromSource(target, source, this._currentWriteEpoch + 1, idsMarkedForInvalidation, this._updatedRecordIDs, this._invalidatedRecordIDs);
|
|
@@ -325,19 +418,19 @@ var RelayModernStore = /*#__PURE__*/function () {
|
|
|
325
418
|
if (currentInvalidations.get('global') !== prevInvalidations.get('global')) {
|
|
326
419
|
return true;
|
|
327
420
|
}
|
|
328
|
-
var
|
|
329
|
-
|
|
421
|
+
var _iterator2 = (0, _createForOfIteratorHelper2["default"])(prevInvalidationState.dataIDs),
|
|
422
|
+
_step2;
|
|
330
423
|
try {
|
|
331
|
-
for (
|
|
332
|
-
var dataID =
|
|
424
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
425
|
+
var dataID = _step2.value;
|
|
333
426
|
if (currentInvalidations.get(dataID) !== prevInvalidations.get(dataID)) {
|
|
334
427
|
return true;
|
|
335
428
|
}
|
|
336
429
|
}
|
|
337
430
|
} catch (err) {
|
|
338
|
-
|
|
431
|
+
_iterator2.e(err);
|
|
339
432
|
} finally {
|
|
340
|
-
|
|
433
|
+
_iterator2.f();
|
|
341
434
|
}
|
|
342
435
|
return false;
|
|
343
436
|
};
|
|
@@ -432,17 +525,17 @@ var RelayModernStore = /*#__PURE__*/function () {
|
|
|
432
525
|
}
|
|
433
526
|
var startEpoch = this._currentWriteEpoch;
|
|
434
527
|
var references = new Set();
|
|
435
|
-
var
|
|
436
|
-
|
|
528
|
+
var _iterator3 = (0, _createForOfIteratorHelper2["default"])(this._roots.entries()),
|
|
529
|
+
_step3;
|
|
437
530
|
try {
|
|
438
|
-
for (
|
|
531
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
439
532
|
var _ref2, _operation$request$no3, _operation$request$no4;
|
|
440
|
-
var
|
|
441
|
-
_dataID =
|
|
442
|
-
|
|
443
|
-
operation =
|
|
444
|
-
refCount =
|
|
445
|
-
fetchTime =
|
|
533
|
+
var _step3$value = _step3.value,
|
|
534
|
+
_dataID = _step3$value[0],
|
|
535
|
+
_step3$value$ = _step3$value[1],
|
|
536
|
+
operation = _step3$value$.operation,
|
|
537
|
+
refCount = _step3$value$.refCount,
|
|
538
|
+
fetchTime = _step3$value$.fetchTime;
|
|
446
539
|
if (this._shouldRetainWithinTTL_EXPERIMENTAL) {
|
|
447
540
|
var _queryCacheExpirationTime = this._queryCacheExpirationTime;
|
|
448
541
|
!(_queryCacheExpirationTime != null) ? process.env.NODE_ENV !== "production" ? invariant(false, 'Query cache expiration time should be non-null if executing GC') : invariant(false) : void 0;
|
|
@@ -466,9 +559,9 @@ var RelayModernStore = /*#__PURE__*/function () {
|
|
|
466
559
|
}
|
|
467
560
|
}
|
|
468
561
|
} catch (err) {
|
|
469
|
-
|
|
562
|
+
_iterator3.e(err);
|
|
470
563
|
} finally {
|
|
471
|
-
|
|
564
|
+
_iterator3.f();
|
|
472
565
|
}
|
|
473
566
|
var storeIDs = this._recordSource.getRecordIDs();
|
|
474
567
|
for (var ii = 0; ii < storeIDs.length; ii++) {
|
|
@@ -502,6 +595,7 @@ var RelayModernStore = /*#__PURE__*/function () {
|
|
|
502
595
|
getDataID: this._getDataID,
|
|
503
596
|
log: this.__log,
|
|
504
597
|
treatMissingFieldsAsNull: this._treatMissingFieldsAsNull,
|
|
598
|
+
deferDeduplicatedFields: this._deferDeduplicatedFields,
|
|
505
599
|
shouldProcessClientComponents: this._shouldProcessClientComponents,
|
|
506
600
|
actorIdentifier: this._actorIdentifier
|
|
507
601
|
};
|
|
@@ -518,6 +612,9 @@ var RelayModernStore = /*#__PURE__*/function () {
|
|
|
518
612
|
function initializeRecordSource(target) {
|
|
519
613
|
if (!target.has(ROOT_ID)) {
|
|
520
614
|
var rootRecord = RelayModernRecord.create(ROOT_ID, ROOT_TYPE);
|
|
615
|
+
if (RelayFeatureFlags.ENABLE_FIELD_GRANULAR_NOTIFICATIONS) {
|
|
616
|
+
RelayModernRecord.setValue(rootRecord, FIELD_GRANULAR_NOTIFICATIONS_KEY, true);
|
|
617
|
+
}
|
|
521
618
|
target.set(ROOT_ID, rootRecord);
|
|
522
619
|
}
|
|
523
620
|
}
|
|
@@ -561,6 +658,18 @@ function updateTargetFromSource(target, source, currentWriteEpoch, idsMarkedForI
|
|
|
561
658
|
}
|
|
562
659
|
updatedRecordIDs.add(dataID);
|
|
563
660
|
target.set(dataID, nextRecord);
|
|
661
|
+
if (RelayModernRecord.getValue(nextRecord, FIELD_GRANULAR_NOTIFICATIONS_KEY)) {
|
|
662
|
+
var fields = RelayModernRecord.getFields(nextRecord);
|
|
663
|
+
for (var jj = 0; jj < fields.length; jj++) {
|
|
664
|
+
var storageKey = fields[jj];
|
|
665
|
+
if (storageKey.startsWith('__')) {
|
|
666
|
+
continue;
|
|
667
|
+
}
|
|
668
|
+
if (RelayModernRecord.hasFieldChanged(targetRecord, nextRecord, storageKey)) {
|
|
669
|
+
updatedRecordIDs.add(getFieldNotificationKey(dataID, storageKey));
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
}
|
|
564
673
|
}
|
|
565
674
|
} else if (sourceRecord === null) {
|
|
566
675
|
target["delete"](dataID);
|
|
@@ -203,7 +203,7 @@ var RelayPublishQueue = /*#__PURE__*/function () {
|
|
|
203
203
|
return RelayPublishQueue;
|
|
204
204
|
}();
|
|
205
205
|
function lookupSelector(source, selector) {
|
|
206
|
-
var selectorData = RelayReader.read(source, selector).data;
|
|
206
|
+
var selectorData = RelayReader.read(source, selector, null, undefined, undefined).data;
|
|
207
207
|
if (process.env.NODE_ENV !== "production") {
|
|
208
208
|
var deepFreeze = require('../util/deepFreeze');
|
|
209
209
|
if (selectorData) {
|