relay-runtime 12.0.0 → 13.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/LICENSE +1 -1
- package/README.md +67 -0
- package/handlers/RelayDefaultHandlerProvider.js.flow +3 -3
- package/handlers/connection/ConnectionHandler.js.flow +9 -18
- package/handlers/connection/ConnectionInterface.js.flow +1 -1
- package/handlers/connection/MutationHandlers.js.flow +8 -12
- package/index.js +2 -2
- package/index.js.flow +43 -34
- package/lib/handlers/RelayDefaultHandlerProvider.js +1 -1
- package/lib/handlers/connection/ConnectionHandler.js +13 -19
- package/lib/handlers/connection/ConnectionInterface.js +1 -1
- package/lib/handlers/connection/MutationHandlers.js +4 -7
- package/lib/index.js +49 -46
- package/lib/multi-actor-environment/ActorIdentifier.js +1 -1
- package/lib/multi-actor-environment/ActorSpecificEnvironment.js +9 -5
- package/lib/multi-actor-environment/ActorUtils.js +1 -1
- package/lib/multi-actor-environment/MultiActorEnvironment.js +36 -23
- package/lib/multi-actor-environment/MultiActorEnvironmentTypes.js +1 -1
- package/lib/multi-actor-environment/index.js +3 -3
- package/lib/mutations/RelayDeclarativeMutationConfig.js +5 -2
- package/lib/mutations/RelayRecordProxy.js +4 -3
- package/lib/mutations/RelayRecordSourceMutator.js +4 -3
- package/lib/mutations/RelayRecordSourceProxy.js +13 -5
- package/lib/mutations/RelayRecordSourceSelectorProxy.js +13 -5
- package/lib/mutations/applyOptimisticMutation.js +7 -7
- package/lib/mutations/commitLocalUpdate.js +1 -1
- package/lib/mutations/commitMutation.js +16 -15
- package/lib/mutations/readUpdatableQuery_EXPERIMENTAL.js +242 -0
- package/lib/mutations/validateMutation.js +7 -7
- package/lib/network/ConvertToExecuteFunction.js +3 -2
- package/lib/network/RelayNetwork.js +4 -3
- package/lib/network/RelayNetworkTypes.js +1 -1
- package/lib/network/RelayObservable.js +2 -4
- package/lib/network/RelayQueryResponseCache.js +3 -3
- package/lib/network/wrapNetworkWithLogObserver.js +3 -2
- package/lib/query/GraphQLTag.js +3 -2
- package/lib/query/PreloadableQueryRegistry.js +1 -1
- package/lib/query/fetchQuery.js +7 -6
- package/lib/query/fetchQueryInternal.js +1 -1
- package/lib/query/fetchQuery_DEPRECATED.js +3 -2
- package/lib/store/ClientID.js +8 -2
- package/lib/store/DataChecker.js +17 -18
- package/lib/store/OperationExecutor.js +14 -14
- package/lib/store/RelayConcreteVariables.js +7 -10
- package/lib/store/RelayExperimentalGraphResponseHandler.js +153 -0
- package/lib/store/RelayExperimentalGraphResponseTransform.js +391 -0
- package/lib/store/RelayModernEnvironment.js +67 -43
- package/lib/store/RelayModernFragmentSpecResolver.js +9 -9
- package/lib/store/RelayModernOperationDescriptor.js +3 -2
- package/lib/store/RelayModernRecord.js +13 -12
- package/lib/store/RelayModernSelector.js +15 -9
- package/lib/store/RelayModernStore.js +15 -16
- package/lib/store/RelayOperationTracker.js +1 -1
- package/lib/store/RelayOptimisticRecordSource.js +1 -1
- package/lib/store/RelayPublishQueue.js +12 -6
- package/lib/store/RelayReader.js +131 -40
- package/lib/store/RelayRecordSource.js +1 -1
- package/lib/store/RelayRecordState.js +1 -1
- package/lib/store/RelayReferenceMarker.js +11 -12
- package/lib/store/RelayResponseNormalizer.js +26 -23
- package/lib/store/RelayStoreReactFlightUtils.js +4 -4
- package/lib/store/RelayStoreSubscriptions.js +7 -5
- package/lib/store/RelayStoreTypes.js +1 -1
- package/lib/store/RelayStoreUtils.js +6 -6
- package/lib/store/ResolverCache.js +7 -7
- package/lib/store/ResolverFragments.js +12 -8
- package/lib/store/StoreInspector.js +1 -1
- package/lib/store/TypeID.js +1 -1
- package/lib/store/ViewerPattern.js +1 -1
- package/lib/store/cloneRelayHandleSourceField.js +6 -5
- package/lib/store/cloneRelayScalarHandleSourceField.js +6 -5
- package/lib/store/createFragmentSpecResolver.js +1 -1
- package/lib/store/createRelayContext.js +4 -2
- package/lib/store/defaultGetDataID.js +1 -1
- package/lib/store/defaultRequiredFieldLogger.js +1 -1
- package/lib/store/hasOverlappingIDs.js +1 -1
- package/lib/store/isRelayModernEnvironment.js +1 -1
- package/lib/store/normalizeRelayPayload.js +1 -1
- package/lib/store/readInlineData.js +7 -3
- package/lib/subscription/requestSubscription.js +4 -6
- package/lib/util/JSResourceTypes.flow.js +1 -1
- package/lib/util/NormalizationNode.js +1 -1
- package/lib/util/ReaderNode.js +1 -1
- package/lib/util/RelayConcreteNode.js +2 -1
- package/lib/util/RelayDefaultHandleKey.js +1 -1
- package/lib/util/RelayError.js +1 -1
- package/lib/util/RelayFeatureFlags.js +8 -3
- package/lib/util/RelayProfiler.js +1 -1
- package/lib/util/RelayReplaySubject.js +1 -1
- package/lib/util/RelayRuntimeTypes.js +1 -7
- package/lib/util/StringInterner.js +71 -0
- package/lib/util/createPayloadFor3DField.js +1 -1
- package/lib/util/deepFreeze.js +1 -1
- package/lib/util/generateID.js +1 -1
- package/lib/util/getAllRootVariables.js +29 -0
- package/lib/util/getFragmentIdentifier.js +16 -8
- package/lib/util/getOperation.js +3 -2
- package/lib/util/getPaginationMetadata.js +1 -1
- package/lib/util/getPaginationVariables.js +3 -4
- package/lib/util/getPendingOperationsForFragment.js +1 -1
- package/lib/util/getRefetchMetadata.js +1 -1
- package/lib/util/getRelayHandleKey.js +3 -3
- package/lib/util/getRequestIdentifier.js +3 -3
- package/lib/util/getValueAtPath.js +1 -1
- package/lib/util/isEmptyObject.js +1 -1
- package/lib/util/isPromise.js +1 -1
- package/lib/util/isScalarAndEqual.js +1 -1
- package/lib/util/recycleNodesInto.js +1 -1
- package/lib/util/registerEnvironmentWithDevTools.js +1 -1
- package/lib/util/reportMissingRequiredFields.js +1 -1
- package/lib/util/resolveImmediate.js +1 -1
- package/lib/util/stableCopy.js +1 -1
- package/lib/util/withDuration.js +1 -1
- package/multi-actor-environment/ActorIdentifier.js.flow +1 -1
- package/multi-actor-environment/ActorSpecificEnvironment.js.flow +28 -20
- package/multi-actor-environment/ActorUtils.js.flow +3 -3
- package/multi-actor-environment/MultiActorEnvironment.js.flow +46 -25
- package/multi-actor-environment/MultiActorEnvironmentTypes.js.flow +28 -12
- package/multi-actor-environment/index.js.flow +2 -3
- package/mutations/RelayDeclarativeMutationConfig.js.flow +33 -28
- package/mutations/RelayRecordProxy.js.flow +5 -6
- package/mutations/RelayRecordSourceMutator.js.flow +5 -7
- package/mutations/RelayRecordSourceProxy.js.flow +20 -11
- package/mutations/RelayRecordSourceSelectorProxy.js.flow +16 -6
- package/mutations/applyOptimisticMutation.js.flow +14 -15
- package/mutations/commitLocalUpdate.js.flow +2 -2
- package/mutations/commitMutation.js.flow +36 -49
- package/mutations/readUpdatableQuery_EXPERIMENTAL.js.flow +318 -0
- package/mutations/validateMutation.js.flow +20 -18
- package/network/ConvertToExecuteFunction.js.flow +3 -3
- package/network/RelayNetwork.js.flow +5 -6
- package/network/RelayNetworkTypes.js.flow +1 -1
- package/network/RelayObservable.js.flow +2 -4
- package/network/RelayQueryResponseCache.js.flow +4 -4
- package/network/wrapNetworkWithLogObserver.js.flow +9 -9
- package/package.json +2 -2
- package/query/GraphQLTag.js.flow +11 -11
- package/query/PreloadableQueryRegistry.js.flow +5 -3
- package/query/fetchQuery.js.flow +19 -19
- package/query/fetchQueryInternal.js.flow +7 -10
- package/query/fetchQuery_DEPRECATED.js.flow +7 -7
- package/relay-runtime.js +2 -2
- package/relay-runtime.min.js +3 -3
- package/store/ClientID.js.flow +10 -3
- package/store/DataChecker.js.flow +21 -30
- package/store/OperationExecutor.js.flow +55 -63
- package/store/RelayConcreteVariables.js.flow +5 -11
- package/store/RelayExperimentalGraphResponseHandler.js.flow +121 -0
- package/store/RelayExperimentalGraphResponseTransform.js.flow +470 -0
- package/store/RelayModernEnvironment.js.flow +57 -28
- package/store/RelayModernFragmentSpecResolver.js.flow +18 -20
- package/store/RelayModernOperationDescriptor.js.flow +11 -12
- package/store/RelayModernRecord.js.flow +20 -13
- package/store/RelayModernSelector.js.flow +25 -15
- package/store/RelayModernStore.js.flow +22 -26
- package/store/RelayOperationTracker.js.flow +12 -18
- package/store/RelayOptimisticRecordSource.js.flow +3 -3
- package/store/RelayPublishQueue.js.flow +43 -24
- package/store/RelayReader.js.flow +181 -68
- package/store/RelayRecordSource.js.flow +3 -3
- package/store/RelayRecordState.js.flow +1 -1
- package/store/RelayReferenceMarker.js.flow +13 -16
- package/store/RelayResponseNormalizer.js.flow +44 -42
- package/store/RelayStoreReactFlightUtils.js.flow +4 -5
- package/store/RelayStoreSubscriptions.js.flow +10 -9
- package/store/RelayStoreTypes.js.flow +73 -30
- package/store/RelayStoreUtils.js.flow +9 -10
- package/store/ResolverCache.js.flow +17 -15
- package/store/ResolverFragments.js.flow +18 -25
- package/store/StoreInspector.js.flow +3 -3
- package/store/TypeID.js.flow +2 -2
- package/store/ViewerPattern.js.flow +3 -3
- package/store/cloneRelayHandleSourceField.js.flow +6 -7
- package/store/cloneRelayScalarHandleSourceField.js.flow +6 -7
- package/store/createFragmentSpecResolver.js.flow +4 -5
- package/store/createRelayContext.js.flow +3 -3
- package/store/defaultGetDataID.js.flow +1 -1
- package/store/defaultRequiredFieldLogger.js.flow +1 -1
- package/store/hasOverlappingIDs.js.flow +1 -1
- package/store/isRelayModernEnvironment.js.flow +1 -1
- package/store/normalizeRelayPayload.js.flow +7 -8
- package/store/readInlineData.js.flow +8 -9
- package/subscription/requestSubscription.js.flow +16 -25
- package/util/JSResourceTypes.flow.js.flow +1 -1
- package/util/NormalizationNode.js.flow +1 -1
- package/util/ReaderNode.js.flow +10 -1
- package/util/RelayConcreteNode.js.flow +4 -1
- package/util/RelayDefaultHandleKey.js.flow +1 -1
- package/util/RelayError.js.flow +1 -1
- package/util/RelayFeatureFlags.js.flow +15 -5
- package/util/RelayProfiler.js.flow +1 -1
- package/util/RelayReplaySubject.js.flow +3 -4
- package/util/RelayRuntimeTypes.js.flow +70 -3
- package/util/StringInterner.js.flow +69 -0
- package/util/createPayloadFor3DField.js.flow +4 -4
- package/util/deepFreeze.js.flow +1 -1
- package/util/generateID.js.flow +1 -1
- package/util/getAllRootVariables.js.flow +36 -0
- package/util/getFragmentIdentifier.js.flow +28 -16
- package/util/getOperation.js.flow +3 -3
- package/util/getPaginationMetadata.js.flow +6 -11
- package/util/getPaginationVariables.js.flow +6 -10
- package/util/getPendingOperationsForFragment.js.flow +3 -3
- package/util/getRefetchMetadata.js.flow +8 -12
- package/util/getRelayHandleKey.js.flow +2 -3
- package/util/getRequestIdentifier.js.flow +4 -4
- package/util/getValueAtPath.js.flow +1 -1
- package/util/isEmptyObject.js.flow +1 -1
- package/util/isPromise.js.flow +1 -1
- package/util/isScalarAndEqual.js.flow +1 -1
- package/util/recycleNodesInto.js.flow +1 -1
- package/util/registerEnvironmentWithDevTools.js.flow +1 -1
- package/util/reportMissingRequiredFields.js.flow +1 -1
- package/util/resolveImmediate.js.flow +2 -2
- package/util/stableCopy.js.flow +1 -1
- package/util/withDuration.js.flow +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -12,12 +12,6 @@
|
|
|
12
12
|
|
|
13
13
|
'use strict';
|
|
14
14
|
|
|
15
|
-
const areEqual = require('areEqual');
|
|
16
|
-
const invariant = require('invariant');
|
|
17
|
-
|
|
18
|
-
const {SCALAR_FIELD} = require('../util/RelayConcreteNode');
|
|
19
|
-
const {getHandleStorageKey} = require('./RelayStoreUtils');
|
|
20
|
-
|
|
21
15
|
import type {
|
|
22
16
|
NormalizationScalarField,
|
|
23
17
|
NormalizationSelection,
|
|
@@ -25,6 +19,11 @@ import type {
|
|
|
25
19
|
import type {NormalizationScalarHandle} from '../util/NormalizationNode';
|
|
26
20
|
import type {Variables} from '../util/RelayRuntimeTypes';
|
|
27
21
|
|
|
22
|
+
const {SCALAR_FIELD} = require('../util/RelayConcreteNode');
|
|
23
|
+
const {getHandleStorageKey} = require('./RelayStoreUtils');
|
|
24
|
+
const areEqual = require('areEqual');
|
|
25
|
+
const invariant = require('invariant');
|
|
26
|
+
|
|
28
27
|
/**
|
|
29
28
|
* @private
|
|
30
29
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -12,10 +12,6 @@
|
|
|
12
12
|
|
|
13
13
|
'use strict';
|
|
14
14
|
|
|
15
|
-
const RelayModernFragmentSpecResolver = require('./RelayModernFragmentSpecResolver');
|
|
16
|
-
|
|
17
|
-
const warning = require('warning');
|
|
18
|
-
|
|
19
15
|
import type {
|
|
20
16
|
FragmentMap,
|
|
21
17
|
FragmentSpecResolver,
|
|
@@ -23,6 +19,9 @@ import type {
|
|
|
23
19
|
RelayContext,
|
|
24
20
|
} from './RelayStoreTypes';
|
|
25
21
|
|
|
22
|
+
const RelayModernFragmentSpecResolver = require('./RelayModernFragmentSpecResolver');
|
|
23
|
+
const warning = require('warning');
|
|
24
|
+
|
|
26
25
|
function createFragmentSpecResolver(
|
|
27
26
|
context: RelayContext,
|
|
28
27
|
containerName: string,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -12,11 +12,11 @@
|
|
|
12
12
|
|
|
13
13
|
'use strict';
|
|
14
14
|
|
|
15
|
-
const invariant = require('invariant');
|
|
16
|
-
|
|
17
15
|
import type {RelayContext} from './RelayStoreTypes.js';
|
|
18
16
|
import typeof {createContext} from 'react';
|
|
19
17
|
|
|
18
|
+
const invariant = require('invariant');
|
|
19
|
+
|
|
20
20
|
// Ideally, we'd just import the type of the react module, but this causes Flow
|
|
21
21
|
// problems.
|
|
22
22
|
type React = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -12,19 +12,18 @@
|
|
|
12
12
|
|
|
13
13
|
'use strict';
|
|
14
14
|
|
|
15
|
-
const RelayModernRecord = require('./RelayModernRecord');
|
|
16
|
-
const RelayRecordSource = require('./RelayRecordSource');
|
|
17
|
-
const RelayResponseNormalizer = require('./RelayResponseNormalizer');
|
|
18
|
-
|
|
19
|
-
const {ROOT_TYPE} = require('./RelayStoreUtils');
|
|
20
|
-
|
|
21
15
|
import type {PayloadData, PayloadError} from '../network/RelayNetworkTypes';
|
|
22
16
|
import type {NormalizationOptions} from './RelayResponseNormalizer';
|
|
23
17
|
import type {
|
|
24
|
-
RelayResponsePayload,
|
|
25
18
|
NormalizationSelector,
|
|
19
|
+
RelayResponsePayload,
|
|
26
20
|
} from './RelayStoreTypes';
|
|
27
21
|
|
|
22
|
+
const RelayModernRecord = require('./RelayModernRecord');
|
|
23
|
+
const RelayRecordSource = require('./RelayRecordSource');
|
|
24
|
+
const RelayResponseNormalizer = require('./RelayResponseNormalizer');
|
|
25
|
+
const {ROOT_TYPE} = require('./RelayStoreUtils');
|
|
26
|
+
|
|
28
27
|
function normalizeRelayPayload(
|
|
29
28
|
selector: NormalizationSelector,
|
|
30
29
|
payload: PayloadData,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -12,24 +12,23 @@
|
|
|
12
12
|
|
|
13
13
|
'use strict';
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
import type {GraphQLTaggedNode} from '../query/GraphQLTag';
|
|
16
|
+
import type {FragmentType} from './RelayStoreTypes';
|
|
16
17
|
|
|
17
18
|
const {getInlineDataFragment} = require('../query/GraphQLTag');
|
|
18
19
|
const {FRAGMENTS_KEY} = require('./RelayStoreUtils');
|
|
19
|
-
|
|
20
|
-
import type {GraphQLTaggedNode} from '../query/GraphQLTag';
|
|
21
|
-
import type {FragmentReference} from './RelayStoreTypes';
|
|
20
|
+
const invariant = require('invariant');
|
|
22
21
|
|
|
23
22
|
/**
|
|
24
23
|
* Reads an @inline data fragment that was spread into the parent fragment.
|
|
25
24
|
*/
|
|
26
25
|
|
|
27
26
|
declare function readInlineData<
|
|
28
|
-
|
|
27
|
+
TFragmentType: FragmentType,
|
|
29
28
|
TData,
|
|
30
29
|
TKey: {
|
|
31
30
|
+$data?: TData,
|
|
32
|
-
+$
|
|
31
|
+
+$fragmentSpreads: TFragmentType,
|
|
33
32
|
...
|
|
34
33
|
},
|
|
35
34
|
>(
|
|
@@ -37,11 +36,11 @@ declare function readInlineData<
|
|
|
37
36
|
fragmentRef: TKey,
|
|
38
37
|
): TData;
|
|
39
38
|
declare function readInlineData<
|
|
40
|
-
|
|
39
|
+
TFragmentType: FragmentType,
|
|
41
40
|
TData,
|
|
42
41
|
TKey: ?{
|
|
43
42
|
+$data?: TData,
|
|
44
|
-
+$
|
|
43
|
+
+$fragmentSpreads: TFragmentType,
|
|
45
44
|
...
|
|
46
45
|
},
|
|
47
46
|
>(
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -12,17 +12,6 @@
|
|
|
12
12
|
|
|
13
13
|
'use strict';
|
|
14
14
|
|
|
15
|
-
const RelayDeclarativeMutationConfig = require('../mutations/RelayDeclarativeMutationConfig');
|
|
16
|
-
const RelayFeatureFlags = require('../util/RelayFeatureFlags');
|
|
17
|
-
|
|
18
|
-
const warning = require('warning');
|
|
19
|
-
|
|
20
|
-
const {getRequest} = require('../query/GraphQLTag');
|
|
21
|
-
const {
|
|
22
|
-
createOperationDescriptor,
|
|
23
|
-
} = require('../store/RelayModernOperationDescriptor');
|
|
24
|
-
const {createReaderSelector} = require('../store/RelayModernSelector');
|
|
25
|
-
|
|
26
15
|
import type {DeclarativeMutationConfig} from '../mutations/RelayDeclarativeMutationConfig';
|
|
27
16
|
import type {GraphQLTaggedNode} from '../query/GraphQLTag';
|
|
28
17
|
import type {
|
|
@@ -35,6 +24,14 @@ import type {
|
|
|
35
24
|
Variables,
|
|
36
25
|
} from '../util/RelayRuntimeTypes';
|
|
37
26
|
|
|
27
|
+
const RelayDeclarativeMutationConfig = require('../mutations/RelayDeclarativeMutationConfig');
|
|
28
|
+
const {getRequest} = require('../query/GraphQLTag');
|
|
29
|
+
const {
|
|
30
|
+
createOperationDescriptor,
|
|
31
|
+
} = require('../store/RelayModernOperationDescriptor');
|
|
32
|
+
const {createReaderSelector} = require('../store/RelayModernSelector');
|
|
33
|
+
const warning = require('warning');
|
|
34
|
+
|
|
38
35
|
export type SubscriptionParameters = {|
|
|
39
36
|
+response: {...},
|
|
40
37
|
+variables: interface {},
|
|
@@ -45,11 +42,11 @@ export type GraphQLSubscriptionConfig<T: SubscriptionParameters> = {|
|
|
|
45
42
|
configs?: Array<DeclarativeMutationConfig>,
|
|
46
43
|
cacheConfig?: CacheConfig,
|
|
47
44
|
subscription: GraphQLTaggedNode,
|
|
48
|
-
variables:
|
|
45
|
+
variables: T['variables'],
|
|
49
46
|
onCompleted?: ?() => void,
|
|
50
47
|
onError?: ?(error: Error) => void,
|
|
51
|
-
onNext?: ?(response:
|
|
52
|
-
updater?: ?SelectorStoreUpdater
|
|
48
|
+
onNext?: ?(response: ?T['response']) => void,
|
|
49
|
+
updater?: ?SelectorStoreUpdater<T['response']>,
|
|
53
50
|
|};
|
|
54
51
|
|
|
55
52
|
export type DEPRECATED_GraphQLSubscriptionConfig<TSubscriptionPayload> = {|
|
|
@@ -60,7 +57,7 @@ export type DEPRECATED_GraphQLSubscriptionConfig<TSubscriptionPayload> = {|
|
|
|
60
57
|
onCompleted?: ?() => void,
|
|
61
58
|
onError?: ?(error: Error) => void,
|
|
62
59
|
onNext?: ?(response: ?TSubscriptionPayload) => void,
|
|
63
|
-
updater?: ?SelectorStoreUpdater
|
|
60
|
+
updater?: ?SelectorStoreUpdater<TSubscriptionPayload>,
|
|
64
61
|
|};
|
|
65
62
|
|
|
66
63
|
function requestSubscription<TSubscriptionPayload>(
|
|
@@ -71,14 +68,8 @@ function requestSubscription<TSubscriptionPayload>(
|
|
|
71
68
|
if (subscription.params.operationKind !== 'subscription') {
|
|
72
69
|
throw new Error('requestSubscription: Must use Subscription operation');
|
|
73
70
|
}
|
|
74
|
-
const {
|
|
75
|
-
|
|
76
|
-
onCompleted,
|
|
77
|
-
onError,
|
|
78
|
-
onNext,
|
|
79
|
-
variables,
|
|
80
|
-
cacheConfig,
|
|
81
|
-
} = config;
|
|
71
|
+
const {configs, onCompleted, onError, onNext, variables, cacheConfig} =
|
|
72
|
+
config;
|
|
82
73
|
const operation = createOperationDescriptor(
|
|
83
74
|
subscription,
|
|
84
75
|
variables,
|
|
@@ -100,7 +91,7 @@ function requestSubscription<TSubscriptionPayload>(
|
|
|
100
91
|
: config;
|
|
101
92
|
|
|
102
93
|
const sub = environment
|
|
103
|
-
.
|
|
94
|
+
.executeSubscription({
|
|
104
95
|
operation,
|
|
105
96
|
updater,
|
|
106
97
|
})
|
package/util/ReaderNode.js.flow
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -226,13 +226,22 @@ export type ReaderRelayResolver = {|
|
|
|
226
226
|
+fragment: ReaderFragmentSpread,
|
|
227
227
|
+resolverModule: (rootKey: {
|
|
228
228
|
+$data?: any, // flowlint-line unclear-type:off
|
|
229
|
+
+$fragmentSpreads: any, // flowlint-line unclear-type:off
|
|
229
230
|
+$fragmentRefs: any, // flowlint-line unclear-type:off
|
|
230
231
|
...
|
|
231
232
|
}) => mixed,
|
|
232
233
|
|};
|
|
233
234
|
|
|
235
|
+
export type ReaderClientEdge = {|
|
|
236
|
+
+kind: 'ClientEdge',
|
|
237
|
+
+linkedField: ReaderLinkedField,
|
|
238
|
+
+operation: ConcreteRequest,
|
|
239
|
+
+backingField: ReaderRelayResolver | ReaderClientExtension,
|
|
240
|
+
|};
|
|
241
|
+
|
|
234
242
|
export type ReaderSelection =
|
|
235
243
|
| ReaderCondition
|
|
244
|
+
| ReaderClientEdge
|
|
236
245
|
| ReaderClientExtension
|
|
237
246
|
| ReaderDefer
|
|
238
247
|
| ReaderField
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -48,6 +48,7 @@ export type RequestParameters =
|
|
|
48
48
|
// common fields
|
|
49
49
|
+name: string,
|
|
50
50
|
+operationKind: 'mutation' | 'query' | 'subscription',
|
|
51
|
+
+providedVariables?: {[key: string]: {|get(): mixed|}},
|
|
51
52
|
+metadata: {[key: string]: mixed, ...},
|
|
52
53
|
|}
|
|
53
54
|
| {|
|
|
@@ -57,6 +58,7 @@ export type RequestParameters =
|
|
|
57
58
|
// common fields
|
|
58
59
|
+name: string,
|
|
59
60
|
+operationKind: 'mutation' | 'query' | 'subscription',
|
|
61
|
+
+providedVariables?: {[key: string]: {|get(): mixed|}},
|
|
60
62
|
+metadata: {[key: string]: mixed, ...},
|
|
61
63
|
|};
|
|
62
64
|
|
|
@@ -70,6 +72,7 @@ const RelayConcreteNode = {
|
|
|
70
72
|
ACTOR_CHANGE: 'ActorChange',
|
|
71
73
|
CONDITION: 'Condition',
|
|
72
74
|
CLIENT_COMPONENT: 'ClientComponent',
|
|
75
|
+
CLIENT_EDGE: 'ClientEdge',
|
|
73
76
|
CLIENT_EXTENSION: 'ClientExtension',
|
|
74
77
|
DEFER: 'Defer',
|
|
75
78
|
CONNECTION: 'Connection',
|
package/util/RelayError.js.flow
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
|
-
* @flow strict
|
|
7
|
+
* @flow strict-local
|
|
8
8
|
* @format
|
|
9
9
|
*/
|
|
10
10
|
|
|
@@ -14,11 +14,12 @@
|
|
|
14
14
|
|
|
15
15
|
import type {Disposable} from '../util/RelayRuntimeTypes';
|
|
16
16
|
|
|
17
|
-
type FeatureFlags = {|
|
|
17
|
+
export type FeatureFlags = {|
|
|
18
|
+
DELAY_CLEANUP_OF_PENDING_PRELOAD_QUERIES: boolean,
|
|
19
|
+
ENABLE_CLIENT_EDGES: boolean,
|
|
18
20
|
ENABLE_VARIABLE_CONNECTION_KEY: boolean,
|
|
19
21
|
ENABLE_PARTIAL_RENDERING_DEFAULT: boolean,
|
|
20
22
|
ENABLE_REACT_FLIGHT_COMPONENT_FIELD: boolean,
|
|
21
|
-
ENABLE_REQUIRED_DIRECTIVES: boolean | string,
|
|
22
23
|
ENABLE_RELAY_RESOLVERS: boolean,
|
|
23
24
|
ENABLE_GETFRAGMENTIDENTIFIER_OPTIMIZATION: boolean,
|
|
24
25
|
ENABLE_FRIENDLY_QUERY_NAME_GQL_URL: boolean,
|
|
@@ -28,13 +29,18 @@ type FeatureFlags = {|
|
|
|
28
29
|
BATCH_ASYNC_MODULE_UPDATES_FN: ?(() => void) => Disposable,
|
|
29
30
|
ENABLE_CONTAINERS_SUBSCRIBE_ON_COMMIT: boolean,
|
|
30
31
|
ENABLE_QUERY_RENDERER_OFFSCREEN_SUPPORT: boolean,
|
|
32
|
+
MAX_DATA_ID_LENGTH: ?number,
|
|
33
|
+
REFACTOR_SUSPENSE_RESOURCE: boolean,
|
|
34
|
+
STRING_INTERN_LEVEL: number,
|
|
35
|
+
USE_REACT_CACHE: boolean,
|
|
31
36
|
|};
|
|
32
37
|
|
|
33
38
|
const RelayFeatureFlags: FeatureFlags = {
|
|
39
|
+
DELAY_CLEANUP_OF_PENDING_PRELOAD_QUERIES: false,
|
|
40
|
+
ENABLE_CLIENT_EDGES: false,
|
|
34
41
|
ENABLE_VARIABLE_CONNECTION_KEY: false,
|
|
35
42
|
ENABLE_PARTIAL_RENDERING_DEFAULT: true,
|
|
36
43
|
ENABLE_REACT_FLIGHT_COMPONENT_FIELD: false,
|
|
37
|
-
ENABLE_REQUIRED_DIRECTIVES: false,
|
|
38
44
|
ENABLE_RELAY_RESOLVERS: false,
|
|
39
45
|
ENABLE_GETFRAGMENTIDENTIFIER_OPTIMIZATION: false,
|
|
40
46
|
ENABLE_FRIENDLY_QUERY_NAME_GQL_URL: false,
|
|
@@ -44,6 +50,10 @@ const RelayFeatureFlags: FeatureFlags = {
|
|
|
44
50
|
BATCH_ASYNC_MODULE_UPDATES_FN: null,
|
|
45
51
|
ENABLE_CONTAINERS_SUBSCRIBE_ON_COMMIT: false,
|
|
46
52
|
ENABLE_QUERY_RENDERER_OFFSCREEN_SUPPORT: false,
|
|
53
|
+
MAX_DATA_ID_LENGTH: null,
|
|
54
|
+
REFACTOR_SUSPENSE_RESOURCE: true,
|
|
55
|
+
STRING_INTERN_LEVEL: 0,
|
|
56
|
+
USE_REACT_CACHE: false,
|
|
47
57
|
};
|
|
48
58
|
|
|
49
59
|
module.exports = RelayFeatureFlags;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -12,12 +12,11 @@
|
|
|
12
12
|
|
|
13
13
|
'use strict';
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
import type {Observer, Sink, Subscription} from '../network/RelayObservable';
|
|
16
16
|
|
|
17
|
+
const RelayObservable = require('../network/RelayObservable');
|
|
17
18
|
const invariant = require('invariant');
|
|
18
19
|
|
|
19
|
-
import type {Observer, Sink, Subscription} from '../network/RelayObservable';
|
|
20
|
-
|
|
21
20
|
type Event<T> =
|
|
22
21
|
| {
|
|
23
22
|
kind: 'next',
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
|
-
* @flow strict
|
|
7
|
+
* @flow strict-local
|
|
8
8
|
* @format
|
|
9
9
|
*/
|
|
10
10
|
|
|
@@ -16,6 +16,9 @@
|
|
|
16
16
|
* Basic types used throughout Relay.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
+
import type {ReaderFragment, ReaderInlineDataFragment} from './ReaderNode';
|
|
20
|
+
import type {ConcreteRequest} from './RelayConcreteNode';
|
|
21
|
+
|
|
19
22
|
/**
|
|
20
23
|
* Represents any resource that must be explicitly disposed of. The most common
|
|
21
24
|
* use-case is as a return value for subscriptions, where calling `dispose()`
|
|
@@ -38,7 +41,7 @@ export type OperationType = {|
|
|
|
38
41
|
+rawResponse?: {...},
|
|
39
42
|
|};
|
|
40
43
|
|
|
41
|
-
export type VariablesOf<T: OperationType> =
|
|
44
|
+
export type VariablesOf<T: OperationType> = T['variables'];
|
|
42
45
|
|
|
43
46
|
/**
|
|
44
47
|
* Settings for how a query response may be cached.
|
|
@@ -69,3 +72,67 @@ export type FetchPolicy =
|
|
|
69
72
|
| 'store-and-network'
|
|
70
73
|
| 'store-only';
|
|
71
74
|
export type RenderPolicy = 'full' | 'partial';
|
|
75
|
+
|
|
76
|
+
/* eslint-disable no-undef */
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Return type of graphql tag literals for all operations.
|
|
80
|
+
*/
|
|
81
|
+
declare export opaque type Operation<
|
|
82
|
+
-TVariables: Variables,
|
|
83
|
+
+TData,
|
|
84
|
+
TRawResponse,
|
|
85
|
+
>: ConcreteRequest;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Return type of graphql tag literals for queries.
|
|
89
|
+
*/
|
|
90
|
+
declare export opaque type Query<
|
|
91
|
+
-TVariables: Variables,
|
|
92
|
+
+TData,
|
|
93
|
+
TRawResponse = void,
|
|
94
|
+
>: Operation<TVariables, TData, TRawResponse>;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Return type of graphql tag literals for mutations.
|
|
98
|
+
*/
|
|
99
|
+
declare export opaque type Mutation<
|
|
100
|
+
-TVariables: Variables,
|
|
101
|
+
+TData,
|
|
102
|
+
TRawResponse = void,
|
|
103
|
+
>: Operation<TVariables, TData, TRawResponse>;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Return type of graphql tag literals for subscriptions.
|
|
107
|
+
*
|
|
108
|
+
* NOTE: Using the GraphQL prefix here because of a naming conflict with
|
|
109
|
+
* `RelayObservable`'s `Subscription` type.
|
|
110
|
+
*/
|
|
111
|
+
declare export opaque type GraphQLSubscription<
|
|
112
|
+
-TVariables: Variables,
|
|
113
|
+
+TData,
|
|
114
|
+
TRawResponse = void,
|
|
115
|
+
>: Operation<TVariables, TData, TRawResponse>;
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Return type of graphql tag literals for `@inline` fragments.
|
|
119
|
+
*/
|
|
120
|
+
declare export opaque type InlineFragment<
|
|
121
|
+
TFragmentType,
|
|
122
|
+
+TData,
|
|
123
|
+
>: ReaderInlineDataFragment;
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Return type of graphql tag literals for fragments, except `@inline`
|
|
127
|
+
* fragments.
|
|
128
|
+
*/
|
|
129
|
+
declare export opaque type Fragment<TFragmentType, +TData>: ReaderFragment;
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Return type of graphql tag literals for `@refetchable` fragments.
|
|
133
|
+
*/
|
|
134
|
+
declare export opaque type RefetchableFragment<
|
|
135
|
+
TFragmentType,
|
|
136
|
+
+TData,
|
|
137
|
+
-TVariables: Variables,
|
|
138
|
+
>: Fragment<TFragmentType, TData>;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @flow strict
|
|
8
|
+
* @format
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
// flowlint ambiguous-object-type:error
|
|
12
|
+
|
|
13
|
+
'use strict';
|
|
14
|
+
|
|
15
|
+
const internTable = new Map();
|
|
16
|
+
let nextIndex = 1;
|
|
17
|
+
const digits = initDigitTable();
|
|
18
|
+
|
|
19
|
+
// Character used as the prefix for interned strings. The specific character is
|
|
20
|
+
// chosen to reduce the likelihood that non-interned input strings need to be
|
|
21
|
+
// escaped (choosing eg a-Z would increase the likelihood we need to escape)
|
|
22
|
+
const INTERN_PREFIX = '\t';
|
|
23
|
+
// Character used as the prefix of escaped strings. As above, this is also
|
|
24
|
+
// chosen to be unlikely in normal input strings.
|
|
25
|
+
const ESCAPE_PREFIX = '\v';
|
|
26
|
+
|
|
27
|
+
function initDigitTable() {
|
|
28
|
+
// disable lint because digits isn't defined when this function is called
|
|
29
|
+
// eslint-disable-next-line no-shadow
|
|
30
|
+
const digits = new Set();
|
|
31
|
+
for (let i = 0; i < 10; ++i) {
|
|
32
|
+
digits.add(i.toString());
|
|
33
|
+
}
|
|
34
|
+
return digits;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Escape a string so that it cannot conflict with an interned string
|
|
38
|
+
function escape(str: string): string {
|
|
39
|
+
if (
|
|
40
|
+
// "\t<digit>..." -> "\v\t<digit>..."
|
|
41
|
+
(str[0] === INTERN_PREFIX && digits.has(str[1])) ||
|
|
42
|
+
// "\v..." -> "\v\v..."
|
|
43
|
+
str[0] === ESCAPE_PREFIX
|
|
44
|
+
) {
|
|
45
|
+
return ESCAPE_PREFIX + str;
|
|
46
|
+
}
|
|
47
|
+
return str;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Interns the input string if its length equals or exceeds the given `limit`,
|
|
51
|
+
// returning a shorter replacement string that is uniquely associated with the
|
|
52
|
+
// input: multiple calls to intern() for the equivalent input strings (and limit)
|
|
53
|
+
// will always return the exact same string.
|
|
54
|
+
// Strings shorter than the limit are not interned but are escaped if they
|
|
55
|
+
// could conflict with interned strings.
|
|
56
|
+
function intern(str: string, limit: ?number): string {
|
|
57
|
+
if (limit == null || str.length < limit) {
|
|
58
|
+
return escape(str);
|
|
59
|
+
}
|
|
60
|
+
let internedString = internTable.get(str);
|
|
61
|
+
if (internedString != null) {
|
|
62
|
+
return internedString;
|
|
63
|
+
}
|
|
64
|
+
internedString = INTERN_PREFIX + nextIndex++;
|
|
65
|
+
internTable.set(str, internedString);
|
|
66
|
+
return internedString;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
module.exports = {intern};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -13,14 +13,14 @@
|
|
|
13
13
|
|
|
14
14
|
'use strict';
|
|
15
15
|
|
|
16
|
+
import type {JSResourceReference} from 'JSResourceReference';
|
|
17
|
+
import type {NormalizationSplitOperation} from './NormalizationNode';
|
|
18
|
+
|
|
16
19
|
const {
|
|
17
20
|
getModuleComponentKey,
|
|
18
21
|
getModuleOperationKey,
|
|
19
22
|
} = require('../store/RelayStoreUtils');
|
|
20
23
|
|
|
21
|
-
import type {NormalizationSplitOperation} from './NormalizationNode';
|
|
22
|
-
import type {JSResourceReference} from 'JSResourceReference';
|
|
23
|
-
|
|
24
24
|
export opaque type Local3DPayload<
|
|
25
25
|
+DocumentName: string,
|
|
26
26
|
+Response: {...},
|
package/util/deepFreeze.js.flow
CHANGED
package/util/generateID.js.flow
CHANGED