relay-runtime 12.0.0 → 13.0.0-rc.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/handlers/RelayDefaultHandlerProvider.js.flow +2 -2
- package/handlers/connection/ConnectionHandler.js.flow +8 -17
- package/handlers/connection/MutationHandlers.js.flow +7 -11
- package/index.js +1 -1
- package/index.js.flow +40 -33
- package/lib/handlers/connection/ConnectionHandler.js +12 -18
- package/lib/handlers/connection/MutationHandlers.js +3 -6
- package/lib/index.js +45 -45
- package/lib/multi-actor-environment/ActorSpecificEnvironment.js +8 -4
- package/lib/multi-actor-environment/MultiActorEnvironment.js +35 -22
- package/lib/multi-actor-environment/index.js +2 -2
- package/lib/mutations/RelayDeclarativeMutationConfig.js +4 -1
- package/lib/mutations/RelayRecordProxy.js +3 -2
- package/lib/mutations/RelayRecordSourceMutator.js +3 -2
- package/lib/mutations/RelayRecordSourceProxy.js +12 -4
- package/lib/mutations/RelayRecordSourceSelectorProxy.js +12 -4
- package/lib/mutations/applyOptimisticMutation.js +6 -6
- package/lib/mutations/commitMutation.js +15 -14
- package/lib/mutations/readUpdatableQuery_EXPERIMENTAL.js +238 -0
- package/lib/mutations/validateMutation.js +6 -6
- package/lib/network/ConvertToExecuteFunction.js +2 -1
- package/lib/network/RelayNetwork.js +3 -2
- package/lib/network/RelayObservable.js +1 -3
- package/lib/network/RelayQueryResponseCache.js +2 -2
- package/lib/network/wrapNetworkWithLogObserver.js +2 -1
- package/lib/query/GraphQLTag.js +2 -1
- package/lib/query/fetchQuery.js +6 -5
- package/lib/query/fetchQuery_DEPRECATED.js +2 -1
- package/lib/store/ClientID.js +7 -1
- package/lib/store/DataChecker.js +16 -17
- package/lib/store/OperationExecutor.js +13 -13
- package/lib/store/RelayConcreteVariables.js +6 -9
- package/lib/store/RelayModernEnvironment.js +66 -42
- package/lib/store/RelayModernFragmentSpecResolver.js +8 -8
- package/lib/store/RelayModernOperationDescriptor.js +2 -1
- package/lib/store/RelayModernRecord.js +12 -11
- package/lib/store/RelayModernSelector.js +14 -8
- package/lib/store/RelayModernStore.js +14 -15
- package/lib/store/RelayPublishQueue.js +11 -5
- package/lib/store/RelayReader.js +130 -37
- package/lib/store/RelayReferenceMarker.js +10 -11
- package/lib/store/RelayResponseNormalizer.js +25 -22
- package/lib/store/RelayStoreReactFlightUtils.js +3 -3
- package/lib/store/RelayStoreSubscriptions.js +6 -4
- package/lib/store/RelayStoreUtils.js +5 -5
- package/lib/store/ResolverCache.js +6 -6
- package/lib/store/ResolverFragments.js +9 -5
- package/lib/store/cloneRelayHandleSourceField.js +5 -4
- package/lib/store/cloneRelayScalarHandleSourceField.js +5 -4
- package/lib/store/createRelayContext.js +3 -1
- package/lib/store/readInlineData.js +6 -2
- package/lib/subscription/requestSubscription.js +5 -5
- package/lib/util/RelayConcreteNode.js +1 -0
- package/lib/util/RelayFeatureFlags.js +7 -1
- package/lib/util/RelayRuntimeTypes.js +0 -6
- package/lib/util/StringInterner.js +71 -0
- package/lib/util/getFragmentIdentifier.js +15 -7
- package/lib/util/getOperation.js +2 -1
- package/lib/util/getPaginationVariables.js +2 -3
- package/lib/util/getRelayHandleKey.js +2 -2
- package/lib/util/getRequestIdentifier.js +2 -2
- package/multi-actor-environment/ActorSpecificEnvironment.js.flow +27 -19
- package/multi-actor-environment/ActorUtils.js.flow +2 -2
- package/multi-actor-environment/MultiActorEnvironment.js.flow +45 -24
- package/multi-actor-environment/MultiActorEnvironmentTypes.js.flow +27 -11
- package/multi-actor-environment/index.js.flow +1 -2
- package/mutations/RelayDeclarativeMutationConfig.js.flow +32 -26
- package/mutations/RelayRecordProxy.js.flow +4 -5
- package/mutations/RelayRecordSourceMutator.js.flow +4 -6
- package/mutations/RelayRecordSourceProxy.js.flow +19 -10
- package/mutations/RelayRecordSourceSelectorProxy.js.flow +15 -5
- package/mutations/applyOptimisticMutation.js.flow +13 -14
- package/mutations/commitLocalUpdate.js.flow +1 -1
- package/mutations/commitMutation.js.flow +35 -48
- package/mutations/readUpdatableQuery_EXPERIMENTAL.js.flow +309 -0
- package/mutations/validateMutation.js.flow +19 -17
- package/network/ConvertToExecuteFunction.js.flow +2 -2
- package/network/RelayNetwork.js.flow +4 -5
- package/network/RelayObservable.js.flow +1 -3
- package/network/RelayQueryResponseCache.js.flow +3 -3
- package/network/wrapNetworkWithLogObserver.js.flow +8 -7
- package/package.json +1 -1
- package/query/GraphQLTag.js.flow +9 -9
- package/query/PreloadableQueryRegistry.js.flow +2 -1
- package/query/fetchQuery.js.flow +11 -13
- package/query/fetchQueryInternal.js.flow +6 -9
- package/query/fetchQuery_DEPRECATED.js.flow +6 -6
- package/relay-runtime.js +2 -2
- package/relay-runtime.min.js +2 -2
- package/store/ClientID.js.flow +9 -2
- package/store/DataChecker.js.flow +20 -29
- package/store/OperationExecutor.js.flow +54 -62
- package/store/RelayConcreteVariables.js.flow +4 -10
- package/store/RelayModernEnvironment.js.flow +56 -27
- package/store/RelayModernFragmentSpecResolver.js.flow +17 -19
- package/store/RelayModernOperationDescriptor.js.flow +10 -11
- package/store/RelayModernRecord.js.flow +19 -12
- package/store/RelayModernSelector.js.flow +24 -14
- package/store/RelayModernStore.js.flow +21 -24
- package/store/RelayOperationTracker.js.flow +11 -17
- package/store/RelayOptimisticRecordSource.js.flow +2 -2
- package/store/RelayPublishQueue.js.flow +42 -23
- package/store/RelayReader.js.flow +180 -60
- package/store/RelayRecordSource.js.flow +2 -2
- package/store/RelayReferenceMarker.js.flow +12 -15
- package/store/RelayResponseNormalizer.js.flow +43 -41
- package/store/RelayStoreReactFlightUtils.js.flow +3 -4
- package/store/RelayStoreSubscriptions.js.flow +9 -8
- package/store/RelayStoreTypes.js.flow +72 -29
- package/store/RelayStoreUtils.js.flow +8 -9
- package/store/ResolverCache.js.flow +16 -14
- package/store/ResolverFragments.js.flow +15 -22
- package/store/StoreInspector.js.flow +2 -2
- package/store/TypeID.js.flow +1 -1
- package/store/ViewerPattern.js.flow +2 -2
- package/store/cloneRelayHandleSourceField.js.flow +5 -6
- package/store/cloneRelayScalarHandleSourceField.js.flow +5 -6
- package/store/createFragmentSpecResolver.js.flow +3 -4
- package/store/createRelayContext.js.flow +2 -2
- package/store/normalizeRelayPayload.js.flow +6 -7
- package/store/readInlineData.js.flow +7 -8
- package/subscription/requestSubscription.js.flow +16 -24
- package/util/ReaderNode.js.flow +9 -0
- package/util/RelayConcreteNode.js.flow +1 -0
- package/util/RelayFeatureFlags.js.flow +14 -2
- package/util/RelayReplaySubject.js.flow +2 -3
- package/util/RelayRuntimeTypes.js.flow +69 -2
- package/util/StringInterner.js.flow +69 -0
- package/util/createPayloadFor3DField.js.flow +3 -3
- package/util/getFragmentIdentifier.js.flow +27 -15
- package/util/getOperation.js.flow +2 -2
- package/util/getPaginationMetadata.js.flow +5 -7
- package/util/getPaginationVariables.js.flow +5 -9
- package/util/getPendingOperationsForFragment.js.flow +2 -2
- package/util/getRefetchMetadata.js.flow +6 -7
- package/util/getRelayHandleKey.js.flow +1 -2
- package/util/getRequestIdentifier.js.flow +3 -3
- package/util/resolveImmediate.js.flow +1 -1
|
@@ -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
|
>(
|
|
@@ -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,15 @@ 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 RelayFeatureFlags = require('../util/RelayFeatureFlags');
|
|
34
|
+
const warning = require('warning');
|
|
35
|
+
|
|
38
36
|
export type SubscriptionParameters = {|
|
|
39
37
|
+response: {...},
|
|
40
38
|
+variables: interface {},
|
|
@@ -45,11 +43,11 @@ export type GraphQLSubscriptionConfig<T: SubscriptionParameters> = {|
|
|
|
45
43
|
configs?: Array<DeclarativeMutationConfig>,
|
|
46
44
|
cacheConfig?: CacheConfig,
|
|
47
45
|
subscription: GraphQLTaggedNode,
|
|
48
|
-
variables:
|
|
46
|
+
variables: T['variables'],
|
|
49
47
|
onCompleted?: ?() => void,
|
|
50
48
|
onError?: ?(error: Error) => void,
|
|
51
|
-
onNext?: ?(response:
|
|
52
|
-
updater?: ?SelectorStoreUpdater
|
|
49
|
+
onNext?: ?(response: ?T['response']) => void,
|
|
50
|
+
updater?: ?SelectorStoreUpdater<T['response']>,
|
|
53
51
|
|};
|
|
54
52
|
|
|
55
53
|
export type DEPRECATED_GraphQLSubscriptionConfig<TSubscriptionPayload> = {|
|
|
@@ -60,7 +58,7 @@ export type DEPRECATED_GraphQLSubscriptionConfig<TSubscriptionPayload> = {|
|
|
|
60
58
|
onCompleted?: ?() => void,
|
|
61
59
|
onError?: ?(error: Error) => void,
|
|
62
60
|
onNext?: ?(response: ?TSubscriptionPayload) => void,
|
|
63
|
-
updater?: ?SelectorStoreUpdater
|
|
61
|
+
updater?: ?SelectorStoreUpdater<TSubscriptionPayload>,
|
|
64
62
|
|};
|
|
65
63
|
|
|
66
64
|
function requestSubscription<TSubscriptionPayload>(
|
|
@@ -71,14 +69,8 @@ function requestSubscription<TSubscriptionPayload>(
|
|
|
71
69
|
if (subscription.params.operationKind !== 'subscription') {
|
|
72
70
|
throw new Error('requestSubscription: Must use Subscription operation');
|
|
73
71
|
}
|
|
74
|
-
const {
|
|
75
|
-
|
|
76
|
-
onCompleted,
|
|
77
|
-
onError,
|
|
78
|
-
onNext,
|
|
79
|
-
variables,
|
|
80
|
-
cacheConfig,
|
|
81
|
-
} = config;
|
|
72
|
+
const {configs, onCompleted, onError, onNext, variables, cacheConfig} =
|
|
73
|
+
config;
|
|
82
74
|
const operation = createOperationDescriptor(
|
|
83
75
|
subscription,
|
|
84
76
|
variables,
|
|
@@ -100,7 +92,7 @@ function requestSubscription<TSubscriptionPayload>(
|
|
|
100
92
|
: config;
|
|
101
93
|
|
|
102
94
|
const sub = environment
|
|
103
|
-
.
|
|
95
|
+
.executeSubscription({
|
|
104
96
|
operation,
|
|
105
97
|
updater,
|
|
106
98
|
})
|
package/util/ReaderNode.js.flow
CHANGED
|
@@ -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
|
|
@@ -4,7 +4,7 @@
|
|
|
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,7 +14,9 @@
|
|
|
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,
|
|
@@ -28,9 +30,15 @@ type FeatureFlags = {|
|
|
|
28
30
|
BATCH_ASYNC_MODULE_UPDATES_FN: ?(() => void) => Disposable,
|
|
29
31
|
ENABLE_CONTAINERS_SUBSCRIBE_ON_COMMIT: boolean,
|
|
30
32
|
ENABLE_QUERY_RENDERER_OFFSCREEN_SUPPORT: boolean,
|
|
33
|
+
MAX_DATA_ID_LENGTH: ?number,
|
|
34
|
+
REFACTOR_SUSPENSE_RESOURCE: boolean,
|
|
35
|
+
STRING_INTERN_LEVEL: number,
|
|
36
|
+
USE_REACT_CACHE: boolean,
|
|
31
37
|
|};
|
|
32
38
|
|
|
33
39
|
const RelayFeatureFlags: FeatureFlags = {
|
|
40
|
+
DELAY_CLEANUP_OF_PENDING_PRELOAD_QUERIES: false,
|
|
41
|
+
ENABLE_CLIENT_EDGES: false,
|
|
34
42
|
ENABLE_VARIABLE_CONNECTION_KEY: false,
|
|
35
43
|
ENABLE_PARTIAL_RENDERING_DEFAULT: true,
|
|
36
44
|
ENABLE_REACT_FLIGHT_COMPONENT_FIELD: false,
|
|
@@ -44,6 +52,10 @@ const RelayFeatureFlags: FeatureFlags = {
|
|
|
44
52
|
BATCH_ASYNC_MODULE_UPDATES_FN: null,
|
|
45
53
|
ENABLE_CONTAINERS_SUBSCRIBE_ON_COMMIT: false,
|
|
46
54
|
ENABLE_QUERY_RENDERER_OFFSCREEN_SUPPORT: false,
|
|
55
|
+
MAX_DATA_ID_LENGTH: null,
|
|
56
|
+
REFACTOR_SUSPENSE_RESOURCE: true,
|
|
57
|
+
STRING_INTERN_LEVEL: 0,
|
|
58
|
+
USE_REACT_CACHE: false,
|
|
47
59
|
};
|
|
48
60
|
|
|
49
61
|
module.exports = RelayFeatureFlags;
|
|
@@ -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',
|
|
@@ -4,7 +4,7 @@
|
|
|
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) Facebook, Inc. and its 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};
|
|
@@ -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: {...},
|
|
@@ -13,18 +13,17 @@
|
|
|
13
13
|
|
|
14
14
|
'use strict';
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const isEmptyObject = require('./isEmptyObject');
|
|
19
|
-
const stableCopy = require('./stableCopy');
|
|
16
|
+
import type {ReaderFragment} from './ReaderNode';
|
|
20
17
|
|
|
21
18
|
const {
|
|
22
19
|
getDataIDsFromFragment,
|
|
23
|
-
getVariablesFromFragment,
|
|
24
20
|
getSelector,
|
|
21
|
+
getVariablesFromFragment,
|
|
25
22
|
} = require('../store/RelayModernSelector');
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
const isEmptyObject = require('./isEmptyObject');
|
|
24
|
+
const RelayFeatureFlags = require('./RelayFeatureFlags');
|
|
25
|
+
const stableCopy = require('./stableCopy');
|
|
26
|
+
const {intern} = require('./StringInterner');
|
|
28
27
|
|
|
29
28
|
function getFragmentIdentifier(
|
|
30
29
|
fragmentNode: ReaderFragment,
|
|
@@ -43,6 +42,19 @@ function getFragmentIdentifier(
|
|
|
43
42
|
const dataIDs = getDataIDsFromFragment(fragmentNode, fragmentRef);
|
|
44
43
|
|
|
45
44
|
if (RelayFeatureFlags.ENABLE_GETFRAGMENTIDENTIFIER_OPTIMIZATION) {
|
|
45
|
+
let ids =
|
|
46
|
+
typeof dataIDs === 'undefined'
|
|
47
|
+
? 'missing'
|
|
48
|
+
: dataIDs == null
|
|
49
|
+
? 'null'
|
|
50
|
+
: Array.isArray(dataIDs)
|
|
51
|
+
? '[' + dataIDs.join(',') + ']'
|
|
52
|
+
: dataIDs;
|
|
53
|
+
ids =
|
|
54
|
+
RelayFeatureFlags.STRING_INTERN_LEVEL <= 1
|
|
55
|
+
? ids
|
|
56
|
+
: intern(ids, RelayFeatureFlags.MAX_DATA_ID_LENGTH);
|
|
57
|
+
|
|
46
58
|
return (
|
|
47
59
|
fragmentOwnerIdentifier +
|
|
48
60
|
'/' +
|
|
@@ -52,15 +64,15 @@ function getFragmentIdentifier(
|
|
|
52
64
|
? '{}'
|
|
53
65
|
: JSON.stringify(stableCopy(fragmentVariables))) +
|
|
54
66
|
'/' +
|
|
55
|
-
|
|
56
|
-
? 'missing'
|
|
57
|
-
: dataIDs == null
|
|
58
|
-
? 'null'
|
|
59
|
-
: Array.isArray(dataIDs)
|
|
60
|
-
? '[' + dataIDs.join(',') + ']'
|
|
61
|
-
: dataIDs)
|
|
67
|
+
ids
|
|
62
68
|
);
|
|
63
69
|
} else {
|
|
70
|
+
let ids = JSON.stringify(dataIDs) ?? 'missing';
|
|
71
|
+
ids =
|
|
72
|
+
RelayFeatureFlags.STRING_INTERN_LEVEL <= 1
|
|
73
|
+
? ids
|
|
74
|
+
: intern(ids, RelayFeatureFlags.MAX_DATA_ID_LENGTH);
|
|
75
|
+
|
|
64
76
|
return (
|
|
65
77
|
fragmentOwnerIdentifier +
|
|
66
78
|
'/' +
|
|
@@ -68,7 +80,7 @@ function getFragmentIdentifier(
|
|
|
68
80
|
'/' +
|
|
69
81
|
JSON.stringify(stableCopy(fragmentVariables)) +
|
|
70
82
|
'/' +
|
|
71
|
-
|
|
83
|
+
ids
|
|
72
84
|
);
|
|
73
85
|
}
|
|
74
86
|
}
|
|
@@ -13,14 +13,14 @@
|
|
|
13
13
|
|
|
14
14
|
'use strict';
|
|
15
15
|
|
|
16
|
-
const {REQUEST, SPLIT_OPERATION} = require('./RelayConcreteNode');
|
|
17
|
-
|
|
18
16
|
import type {
|
|
19
17
|
NormalizationOperation,
|
|
20
18
|
NormalizationRootNode,
|
|
21
19
|
NormalizationSplitOperation,
|
|
22
20
|
} from './NormalizationNode';
|
|
23
21
|
|
|
22
|
+
const {REQUEST, SPLIT_OPERATION} = require('./RelayConcreteNode');
|
|
23
|
+
|
|
24
24
|
/**
|
|
25
25
|
* OperationLoaders can return either a NormalizationSplitOperation or
|
|
26
26
|
* ConcreteRequest.
|
|
@@ -13,15 +13,15 @@
|
|
|
13
13
|
|
|
14
14
|
'use strict';
|
|
15
15
|
|
|
16
|
-
const getRefetchMetadata = require('./getRefetchMetadata');
|
|
17
|
-
const invariant = require('invariant');
|
|
18
|
-
|
|
19
16
|
import type {
|
|
20
17
|
ConcreteRequest,
|
|
21
18
|
ReaderFragment,
|
|
22
19
|
ReaderPaginationMetadata,
|
|
23
20
|
} from 'relay-runtime';
|
|
24
21
|
|
|
22
|
+
const getRefetchMetadata = require('./getRefetchMetadata');
|
|
23
|
+
const invariant = require('invariant');
|
|
24
|
+
|
|
25
25
|
function getPaginationMetadata(
|
|
26
26
|
fragmentNode: ReaderFragment,
|
|
27
27
|
componentDisplayName: string,
|
|
@@ -32,10 +32,8 @@ function getPaginationMetadata(
|
|
|
32
32
|
paginationMetadata: ReaderPaginationMetadata,
|
|
33
33
|
stream: boolean,
|
|
34
34
|
|} {
|
|
35
|
-
const {
|
|
36
|
-
|
|
37
|
-
refetchMetadata,
|
|
38
|
-
} = getRefetchMetadata(fragmentNode, componentDisplayName);
|
|
35
|
+
const {refetchableRequest: paginationRequest, refetchMetadata} =
|
|
36
|
+
getRefetchMetadata(fragmentNode, componentDisplayName);
|
|
39
37
|
|
|
40
38
|
const paginationMetadata = refetchMetadata.connection;
|
|
41
39
|
invariant(
|
|
@@ -13,12 +13,12 @@
|
|
|
13
13
|
|
|
14
14
|
'use strict';
|
|
15
15
|
|
|
16
|
-
const invariant = require('invariant');
|
|
17
|
-
const warning = require('warning');
|
|
18
|
-
|
|
19
16
|
import type {ReaderPaginationMetadata} from './ReaderNode';
|
|
20
17
|
import type {Variables} from './RelayRuntimeTypes';
|
|
21
18
|
|
|
19
|
+
const invariant = require('invariant');
|
|
20
|
+
const warning = require('warning');
|
|
21
|
+
|
|
22
22
|
export type Direction = 'forward' | 'backward';
|
|
23
23
|
|
|
24
24
|
function getPaginationVariables(
|
|
@@ -29,10 +29,8 @@ function getPaginationVariables(
|
|
|
29
29
|
extraVariables: Variables,
|
|
30
30
|
paginationMetadata: ReaderPaginationMetadata,
|
|
31
31
|
): {[string]: mixed, ...} {
|
|
32
|
-
const {
|
|
33
|
-
|
|
34
|
-
forward: forwardMetadata,
|
|
35
|
-
} = paginationMetadata;
|
|
32
|
+
const {backward: backwardMetadata, forward: forwardMetadata} =
|
|
33
|
+
paginationMetadata;
|
|
36
34
|
|
|
37
35
|
if (direction === 'backward') {
|
|
38
36
|
invariant(
|
|
@@ -56,7 +54,6 @@ function getPaginationVariables(
|
|
|
56
54
|
'determined by Relay.',
|
|
57
55
|
backwardMetadata.count,
|
|
58
56
|
);
|
|
59
|
-
// $FlowFixMe[cannot-spread-interface]
|
|
60
57
|
const paginationVariables = {
|
|
61
58
|
...baseVariables,
|
|
62
59
|
...extraVariables,
|
|
@@ -93,7 +90,6 @@ function getPaginationVariables(
|
|
|
93
90
|
'determined by Relay.',
|
|
94
91
|
forwardMetadata.count,
|
|
95
92
|
);
|
|
96
|
-
// $FlowFixMe[cannot-spread-interface]
|
|
97
93
|
const paginationVariables = {
|
|
98
94
|
...baseVariables,
|
|
99
95
|
...extraVariables,
|
|
@@ -13,11 +13,11 @@
|
|
|
13
13
|
|
|
14
14
|
'use strict';
|
|
15
15
|
|
|
16
|
-
const {getPromiseForActiveRequest} = require('../query/fetchQueryInternal');
|
|
17
|
-
|
|
18
16
|
import type {IEnvironment, RequestDescriptor} from '../store/RelayStoreTypes';
|
|
19
17
|
import type {ReaderFragment} from './ReaderNode';
|
|
20
18
|
|
|
19
|
+
const {getPromiseForActiveRequest} = require('../query/fetchQueryInternal');
|
|
20
|
+
|
|
21
21
|
function getPendingOperationsForFragment(
|
|
22
22
|
environment: IEnvironment,
|
|
23
23
|
fragmentNode: ReaderFragment,
|
|
@@ -13,14 +13,14 @@
|
|
|
13
13
|
|
|
14
14
|
'use strict';
|
|
15
15
|
|
|
16
|
-
const invariant = require('invariant');
|
|
17
|
-
|
|
18
16
|
import type {
|
|
19
17
|
ConcreteRequest,
|
|
20
18
|
ReaderFragment,
|
|
21
19
|
ReaderRefetchMetadata,
|
|
22
20
|
} from 'relay-runtime';
|
|
23
21
|
|
|
22
|
+
const invariant = require('invariant');
|
|
23
|
+
|
|
24
24
|
function getRefetchMetadata(
|
|
25
25
|
fragmentNode: ReaderFragment,
|
|
26
26
|
componentDisplayName: string,
|
|
@@ -51,11 +51,10 @@ function getRefetchMetadata(
|
|
|
51
51
|
);
|
|
52
52
|
|
|
53
53
|
// handle both commonjs and es modules
|
|
54
|
-
const refetchableRequest:
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
: refetchMetadata.operation;
|
|
54
|
+
const refetchableRequest: ConcreteRequest | string =
|
|
55
|
+
(refetchMetadata: $FlowFixMe).operation.default
|
|
56
|
+
? (refetchMetadata: $FlowFixMe).operation.default
|
|
57
|
+
: refetchMetadata.operation;
|
|
59
58
|
const fragmentRefPathInResponse = refetchMetadata.fragmentPathInResult;
|
|
60
59
|
invariant(
|
|
61
60
|
typeof refetchableRequest !== 'string',
|
|
@@ -12,12 +12,12 @@
|
|
|
12
12
|
|
|
13
13
|
'use strict';
|
|
14
14
|
|
|
15
|
-
const invariant = require('invariant');
|
|
16
|
-
const stableCopy = require('./stableCopy');
|
|
17
|
-
|
|
18
15
|
import type {RequestParameters} from './RelayConcreteNode';
|
|
19
16
|
import type {Variables} from './RelayRuntimeTypes';
|
|
20
17
|
|
|
18
|
+
const stableCopy = require('./stableCopy');
|
|
19
|
+
const invariant = require('invariant');
|
|
20
|
+
|
|
21
21
|
export type RequestIdentifier = string;
|
|
22
22
|
|
|
23
23
|
/**
|