relay-runtime 20.1.1 → 21.0.0
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.js +1 -1
- package/experimental.js.flow +8 -8
- package/handlers/connection/ConnectionHandler.js.flow +5 -5
- package/handlers/connection/ConnectionInterface.js.flow +1 -1
- 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 +113 -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 +82 -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 +213 -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 +66 -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.js.flow +2 -2
- package/multi-actor-environment/ActorSpecificEnvironment.js.flow +7 -7
- package/multi-actor-environment/ActorUtils.js.flow +1 -1
- package/multi-actor-environment/MultiActorEnvironment.js.flow +12 -8
- package/multi-actor-environment/MultiActorEnvironmentTypes.js.flow +3 -3
- 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.js.flow +2 -2
- package/mutations/commitMutation.js.flow +20 -16
- 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/RelayNetworkTypes.js.flow +4 -4
- package/network/RelayObservable.js.flow +16 -14
- package/network/RelayQueryResponseCache.js.flow +3 -3
- package/network/wrapNetworkWithLogObserver.js.flow +1 -1
- package/package.json +2 -1
- package/query/GraphQLTag.js.flow +22 -10
- package/query/fetchQuery.js.flow +23 -10
- package/query/fetchQuery_DEPRECATED.js.flow +1 -1
- package/store/DataChecker.js.flow +43 -9
- package/store/NormalizationEngine.js.flow +779 -0
- package/store/OperationExecutor.js.flow +173 -70
- 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.js.flow +41 -26
- package/store/RelayModernFragmentSpecResolver.js.flow +1 -1
- package/store/RelayModernOperationDescriptor.js.flow +1 -1
- package/store/RelayModernRecord.js.flow +44 -20
- package/store/RelayModernSelector.js.flow +21 -21
- package/store/RelayModernStore.js.flow +219 -58
- package/store/RelayOperationTracker.js.flow +2 -2
- package/store/RelayOptimisticRecordSource.js.flow +2 -2
- package/store/RelayPublishQueue.js.flow +21 -12
- package/store/RelayReader.js.flow +129 -57
- package/store/RelayRecordSource.js.flow +10 -0
- package/store/RelayRecordState.js.flow +1 -1
- package/store/RelayReferenceMarker.js.flow +5 -4
- package/store/RelayResponseNormalizer.js.flow +125 -57
- package/store/RelayStoreSubscriptions.js.flow +52 -8
- package/store/RelayStoreTypes.js.flow +153 -64
- package/store/RelayStoreUtils.js.flow +15 -7
- package/store/ResolverCache.js.flow +2 -2
- package/store/ResolverFragments.js.flow +12 -12
- package/store/StoreInspector.js.flow +6 -7
- package/store/cloneRelayHandleSourceField.js.flow +1 -1
- package/store/cloneRelayScalarHandleSourceField.js.flow +1 -1
- package/store/createRelayContext.js.flow +1 -1
- package/store/createRelayLoggingContext.js.flow +4 -4
- package/store/defaultGetDataID.js.flow +2 -2
- 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.js.flow +8 -5
- package/store/observeFragmentExperimental.js.flow +49 -20
- package/store/observeQueryExperimental.js.flow +5 -5
- package/store/readInlineData.js.flow +4 -4
- package/store/waitForFragmentExperimental.js.flow +3 -3
- package/subscription/requestSubscription.js.flow +7 -7
- package/util/NormalizationNode.js.flow +34 -32
- package/util/ReaderNode.js.flow +32 -30
- package/util/RelayConcreteNode.js.flow +5 -5
- package/util/RelayError.js.flow +4 -1
- package/util/RelayFeatureFlags.js.flow +21 -1
- package/util/RelayProfiler.js.flow +1 -1
- package/util/RelayReplaySubject.js.flow +3 -3
- package/util/RelayRuntimeTypes.js.flow +11 -11
- package/util/createPayloadFor3DField.js.flow +9 -5
- package/util/deepFreeze.js.flow +2 -2
- package/util/getFragmentIdentifier.js.flow +1 -1
- package/util/getPaginationMetadata.js.flow +1 -1
- package/util/getPaginationVariables.js.flow +1 -1
- package/util/getPendingOperationsForFragment.js.flow +2 -2
- package/util/getRefetchMetadata.js.flow +6 -5
- package/util/getValueAtPath.js.flow +3 -3
- package/util/handlePotentialSnapshotErrors.js.flow +5 -5
- package/util/isEmptyObject.js.flow +1 -1
- package/util/isPromise.js.flow +2 -2
- package/util/isScalarAndEqual.js.flow +1 -1
- package/util/recycleNodesInto.js.flow +2 -2
- package/util/registerEnvironmentWithDevTools.js.flow +1 -1
- package/util/shallowFreeze.js.flow +1 -1
- package/util/stableCopy.js.flow +5 -5
- package/util/withProvidedVariables.js.flow +14 -10
|
@@ -9,6 +9,7 @@ var RelayReader = require('./RelayReader');
|
|
|
9
9
|
var RelayStoreSubscriptions = /*#__PURE__*/function () {
|
|
10
10
|
function RelayStoreSubscriptions(log, resolverCache, resolverContext) {
|
|
11
11
|
this._subscriptions = new Set();
|
|
12
|
+
this._staleSubscriptions = new Set();
|
|
12
13
|
this.__log = log;
|
|
13
14
|
this._resolverCache = resolverCache;
|
|
14
15
|
this._resolverContext = resolverContext;
|
|
@@ -24,6 +25,9 @@ var RelayStoreSubscriptions = /*#__PURE__*/function () {
|
|
|
24
25
|
};
|
|
25
26
|
var dispose = function dispose() {
|
|
26
27
|
_this._subscriptions["delete"](subscription);
|
|
28
|
+
if (RelayFeatureFlags.OPTIMIZE_NOTIFY && subscription.stale) {
|
|
29
|
+
_this._staleSubscriptions["delete"](subscription);
|
|
30
|
+
}
|
|
27
31
|
};
|
|
28
32
|
this._subscriptions.add(subscription);
|
|
29
33
|
return {
|
|
@@ -38,39 +42,56 @@ var RelayStoreSubscriptions = /*#__PURE__*/function () {
|
|
|
38
42
|
return;
|
|
39
43
|
}
|
|
40
44
|
var snapshot = subscription.snapshot;
|
|
41
|
-
var backup = RelayReader.read(source, snapshot.selector, _this2._resolverCache, _this2._resolverContext);
|
|
45
|
+
var backup = RelayReader.read(source, snapshot.selector, _this2.__log, _this2._resolverCache, _this2._resolverContext);
|
|
42
46
|
var nextData = recycleNodesInto(snapshot.data, backup.data);
|
|
43
47
|
backup.data = nextData;
|
|
44
48
|
subscription.backup = backup;
|
|
45
49
|
});
|
|
46
50
|
};
|
|
47
51
|
_proto.restoreSubscriptions = function restoreSubscriptions() {
|
|
52
|
+
var _this3 = this;
|
|
48
53
|
this._subscriptions.forEach(function (subscription) {
|
|
49
54
|
var backup = subscription.backup;
|
|
50
55
|
subscription.backup = null;
|
|
51
56
|
if (backup) {
|
|
52
57
|
if (backup.data !== subscription.snapshot.data) {
|
|
53
58
|
subscription.stale = true;
|
|
59
|
+
if (RelayFeatureFlags.OPTIMIZE_NOTIFY) {
|
|
60
|
+
_this3._staleSubscriptions.add(subscription);
|
|
61
|
+
}
|
|
54
62
|
}
|
|
55
63
|
subscription.snapshot = {
|
|
56
64
|
data: subscription.snapshot.data,
|
|
65
|
+
fieldErrors: backup.fieldErrors,
|
|
57
66
|
isMissingData: backup.isMissingData,
|
|
58
67
|
missingClientEdges: backup.missingClientEdges,
|
|
59
68
|
missingLiveResolverFields: backup.missingLiveResolverFields,
|
|
60
69
|
seenRecords: backup.seenRecords,
|
|
61
|
-
selector: backup.selector
|
|
62
|
-
fieldErrors: backup.fieldErrors
|
|
70
|
+
selector: backup.selector
|
|
63
71
|
};
|
|
64
72
|
} else {
|
|
65
73
|
subscription.stale = true;
|
|
74
|
+
if (RelayFeatureFlags.OPTIMIZE_NOTIFY) {
|
|
75
|
+
_this3._staleSubscriptions.add(subscription);
|
|
76
|
+
}
|
|
66
77
|
}
|
|
67
78
|
});
|
|
68
79
|
};
|
|
69
80
|
_proto.updateSubscriptions = function updateSubscriptions(source, updatedRecordIDs, updatedOwners, sourceOperation) {
|
|
70
|
-
var
|
|
81
|
+
var _this4 = this;
|
|
71
82
|
var hasUpdatedRecords = updatedRecordIDs.size !== 0;
|
|
72
83
|
this._subscriptions.forEach(function (subscription) {
|
|
73
|
-
var owner =
|
|
84
|
+
var owner = _this4._updateSubscription(source, subscription, updatedRecordIDs, hasUpdatedRecords, sourceOperation);
|
|
85
|
+
if (owner != null) {
|
|
86
|
+
updatedOwners.push(owner);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
_proto.updateStaleSubscriptions = function updateStaleSubscriptions(source, updatedRecordIDs, updatedOwners, sourceOperation) {
|
|
91
|
+
var _this5 = this;
|
|
92
|
+
var hasUpdatedRecords = updatedRecordIDs.size !== 0;
|
|
93
|
+
this._staleSubscriptions.forEach(function (subscription) {
|
|
94
|
+
var owner = _this5._updateSubscription(source, subscription, updatedRecordIDs, hasUpdatedRecords, sourceOperation);
|
|
74
95
|
if (owner != null) {
|
|
75
96
|
updatedOwners.push(owner);
|
|
76
97
|
}
|
|
@@ -85,29 +106,32 @@ var RelayStoreSubscriptions = /*#__PURE__*/function () {
|
|
|
85
106
|
if (!stale && !hasOverlappingUpdates) {
|
|
86
107
|
return;
|
|
87
108
|
}
|
|
88
|
-
var nextSnapshot = hasOverlappingUpdates || !backup ? RelayReader.read(source, snapshot.selector, this._resolverCache, this._resolverContext) : backup;
|
|
109
|
+
var nextSnapshot = hasOverlappingUpdates || !backup ? RelayReader.read(source, snapshot.selector, this.__log, this._resolverCache, this._resolverContext) : backup;
|
|
89
110
|
var nextData = recycleNodesInto(snapshot.data, nextSnapshot.data);
|
|
90
111
|
nextSnapshot = {
|
|
91
112
|
data: nextData,
|
|
113
|
+
fieldErrors: nextSnapshot.fieldErrors,
|
|
92
114
|
isMissingData: nextSnapshot.isMissingData,
|
|
93
115
|
missingClientEdges: nextSnapshot.missingClientEdges,
|
|
94
116
|
missingLiveResolverFields: nextSnapshot.missingLiveResolverFields,
|
|
95
117
|
seenRecords: nextSnapshot.seenRecords,
|
|
96
|
-
selector: nextSnapshot.selector
|
|
97
|
-
fieldErrors: nextSnapshot.fieldErrors
|
|
118
|
+
selector: nextSnapshot.selector
|
|
98
119
|
};
|
|
99
120
|
if (process.env.NODE_ENV !== "production") {
|
|
100
121
|
deepFreeze(nextSnapshot);
|
|
101
122
|
}
|
|
102
123
|
subscription.snapshot = nextSnapshot;
|
|
103
124
|
subscription.stale = false;
|
|
125
|
+
if (RelayFeatureFlags.OPTIMIZE_NOTIFY && stale) {
|
|
126
|
+
this._staleSubscriptions["delete"](subscription);
|
|
127
|
+
}
|
|
104
128
|
if (nextSnapshot.data !== snapshot.data) {
|
|
105
129
|
if (this.__log && RelayFeatureFlags.ENABLE_NOTIFY_SUBSCRIPTION) {
|
|
106
130
|
this.__log({
|
|
107
131
|
name: 'store.notify.subscription',
|
|
108
|
-
|
|
132
|
+
nextSnapshot: nextSnapshot,
|
|
109
133
|
snapshot: snapshot,
|
|
110
|
-
|
|
134
|
+
sourceOperation: sourceOperation
|
|
111
135
|
});
|
|
112
136
|
}
|
|
113
137
|
callback(nextSnapshot);
|
|
@@ -13,6 +13,7 @@ var VARIABLE = RelayConcreteNode.VARIABLE,
|
|
|
13
13
|
OBJECT_VALUE = RelayConcreteNode.OBJECT_VALUE,
|
|
14
14
|
LIST_VALUE = RelayConcreteNode.LIST_VALUE;
|
|
15
15
|
var ERRORS_KEY = '__errors';
|
|
16
|
+
var FIELD_GRANULAR_NOTIFICATIONS_KEY = '__fieldGranularNotifications';
|
|
16
17
|
var MODULE_COMPONENT_KEY_PREFIX = '__module_component_';
|
|
17
18
|
var MODULE_OPERATION_KEY_PREFIX = '__module_operation_';
|
|
18
19
|
var RELAY_READ_TIME_RESOLVER_KEY_PREFIX = '$r:';
|
|
@@ -126,6 +127,9 @@ function getModuleComponentKey(documentName) {
|
|
|
126
127
|
function getModuleOperationKey(documentName) {
|
|
127
128
|
return "".concat(MODULE_OPERATION_KEY_PREFIX).concat(documentName);
|
|
128
129
|
}
|
|
130
|
+
function getFieldNotificationKey(dataID, storageKey) {
|
|
131
|
+
return "__fn:".concat(dataID, ":").concat(storageKey);
|
|
132
|
+
}
|
|
129
133
|
var RelayStoreUtils = {
|
|
130
134
|
ACTOR_IDENTIFIER_KEY: '__actorIdentifier',
|
|
131
135
|
CLIENT_EDGE_TRAVERSAL_PATH: '__clientEdgeTraversalPath',
|
|
@@ -135,6 +139,7 @@ var RelayStoreUtils = {
|
|
|
135
139
|
FRAGMENT_PROP_NAME_KEY: '__fragmentPropName',
|
|
136
140
|
MODULE_COMPONENT_KEY: '__module_component',
|
|
137
141
|
ERRORS_KEY: ERRORS_KEY,
|
|
142
|
+
FIELD_GRANULAR_NOTIFICATIONS_KEY: FIELD_GRANULAR_NOTIFICATIONS_KEY,
|
|
138
143
|
ID_KEY: '__id',
|
|
139
144
|
REF_KEY: '__ref',
|
|
140
145
|
REFS_KEY: '__refs',
|
|
@@ -147,6 +152,7 @@ var RelayStoreUtils = {
|
|
|
147
152
|
RELAY_RESOLVER_SNAPSHOT_KEY: '__resolverSnapshot',
|
|
148
153
|
RELAY_RESOLVER_ERROR_KEY: '__resolverError',
|
|
149
154
|
RELAY_RESOLVER_OUTPUT_TYPE_RECORD_IDS: '__resolverOutputTypeRecordIDs',
|
|
155
|
+
RELAY_RESOLVER_RECORD_TYPENAME: '__RELAY_RESOLVER__',
|
|
150
156
|
RELAY_READ_TIME_RESOLVER_KEY_PREFIX: RELAY_READ_TIME_RESOLVER_KEY_PREFIX,
|
|
151
157
|
formatStorageKey: formatStorageKey,
|
|
152
158
|
getArgumentValue: getArgumentValue,
|
|
@@ -156,6 +162,7 @@ var RelayStoreUtils = {
|
|
|
156
162
|
getReadTimeResolverStorageKey: getReadTimeResolverStorageKey,
|
|
157
163
|
getStableStorageKey: getStableStorageKey,
|
|
158
164
|
getModuleComponentKey: getModuleComponentKey,
|
|
159
|
-
getModuleOperationKey: getModuleOperationKey
|
|
165
|
+
getModuleOperationKey: getModuleOperationKey,
|
|
166
|
+
getFieldNotificationKey: getFieldNotificationKey
|
|
160
167
|
};
|
|
161
168
|
module.exports = RelayStoreUtils;
|
|
@@ -36,7 +36,7 @@ function readFragment(fragmentInput, fragmentKey) {
|
|
|
36
36
|
}
|
|
37
37
|
var RESOLVER_FRAGMENT_ERRORED_SENTINEL = {};
|
|
38
38
|
module.exports = {
|
|
39
|
+
RESOLVER_FRAGMENT_ERRORED_SENTINEL: RESOLVER_FRAGMENT_ERRORED_SENTINEL,
|
|
39
40
|
readFragment: readFragment,
|
|
40
|
-
withResolverContext: withResolverContext
|
|
41
|
-
RESOLVER_FRAGMENT_ERRORED_SENTINEL: RESOLVER_FRAGMENT_ERRORED_SENTINEL
|
|
41
|
+
withResolverContext: withResolverContext
|
|
42
42
|
};
|
|
@@ -20,6 +20,7 @@ var _require5 = require('../RelayStoreUtils'),
|
|
|
20
20
|
RELAY_RESOLVER_ERROR_KEY = _require5.RELAY_RESOLVER_ERROR_KEY,
|
|
21
21
|
RELAY_RESOLVER_INVALIDATION_KEY = _require5.RELAY_RESOLVER_INVALIDATION_KEY,
|
|
22
22
|
RELAY_RESOLVER_OUTPUT_TYPE_RECORD_IDS = _require5.RELAY_RESOLVER_OUTPUT_TYPE_RECORD_IDS,
|
|
23
|
+
RELAY_RESOLVER_RECORD_TYPENAME = _require5.RELAY_RESOLVER_RECORD_TYPENAME,
|
|
23
24
|
RELAY_RESOLVER_SNAPSHOT_KEY = _require5.RELAY_RESOLVER_SNAPSHOT_KEY,
|
|
24
25
|
RELAY_RESOLVER_VALUE_KEY = _require5.RELAY_RESOLVER_VALUE_KEY,
|
|
25
26
|
getReadTimeResolverStorageKey = _require5.getReadTimeResolverStorageKey,
|
|
@@ -33,7 +34,6 @@ var warning = require("fbjs/lib/warning");
|
|
|
33
34
|
var RELAY_RESOLVER_LIVE_STATE_SUBSCRIPTION_KEY = '__resolverLiveStateSubscription';
|
|
34
35
|
var RELAY_RESOLVER_LIVE_STATE_VALUE = '__resolverLiveStateValue';
|
|
35
36
|
var RELAY_RESOLVER_LIVE_STATE_DIRTY = '__resolverLiveStateDirty';
|
|
36
|
-
var RELAY_RESOLVER_RECORD_TYPENAME = '__RELAY_RESOLVER__';
|
|
37
37
|
var MODEL_PROPERTY_NAME = '__relay_model_instance';
|
|
38
38
|
function addDependencyEdge(edges, from, to) {
|
|
39
39
|
var set = edges.get(from);
|
|
@@ -204,6 +204,21 @@ var LiveResolverCache = /*#__PURE__*/function () {
|
|
|
204
204
|
this._handlingBatch = false;
|
|
205
205
|
}
|
|
206
206
|
};
|
|
207
|
+
_proto.batchLiveStateUpdatesWithoutNotify = function batchLiveStateUpdatesWithoutNotify(callback) {
|
|
208
|
+
!!this._handlingBatch ? process.env.NODE_ENV !== "production" ? invariant(false, 'Unexpected nested call to batchLiveStateUpdates.') : invariant(false) : void 0;
|
|
209
|
+
this._handlingBatch = true;
|
|
210
|
+
try {
|
|
211
|
+
callback();
|
|
212
|
+
} finally {
|
|
213
|
+
var shouldPublish = this._liveResolverBatchRecordSource != null;
|
|
214
|
+
if (shouldPublish) {
|
|
215
|
+
this._store.publish(this._liveResolverBatchRecordSource);
|
|
216
|
+
}
|
|
217
|
+
this._liveResolverBatchRecordSource = null;
|
|
218
|
+
this._handlingBatch = false;
|
|
219
|
+
return shouldPublish;
|
|
220
|
+
}
|
|
221
|
+
};
|
|
207
222
|
_proto._setLiveResolverValue = function _setLiveResolverValue(resolverRecord, liveValue, field, variables) {
|
|
208
223
|
var value = null;
|
|
209
224
|
var resolverError = null;
|
|
@@ -278,6 +293,7 @@ var LiveResolverCache = /*#__PURE__*/function () {
|
|
|
278
293
|
} else {
|
|
279
294
|
shallowFreeze(value);
|
|
280
295
|
RelayModernRecord.setValue(resolverRecord, RELAY_RESOLVER_VALUE_KEY, value);
|
|
296
|
+
RelayModernRecord.setValue(resolverRecord, RELAY_RESOLVER_OUTPUT_TYPE_RECORD_IDS, new Set());
|
|
281
297
|
}
|
|
282
298
|
return updatedDataIDs;
|
|
283
299
|
};
|
|
@@ -514,20 +530,20 @@ function unsubscribeFromLiveResolverRecordsImpl(recordSource, invalidatedDataIDs
|
|
|
514
530
|
if (invalidatedDataIDs.size === 0) {
|
|
515
531
|
return;
|
|
516
532
|
}
|
|
517
|
-
var
|
|
518
|
-
|
|
533
|
+
var _iterator0 = (0, _createForOfIteratorHelper2["default"])(invalidatedDataIDs),
|
|
534
|
+
_step0;
|
|
519
535
|
try {
|
|
520
|
-
for (
|
|
521
|
-
var dataID =
|
|
536
|
+
for (_iterator0.s(); !(_step0 = _iterator0.n()).done;) {
|
|
537
|
+
var dataID = _step0.value;
|
|
522
538
|
var record = recordSource.get(dataID);
|
|
523
539
|
if (record != null && isResolverRecord(record)) {
|
|
524
540
|
maybeUnsubscribeFromLiveState(record);
|
|
525
541
|
}
|
|
526
542
|
}
|
|
527
543
|
} catch (err) {
|
|
528
|
-
|
|
544
|
+
_iterator0.e(err);
|
|
529
545
|
} finally {
|
|
530
|
-
|
|
546
|
+
_iterator0.f();
|
|
531
547
|
}
|
|
532
548
|
}
|
|
533
549
|
function isResolverRecord(record) {
|
|
@@ -555,6 +571,6 @@ function getConcreteTypename(normalizationInfo, currentValue) {
|
|
|
555
571
|
}
|
|
556
572
|
module.exports = {
|
|
557
573
|
LiveResolverCache: LiveResolverCache,
|
|
558
|
-
|
|
559
|
-
|
|
574
|
+
RELAY_RESOLVER_LIVE_STATE_SUBSCRIPTION_KEY: RELAY_RESOLVER_LIVE_STATE_SUBSCRIPTION_KEY,
|
|
575
|
+
getUpdatedDataIDs: getUpdatedDataIDs
|
|
560
576
|
};
|
|
@@ -46,8 +46,8 @@ function observeFragment(environment, fragment, fragmentRef) {
|
|
|
46
46
|
var _fragmentNode$metadat;
|
|
47
47
|
var fragmentNode = getFragment(fragment);
|
|
48
48
|
var fragmentSelector = getSelector(fragmentNode, fragmentRef);
|
|
49
|
-
!(((_fragmentNode$metadat = fragmentNode.metadata) === null || _fragmentNode$metadat === void 0 ? void 0 : _fragmentNode$metadat.hasClientEdges) == null) ? process.env.NODE_ENV !== "production" ? invariant(false, "Client edges aren't supported yet.") : invariant(false) : void 0;
|
|
50
49
|
!(fragmentSelector != null) ? process.env.NODE_ENV !== "production" ? invariant(false, 'Expected a selector, got null.') : invariant(false) : void 0;
|
|
50
|
+
!(((_fragmentNode$metadat = fragmentNode.metadata) === null || _fragmentNode$metadat === void 0 ? void 0 : _fragmentNode$metadat.hasClientEdges) == null || fragmentSelectorUsesExecTimeResolver(fragmentSelector)) ? process.env.NODE_ENV !== "production" ? invariant(false, "Client edges aren't supported yet.") : invariant(false) : void 0;
|
|
51
51
|
switch (fragmentSelector.kind) {
|
|
52
52
|
case 'SingularReaderSelector':
|
|
53
53
|
return observeSingularSelector(environment, fragment, fragmentSelector);
|
|
@@ -58,6 +58,22 @@ function observeFragment(environment, fragment, fragmentRef) {
|
|
|
58
58
|
}
|
|
59
59
|
!false ? process.env.NODE_ENV !== "production" ? invariant(false, 'Unsupported fragment selector kind') : invariant(false) : void 0;
|
|
60
60
|
}
|
|
61
|
+
function fragmentSelectorUsesExecTimeResolver(fragmentSelector) {
|
|
62
|
+
var _fragmentSelector$own, _fragmentSelector$own2, _fragmentSelector$own3, _fragmentSelector$own4;
|
|
63
|
+
switch (fragmentSelector === null || fragmentSelector === void 0 ? void 0 : fragmentSelector.kind) {
|
|
64
|
+
case 'SingularReaderSelector':
|
|
65
|
+
return ((_fragmentSelector$own = (_fragmentSelector$own2 = fragmentSelector.owner.node.operation) === null || _fragmentSelector$own2 === void 0 ? void 0 : _fragmentSelector$own2.use_exec_time_resolvers) !== null && _fragmentSelector$own !== void 0 ? _fragmentSelector$own : (_fragmentSelector$own3 = fragmentSelector.owner.node.operation) === null || _fragmentSelector$own3 === void 0 ? void 0 : (_fragmentSelector$own4 = _fragmentSelector$own3.exec_time_resolvers_enabled_provider) === null || _fragmentSelector$own4 === void 0 ? void 0 : _fragmentSelector$own4.get()) === true;
|
|
66
|
+
case 'PluralReaderSelector':
|
|
67
|
+
{
|
|
68
|
+
var _fragmentSelector$sel;
|
|
69
|
+
return (_fragmentSelector$sel = fragmentSelector.selectors) === null || _fragmentSelector$sel === void 0 ? void 0 : _fragmentSelector$sel.every(function (selector) {
|
|
70
|
+
var _selector$owner$node$, _selector$owner$node$2, _selector$owner$node$3;
|
|
71
|
+
return ((_selector$owner$node$ = selector.owner.node.operation.use_exec_time_resolvers) !== null && _selector$owner$node$ !== void 0 ? _selector$owner$node$ : (_selector$owner$node$2 = selector.owner.node.operation) === null || _selector$owner$node$2 === void 0 ? void 0 : (_selector$owner$node$3 = _selector$owner$node$2.exec_time_resolvers_enabled_provider) === null || _selector$owner$node$3 === void 0 ? void 0 : _selector$owner$node$3.get()) === true;
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
61
77
|
function observeSingularSelector(environment, fragmentNode, fragmentSelector) {
|
|
62
78
|
var snapshot = environment.lookup(fragmentSelector);
|
|
63
79
|
return Observable.create(function (sink) {
|
|
@@ -9,9 +9,9 @@ var _require2 = require('./RelayModernOperationDescriptor'),
|
|
|
9
9
|
function observeQuery(environment, gqlQuery, variables) {
|
|
10
10
|
var operation = createOperationDescriptor(gqlQuery, variables);
|
|
11
11
|
var rootFragmentRef = {
|
|
12
|
-
|
|
12
|
+
__fragmentOwner: operation.request,
|
|
13
13
|
__fragments: (0, _defineProperty2["default"])({}, operation.fragment.node.name, operation.request.variables),
|
|
14
|
-
|
|
14
|
+
__id: operation.fragment.dataID
|
|
15
15
|
};
|
|
16
16
|
var fragmentNode = operation.request.node.fragment;
|
|
17
17
|
return observeFragment(environment, fragmentNode, rootFragmentRef);
|
|
@@ -27,6 +27,8 @@ function requestSubscription(environment, config) {
|
|
|
27
27
|
operation: operation,
|
|
28
28
|
updater: updater
|
|
29
29
|
}).subscribe({
|
|
30
|
+
complete: onCompleted,
|
|
31
|
+
error: onError,
|
|
30
32
|
next: function next(responses) {
|
|
31
33
|
if (onNext != null) {
|
|
32
34
|
var selector = operation.fragment;
|
|
@@ -44,9 +46,7 @@ function requestSubscription(environment, config) {
|
|
|
44
46
|
var data = environment.lookup(selector).data;
|
|
45
47
|
onNext(data);
|
|
46
48
|
}
|
|
47
|
-
}
|
|
48
|
-
error: onError,
|
|
49
|
-
complete: onCompleted
|
|
49
|
+
}
|
|
50
50
|
});
|
|
51
51
|
return {
|
|
52
52
|
dispose: sub.unsubscribe
|
package/lib/util/RelayError.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
function createError(type, name, messageFormat) {
|
|
4
|
+
var _messageParams$;
|
|
4
5
|
for (var _len = arguments.length, messageParams = new Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++) {
|
|
5
6
|
messageParams[_key - 3] = arguments[_key];
|
|
6
7
|
}
|
|
@@ -9,11 +10,13 @@ function createError(type, name, messageFormat) {
|
|
|
9
10
|
return String(messageParams[index++]);
|
|
10
11
|
});
|
|
11
12
|
var err = new Error(message);
|
|
13
|
+
var operation = (_messageParams$ = messageParams[2]) !== null && _messageParams$ !== void 0 ? _messageParams$ : null;
|
|
12
14
|
var error = Object.assign(err, {
|
|
13
15
|
name: name,
|
|
14
16
|
messageFormat: messageFormat,
|
|
15
17
|
messageParams: messageParams,
|
|
16
18
|
type: type,
|
|
19
|
+
operation: operation,
|
|
17
20
|
taalOpcodes: [2, 2]
|
|
18
21
|
});
|
|
19
22
|
if (error.stack === undefined) {
|
|
@@ -20,12 +20,16 @@ var RelayFeatureFlags = {
|
|
|
20
20
|
PROCESS_OPTIMISTIC_UPDATE_BEFORE_SUBSCRIPTION: false,
|
|
21
21
|
MARK_RESOLVER_VALUES_AS_CLEAN_AFTER_FRAGMENT_REREAD: false,
|
|
22
22
|
ENABLE_CYLE_DETECTION_IN_VARIABLES: false,
|
|
23
|
-
ENABLE_ACTIVITY_COMPATIBILITY:
|
|
23
|
+
ENABLE_ACTIVITY_COMPATIBILITY: true,
|
|
24
24
|
ENABLE_READ_TIME_RESOLVER_STORAGE_KEY_PREFIX: true,
|
|
25
25
|
ENABLE_USE_PAGINATION_IS_LOADING_FIX: false,
|
|
26
26
|
DISALLOW_NESTED_UPDATES: false,
|
|
27
27
|
ENABLE_TYPENAME_PREFIXED_DATA_ID: false,
|
|
28
28
|
ENABLE_UI_CONTEXT_ON_RELAY_LOGGER: false,
|
|
29
|
-
CHECK_ALL_FRAGMENTS_FOR_MISSING_CLIENT_EDGES: false
|
|
29
|
+
CHECK_ALL_FRAGMENTS_FOR_MISSING_CLIENT_EDGES: false,
|
|
30
|
+
FILTER_OUT_RELAY_RESOLVER_RECORDS: false,
|
|
31
|
+
OPTIMIZE_NOTIFY: false,
|
|
32
|
+
ENABLE_FIELD_GRANULAR_NOTIFICATIONS: false,
|
|
33
|
+
ENABLE_READER_FRAGMENTS_LOGGING: false
|
|
30
34
|
};
|
|
31
35
|
module.exports = RelayFeatureFlags;
|
|
@@ -59,8 +59,8 @@ var RelayReplaySubject = /*#__PURE__*/function () {
|
|
|
59
59
|
}
|
|
60
60
|
this._complete = true;
|
|
61
61
|
this._events.push({
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
error: _error,
|
|
63
|
+
kind: 'error'
|
|
64
64
|
});
|
|
65
65
|
this._sinks.forEach(function (sink) {
|
|
66
66
|
return sink.error(_error);
|
|
@@ -71,8 +71,8 @@ var RelayReplaySubject = /*#__PURE__*/function () {
|
|
|
71
71
|
return;
|
|
72
72
|
}
|
|
73
73
|
this._events.push({
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
data: data,
|
|
75
|
+
kind: 'next'
|
|
76
76
|
});
|
|
77
77
|
this._sinks.forEach(function (sink) {
|
|
78
78
|
return sink.next(data);
|
|
@@ -71,6 +71,6 @@ function handlePotentialSnapshotErrors(environment, fieldErrors, loggingContext)
|
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
module.exports = {
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
eventShouldThrow: eventShouldThrow,
|
|
75
|
+
handlePotentialSnapshotErrors: handlePotentialSnapshotErrors
|
|
76
76
|
};
|
package/lib/util/stableCopy.js
CHANGED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: entrypoint-container
|
|
3
|
+
title: EntryPointContainer
|
|
4
|
+
slug: /api-reference/entrypoint-container/
|
|
5
|
+
description: API reference for EntryPointContainer, a React component used to render the root component of an entrypoint
|
|
6
|
+
keywords:
|
|
7
|
+
- entrypoint
|
|
8
|
+
- container
|
|
9
|
+
- root
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
import DocsRating from '@site/src/core/DocsRating';
|
|
13
|
+
import {OssOnly, FbInternalOnly} from 'docusaurus-plugin-internaldocs-fb/internal';
|
|
14
|
+
|
|
15
|
+
## `EntryPointContainer`
|
|
16
|
+
|
|
17
|
+
<FbInternalOnly>
|
|
18
|
+
|
|
19
|
+
For more information, see the [Defining EntryPoints](../../guides/entrypoints/using-entrypoints/#defining-entrypoints) and [Consuming EntryPoints](../../guides/entrypoints/using-entrypoints/#-entrypoints) guides.
|
|
20
|
+
|
|
21
|
+
</FbInternalOnly>
|
|
22
|
+
|
|
23
|
+
```js
|
|
24
|
+
function EntryPointContainer({
|
|
25
|
+
entryPointReference,
|
|
26
|
+
props,
|
|
27
|
+
}: {
|
|
28
|
+
+entryPointReference: PreloadedEntryPoint<TEntryPointComponent>,
|
|
29
|
+
+props: TRuntimeProps,
|
|
30
|
+
}): ReactElement
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
A React component that renders a preloaded EntryPoint.
|
|
34
|
+
|
|
35
|
+
* `entryPointReference`: the value returned from a call to `loadEntryPoint` or acquired from the `useEntryPointLoader` hook.
|
|
36
|
+
* `props`: additional runtime props that will be passed to the `Component`
|
|
37
|
+
|
|
38
|
+
<DocsRating />
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: load-entrypoint
|
|
3
|
+
title: loadEntryPoint
|
|
4
|
+
slug: /api-reference/load-entrypoint/
|
|
5
|
+
description: API reference for loadEntryPoint, which imperatively loads an entrypoint and data for its queries
|
|
6
|
+
keywords:
|
|
7
|
+
- entrypoint
|
|
8
|
+
- preload
|
|
9
|
+
- render-as-you-fetch
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
import DocsRating from '@site/src/core/DocsRating';
|
|
13
|
+
import {OssOnly, FbInternalOnly} from 'docusaurus-plugin-internaldocs-fb/internal';
|
|
14
|
+
|
|
15
|
+
## `loadEntryPoint`
|
|
16
|
+
|
|
17
|
+
This function is designed to be used with `EntryPointContainer` to implement the "render-as-you-fetch" pattern.
|
|
18
|
+
|
|
19
|
+
EntryPoint references returned from `loadEntryPoint` will leak data to the Relay store (if they have associated queries) unless `.dispose()` is called on them once they are no longer referenced. As such, prefer using `useEntryPointLoader` when possible, which ensures that EntryPoint references are correctly disposed for you. See the [`useEntryPointLoader`](../use-entrypoint-loader) docs for a more complete example.
|
|
20
|
+
|
|
21
|
+
<FbInternalOnly>
|
|
22
|
+
|
|
23
|
+
For more information, see the [Loading EntryPoints](../../guides/entrypoints/using-entrypoints/#loading-entrypoints) guide.
|
|
24
|
+
|
|
25
|
+
</FbInternalOnly>
|
|
26
|
+
|
|
27
|
+
```js
|
|
28
|
+
const EntryPoint = require('MyComponent.entrypoint.js');
|
|
29
|
+
|
|
30
|
+
const {loadQuery} = require('react-relay');
|
|
31
|
+
|
|
32
|
+
// Generally, your component should access the environment from the React context,
|
|
33
|
+
// and pass that environment to this function.
|
|
34
|
+
const getEntrypointReference = environment => loadEntryPoint(
|
|
35
|
+
{ getEnvironment: () => environment },
|
|
36
|
+
EntryPoint,
|
|
37
|
+
{id: '4'},
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
// later: pass entryPointReference to EntryPointContainer
|
|
41
|
+
// Note that EntryPoint references should have .dispose() called on them,
|
|
42
|
+
// which is missing in this example.
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Arguments
|
|
46
|
+
|
|
47
|
+
* `environmentProvider`: A provider for a Relay Environment instance on which to execute the request. If you're starting this request somewhere within a React component, you probably want to use the environment you obtain from using [`useRelayEnvironment`](../use-relay-environment/).
|
|
48
|
+
* `EntryPoint`: EntryPoint to load.
|
|
49
|
+
* `entryPointParams`: Parameters that will be passed to the EntryPoint's `getPreloadProps` method.
|
|
50
|
+
|
|
51
|
+
### Flow Type Parameters
|
|
52
|
+
|
|
53
|
+
* `TEntryPointParams`: Type parameter corresponding to the type of the first parameter of the `getPreloadProps` method of the EntryPoint.
|
|
54
|
+
* `TPreloadedQueries`: the type of the `queries` parameter to the EntryPoint component.
|
|
55
|
+
* `TPreloadedEntryPoints`: the type of the `entrypoints` parameter passed to the EntryPoint component.
|
|
56
|
+
* `TRuntimeProps`: the type of the `props` prop passed to `EntryPointContainer`. This object is passed down to the EntryPoint component, also as `props`.
|
|
57
|
+
* `TExtraProps`: if an EntryPoint's `getPreloadProps` method returns an object with an `extraProps` property, those extra props will be passed to the EntryPoint component as `extraProps`.
|
|
58
|
+
* `TEntryPointComponent`: the type of the EntryPoint.
|
|
59
|
+
* `TEntryPoint`: the type of the EntryPoint.
|
|
60
|
+
|
|
61
|
+
### Return Value
|
|
62
|
+
|
|
63
|
+
An EntryPoint reference with the following properties:
|
|
64
|
+
|
|
65
|
+
* `dispose`: a method that will release any query references loaded by this EntryPoint (including indirectly, by way of other EntryPoints) from being retained by the store. This can cause the data referenced by these query reference to be garbage collected.
|
|
66
|
+
|
|
67
|
+
The exact format of the return value is *unstable and highly likely to change*. We strongly recommend not using any other properties of the return value, as such code would be highly likely to break when upgrading to future versions of Relay. Instead, pass the result of `loadEntryPoint()` to `EntryPointContainer`.
|
|
68
|
+
|
|
69
|
+
### Behavior
|
|
70
|
+
|
|
71
|
+
* When `loadEntryPoint()` is called, each of an EntryPoint's associated queries (if it has any) will load their query data and query AST. Once both the query AST and the data are available, the data will be written to the store. This differs from the behavior of `prepareEntryPoint_DEPRECATED`, which would only write the data from an associated query to the store when that query was rendered with `usePreloadedQuery`.
|
|
72
|
+
* The EntryPoint reference's associated query references will be retained by the Relay store, preventing the data from being garbage collected. Once you call `.dispose()` on the EntryPoint reference, the data from the associated queries is liable to be garbage collected.
|
|
73
|
+
* `loadEntryPoint` may throw an error if it is called during React's render phase.
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
<DocsRating />
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: use-entrypoint-loader
|
|
3
|
+
title: useEntryPointLoader
|
|
4
|
+
slug: /api-reference/use-entrypoint-loader/
|
|
5
|
+
description: API reference for useEntryPointLoader, a React hook used to load entrypoints in response to user events
|
|
6
|
+
keywords:
|
|
7
|
+
- render-as-you-fetch
|
|
8
|
+
- entrypoint
|
|
9
|
+
- preload
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
import DocsRating from '@site/src/core/DocsRating';
|
|
13
|
+
import {OssOnly, FbInternalOnly} from 'docusaurus-plugin-internaldocs-fb/internal';
|
|
14
|
+
|
|
15
|
+
## `useEntryPointLoader`
|
|
16
|
+
|
|
17
|
+
Hook used to make it easy to safely work with EntryPoints, while avoiding data leaking into the Relay store. It will keep an EntryPoint reference in state, and dispose of it when it is no longer accessible via state.
|
|
18
|
+
|
|
19
|
+
<FbInternalOnly>
|
|
20
|
+
|
|
21
|
+
For more information, see the [Loading EntryPoints](https://www.internalfb.com/intern/wiki/Relay/Guides/entry-points/#loading-entrypoints) guide.
|
|
22
|
+
|
|
23
|
+
</FbInternalOnly>
|
|
24
|
+
|
|
25
|
+
```js
|
|
26
|
+
const {useEntryPointLoader, EntryPointContainer} = require('react-relay');
|
|
27
|
+
|
|
28
|
+
const ComponentEntryPoint = require('Component.entrypoint');
|
|
29
|
+
|
|
30
|
+
function EntryPointRevealer(): React.MixedElement {
|
|
31
|
+
const environmentProvider = useMyEnvironmentProvider();
|
|
32
|
+
const [
|
|
33
|
+
entryPointReference,
|
|
34
|
+
loadEntryPoint,
|
|
35
|
+
disposeEntryPoint,
|
|
36
|
+
] = useEntryPointLoader(environmentProvider, ComponentEntryPoint);
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<>
|
|
40
|
+
{
|
|
41
|
+
entryPointReference == null && (
|
|
42
|
+
<Button onClick={() => loadEntryPoint({})}>
|
|
43
|
+
Click to reveal the contents of the EntryPoint
|
|
44
|
+
</Button>
|
|
45
|
+
)
|
|
46
|
+
}
|
|
47
|
+
{
|
|
48
|
+
entryPointReference != null && (
|
|
49
|
+
<>
|
|
50
|
+
<Button onClick={disposeEntryPoint}>
|
|
51
|
+
Click to hide and dispose the EntryPoint.
|
|
52
|
+
</Button>
|
|
53
|
+
<Suspense fallback="Loading...">
|
|
54
|
+
<EntryPointContainer
|
|
55
|
+
entryPointReference={entryPointReference}
|
|
56
|
+
props={{}}
|
|
57
|
+
/>
|
|
58
|
+
</Suspense>
|
|
59
|
+
</>
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
</>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Arguments
|
|
68
|
+
|
|
69
|
+
* `environmentProvider`: an object with a `getEnvironment` method that returns a Relay environment.
|
|
70
|
+
* `EntryPoint`: the EntryPoint, usually acquired by importing a `.entrypoint.js` file.
|
|
71
|
+
|
|
72
|
+
### Flow Type Parameters
|
|
73
|
+
|
|
74
|
+
* `TEntryPointParams`: the type of the first argument to the `getPreloadProps` method of the EntryPoint.
|
|
75
|
+
* `TPreloadedQueries`: the type of the `queries` prop passed to the EntryPoint component.
|
|
76
|
+
* `TPreloadedEntryPoints`: the type of the `entryPoints` prop passed to the EntryPoint component.
|
|
77
|
+
* `TRuntimeProps`: the type of the `props` prop passed to `EntryPointContainer`. This object is passed down to the EntryPoint component, also as `props`.
|
|
78
|
+
* `TExtraProps`: if an EntryPoint's `getPreloadProps` method returns an object with an `extraProps` property, those extra props will be passed to the EntryPoint component as `extraProps` and have type `TExtraProps`.
|
|
79
|
+
* `TEntryPointComponent`: the type of the EntryPoint component.
|
|
80
|
+
* `TEntryPoint`: the type of the EntryPoint.
|
|
81
|
+
|
|
82
|
+
### Return value
|
|
83
|
+
|
|
84
|
+
A tuple containing the following values:
|
|
85
|
+
|
|
86
|
+
* `entryPointReference`: the EntryPoint reference, or `null`.
|
|
87
|
+
* `loadEntryPoint`: a callback that, when executed, will load an EntryPoint, which will be accessible as `entryPointReference`. If a previous EntryPoint was loaded, it will dispose of it. It may throw an error if called during React's render phase.
|
|
88
|
+
* Parameters
|
|
89
|
+
* `params: TEntryPointParams`: the params passed to the EntryPoint's `getPreloadProps` method.
|
|
90
|
+
* `disposeEntryPoint`: a callback that, when executed, will set `entryPointReference` to `null` and call `.dispose()` on it. It has type `() => void`. It should not be called during React's render phase.
|
|
91
|
+
|
|
92
|
+
### Behavior
|
|
93
|
+
|
|
94
|
+
* When the `loadEntryPoint` callback is called, each of an EntryPoint's associated queries (if it has any) will load their query data and query AST. Once both the query AST and the data are available, the data will be written to the store. This differs from the behavior of `prepareEntryPoint_DEPRECATED`, which would only write the data from an associated query to the store when that query was rendered with `usePreloadedQuery`.
|
|
95
|
+
* The EntryPoint reference's associated query references will be retained by the Relay store, preventing the data from being garbage collected. Once you call `.dispose()` on the EntryPoint reference, the data from the associated queries is liable to be garbage collected.
|
|
96
|
+
* The `loadEntryPoint` callback may throw an error if it is called during React's render phase.
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
<DocsRating />
|