relay-runtime 7.0.0 → 9.1.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 +34 -0
- package/handlers/connection/ConnectionHandler.js.flow +549 -0
- package/handlers/connection/ConnectionInterface.js.flow +92 -0
- package/index.js +1 -1
- package/index.js.flow +314 -0
- package/lib/handlers/RelayDefaultHandlerProvider.js +3 -2
- package/lib/handlers/connection/{RelayConnectionHandler.js → ConnectionHandler.js} +34 -35
- package/lib/handlers/connection/{RelayConnectionInterface.js → ConnectionInterface.js} +3 -30
- package/lib/index.js +29 -27
- package/lib/mutations/RelayDeclarativeMutationConfig.js +30 -52
- package/lib/mutations/RelayRecordProxy.js +6 -3
- package/lib/mutations/RelayRecordSourceMutator.js +3 -9
- package/lib/mutations/RelayRecordSourceProxy.js +21 -24
- package/lib/mutations/RelayRecordSourceSelectorProxy.js +18 -14
- package/lib/mutations/applyOptimisticMutation.js +2 -1
- package/lib/mutations/commitLocalUpdate.js +1 -0
- package/lib/mutations/commitMutation.js +26 -8
- package/lib/mutations/validateMutation.js +21 -11
- package/lib/network/ConvertToExecuteFunction.js +1 -0
- package/lib/network/RelayNetwork.js +1 -0
- package/lib/network/RelayNetworkTypes.js +1 -0
- package/lib/network/RelayObservable.js +10 -9
- package/lib/network/RelayQueryResponseCache.js +9 -7
- package/lib/query/{RelayModernGraphQLTag.js → GraphQLTag.js} +15 -8
- package/lib/query/fetchQuery.js +2 -1
- package/lib/query/fetchQueryInternal.js +30 -20
- package/lib/store/ClientID.js +1 -0
- package/lib/store/DataChecker.js +47 -97
- package/lib/store/RelayConcreteVariables.js +7 -2
- package/lib/store/RelayModernEnvironment.js +82 -41
- package/lib/store/RelayModernFragmentSpecResolver.js +61 -21
- package/lib/store/RelayModernOperationDescriptor.js +2 -1
- package/lib/store/RelayModernQueryExecutor.js +476 -333
- package/lib/store/RelayModernRecord.js +39 -9
- package/lib/store/RelayModernSelector.js +2 -1
- package/lib/store/RelayModernStore.js +359 -371
- package/lib/store/RelayOperationTracker.js +36 -78
- package/lib/store/RelayOptimisticRecordSource.js +8 -5
- package/lib/store/RelayPublishQueue.js +66 -53
- package/lib/store/RelayReader.js +2 -24
- package/lib/store/RelayRecordSource.js +3 -9
- package/lib/store/RelayRecordSourceMapImpl.js +14 -18
- package/lib/store/RelayRecordState.js +1 -0
- package/lib/store/RelayReferenceMarker.js +8 -58
- package/lib/store/RelayResponseNormalizer.js +15 -144
- package/lib/store/RelayStoreTypes.js +1 -0
- package/lib/store/RelayStoreUtils.js +34 -10
- package/lib/store/StoreInspector.js +11 -5
- package/lib/store/ViewerPattern.js +1 -0
- package/lib/store/cloneRelayHandleSourceField.js +1 -0
- package/lib/store/createFragmentSpecResolver.js +1 -0
- package/lib/store/createRelayContext.js +1 -0
- package/lib/store/defaultGetDataID.js +1 -0
- package/lib/store/hasOverlappingIDs.js +1 -0
- package/lib/store/isRelayModernEnvironment.js +1 -0
- package/lib/store/normalizeRelayPayload.js +8 -4
- package/lib/store/readInlineData.js +2 -1
- package/lib/subscription/requestSubscription.js +6 -3
- package/lib/util/JSResourceTypes.flow.js +12 -0
- package/lib/util/NormalizationNode.js +1 -0
- package/lib/util/ReaderNode.js +1 -0
- package/lib/util/RelayConcreteNode.js +3 -0
- package/lib/util/RelayDefaultHandleKey.js +1 -0
- package/lib/util/RelayError.js +2 -1
- package/lib/util/RelayFeatureFlags.js +3 -2
- package/lib/util/RelayProfiler.js +1 -0
- package/lib/util/RelayReplaySubject.js +2 -3
- package/lib/util/RelayRuntimeTypes.js +1 -0
- package/lib/util/createPayloadFor3DField.js +34 -0
- package/lib/util/deepFreeze.js +1 -0
- package/lib/util/generateID.js +1 -0
- package/lib/util/getFragmentIdentifier.js +1 -0
- package/lib/util/getRelayHandleKey.js +1 -0
- package/lib/util/getRequestIdentifier.js +1 -0
- package/lib/util/isPromise.js +1 -0
- package/lib/util/isScalarAndEqual.js +1 -0
- package/lib/util/recycleNodesInto.js +1 -0
- package/lib/util/resolveImmediate.js +1 -0
- package/lib/util/stableCopy.js +1 -0
- package/mutations/RelayDeclarativeMutationConfig.js.flow +380 -0
- package/mutations/RelayRecordProxy.js.flow +165 -0
- package/mutations/RelayRecordSourceMutator.js.flow +238 -0
- package/mutations/RelayRecordSourceProxy.js.flow +164 -0
- package/mutations/RelayRecordSourceSelectorProxy.js.flow +119 -0
- package/mutations/applyOptimisticMutation.js.flow +76 -0
- package/mutations/commitLocalUpdate.js.flow +24 -0
- package/mutations/commitMutation.js.flow +184 -0
- package/mutations/validateMutation.js.flow +211 -0
- package/network/ConvertToExecuteFunction.js.flow +49 -0
- package/network/RelayNetwork.js.flow +84 -0
- package/network/RelayNetworkTypes.js.flow +123 -0
- package/network/RelayObservable.js.flow +634 -0
- package/network/RelayQueryResponseCache.js.flow +111 -0
- package/package.json +1 -1
- package/query/GraphQLTag.js.flow +166 -0
- package/query/fetchQuery.js.flow +47 -0
- package/query/fetchQueryInternal.js.flow +349 -0
- package/relay-runtime.js +2 -2
- package/relay-runtime.min.js +2 -2
- package/store/ClientID.js.flow +43 -0
- package/store/DataChecker.js.flow +426 -0
- package/store/RelayConcreteVariables.js.flow +96 -0
- package/store/RelayModernEnvironment.js.flow +526 -0
- package/store/RelayModernFragmentSpecResolver.js.flow +426 -0
- package/store/RelayModernOperationDescriptor.js.flow +88 -0
- package/store/RelayModernQueryExecutor.js.flow +1327 -0
- package/store/RelayModernRecord.js.flow +403 -0
- package/store/RelayModernSelector.js.flow +444 -0
- package/store/RelayModernStore.js.flow +757 -0
- package/store/RelayOperationTracker.js.flow +164 -0
- package/store/RelayOptimisticRecordSource.js.flow +119 -0
- package/store/RelayPublishQueue.js.flow +401 -0
- package/store/RelayReader.js.flow +376 -0
- package/store/RelayRecordSource.js.flow +29 -0
- package/store/RelayRecordSourceMapImpl.js.flow +87 -0
- package/store/RelayRecordState.js.flow +37 -0
- package/store/RelayReferenceMarker.js.flow +236 -0
- package/store/RelayResponseNormalizer.js.flow +556 -0
- package/store/RelayStoreTypes.js.flow +873 -0
- package/store/RelayStoreUtils.js.flow +218 -0
- package/store/StoreInspector.js.flow +173 -0
- package/store/ViewerPattern.js.flow +26 -0
- package/store/cloneRelayHandleSourceField.js.flow +66 -0
- package/store/createFragmentSpecResolver.js.flow +55 -0
- package/store/createRelayContext.js.flow +44 -0
- package/store/defaultGetDataID.js.flow +27 -0
- package/store/hasOverlappingIDs.js.flow +34 -0
- package/store/isRelayModernEnvironment.js.flow +27 -0
- package/store/normalizeRelayPayload.js.flow +51 -0
- package/store/readInlineData.js.flow +75 -0
- package/subscription/requestSubscription.js.flow +100 -0
- package/util/JSResourceTypes.flow.js.flow +20 -0
- package/util/NormalizationNode.js.flow +191 -0
- package/util/ReaderNode.js.flow +208 -0
- package/util/RelayConcreteNode.js.flow +80 -0
- package/util/RelayDefaultHandleKey.js.flow +17 -0
- package/util/RelayError.js.flow +33 -0
- package/util/RelayFeatureFlags.js.flow +30 -0
- package/util/RelayProfiler.js.flow +284 -0
- package/util/RelayReplaySubject.js.flow +134 -0
- package/util/RelayRuntimeTypes.js.flow +70 -0
- package/util/createPayloadFor3DField.js.flow +43 -0
- package/util/deepFreeze.js.flow +36 -0
- package/util/generateID.js.flow +21 -0
- package/util/getFragmentIdentifier.js.flow +52 -0
- package/util/getRelayHandleKey.js.flow +41 -0
- package/util/getRequestIdentifier.js.flow +41 -0
- package/util/isPromise.js.flow +21 -0
- package/util/isScalarAndEqual.js.flow +26 -0
- package/util/recycleNodesInto.js.flow +80 -0
- package/util/resolveImmediate.js.flow +30 -0
- package/util/stableCopy.js.flow +35 -0
- package/lib/handlers/RelayDefaultMissingFieldHandlers.js +0 -26
- package/lib/store/RelayConnection.js +0 -36
- package/lib/store/RelayConnectionResolver.js +0 -177
- package/lib/store/RelayRecordSourceObjectImpl.js +0 -78
- package/lib/util/getFragmentSpecIdentifier.js +0 -26
|
@@ -0,0 +1,51 @@
|
|
|
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-local
|
|
8
|
+
* @format
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
// flowlint ambiguous-object-type:error
|
|
12
|
+
|
|
13
|
+
'use strict';
|
|
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
|
+
import type {PayloadData, PayloadError} from '../network/RelayNetworkTypes';
|
|
22
|
+
import type {NormalizationOptions} from './RelayResponseNormalizer';
|
|
23
|
+
import type {
|
|
24
|
+
RelayResponsePayload,
|
|
25
|
+
NormalizationSelector,
|
|
26
|
+
} from './RelayStoreTypes';
|
|
27
|
+
|
|
28
|
+
function normalizeRelayPayload(
|
|
29
|
+
selector: NormalizationSelector,
|
|
30
|
+
payload: PayloadData,
|
|
31
|
+
errors: ?Array<PayloadError>,
|
|
32
|
+
options: NormalizationOptions,
|
|
33
|
+
): RelayResponsePayload {
|
|
34
|
+
const source = RelayRecordSource.create();
|
|
35
|
+
source.set(
|
|
36
|
+
selector.dataID,
|
|
37
|
+
RelayModernRecord.create(selector.dataID, ROOT_TYPE),
|
|
38
|
+
);
|
|
39
|
+
const relayPayload = RelayResponseNormalizer.normalize(
|
|
40
|
+
source,
|
|
41
|
+
selector,
|
|
42
|
+
payload,
|
|
43
|
+
options,
|
|
44
|
+
);
|
|
45
|
+
return {
|
|
46
|
+
...relayPayload,
|
|
47
|
+
errors,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
module.exports = normalizeRelayPayload;
|
|
@@ -0,0 +1,75 @@
|
|
|
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-local
|
|
8
|
+
* @format
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
// flowlint ambiguous-object-type:error
|
|
12
|
+
|
|
13
|
+
'use strict';
|
|
14
|
+
|
|
15
|
+
const invariant = require('invariant');
|
|
16
|
+
|
|
17
|
+
const {getInlineDataFragment} = require('../query/GraphQLTag');
|
|
18
|
+
const {FRAGMENTS_KEY} = require('./RelayStoreUtils');
|
|
19
|
+
|
|
20
|
+
import type {GraphQLTaggedNode} from '../query/GraphQLTag';
|
|
21
|
+
import type {FragmentReference} from './RelayStoreTypes';
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Reads an @inline data fragment that was spread into the parent fragment.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
declare function readInlineData<
|
|
28
|
+
TRef: FragmentReference,
|
|
29
|
+
TData,
|
|
30
|
+
TKey: {
|
|
31
|
+
+$data?: TData,
|
|
32
|
+
+$fragmentRefs: TRef,
|
|
33
|
+
...
|
|
34
|
+
},
|
|
35
|
+
>(
|
|
36
|
+
fragment: GraphQLTaggedNode,
|
|
37
|
+
fragmentRef: TKey,
|
|
38
|
+
): TData;
|
|
39
|
+
declare function readInlineData<
|
|
40
|
+
TRef: FragmentReference,
|
|
41
|
+
TData,
|
|
42
|
+
TKey: ?{
|
|
43
|
+
+$data?: TData,
|
|
44
|
+
+$fragmentRefs: TRef,
|
|
45
|
+
...
|
|
46
|
+
},
|
|
47
|
+
>(
|
|
48
|
+
fragment: GraphQLTaggedNode,
|
|
49
|
+
fragmentRef: null | void,
|
|
50
|
+
): ?TData;
|
|
51
|
+
function readInlineData(
|
|
52
|
+
fragment: GraphQLTaggedNode,
|
|
53
|
+
fragmentRef: mixed,
|
|
54
|
+
): mixed {
|
|
55
|
+
const inlineDataFragment = getInlineDataFragment(fragment);
|
|
56
|
+
if (fragmentRef == null) {
|
|
57
|
+
return fragmentRef;
|
|
58
|
+
}
|
|
59
|
+
invariant(
|
|
60
|
+
typeof fragmentRef === 'object',
|
|
61
|
+
'readInlineData(): Expected an object, got `%s`.',
|
|
62
|
+
typeof fragmentRef,
|
|
63
|
+
);
|
|
64
|
+
// $FlowFixMe
|
|
65
|
+
const inlineData = fragmentRef[FRAGMENTS_KEY]?.[inlineDataFragment.name];
|
|
66
|
+
invariant(
|
|
67
|
+
inlineData != null,
|
|
68
|
+
'readInlineData(): Expected fragment `%s` to be spread in the parent ' +
|
|
69
|
+
'fragment.',
|
|
70
|
+
inlineDataFragment.name,
|
|
71
|
+
);
|
|
72
|
+
return inlineData;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
module.exports = readInlineData;
|
|
@@ -0,0 +1,100 @@
|
|
|
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
|
|
8
|
+
* @format
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
// flowlint ambiguous-object-type:error
|
|
12
|
+
|
|
13
|
+
'use strict';
|
|
14
|
+
|
|
15
|
+
const RelayDeclarativeMutationConfig = require('../mutations/RelayDeclarativeMutationConfig');
|
|
16
|
+
|
|
17
|
+
const warning = require('warning');
|
|
18
|
+
|
|
19
|
+
const {getRequest} = require('../query/GraphQLTag');
|
|
20
|
+
const {
|
|
21
|
+
createOperationDescriptor,
|
|
22
|
+
} = require('../store/RelayModernOperationDescriptor');
|
|
23
|
+
|
|
24
|
+
import type {DeclarativeMutationConfig} from '../mutations/RelayDeclarativeMutationConfig';
|
|
25
|
+
import type {GraphQLTaggedNode} from '../query/GraphQLTag';
|
|
26
|
+
import type {
|
|
27
|
+
IEnvironment,
|
|
28
|
+
SelectorStoreUpdater,
|
|
29
|
+
} from '../store/RelayStoreTypes';
|
|
30
|
+
import type {
|
|
31
|
+
CacheConfig,
|
|
32
|
+
Disposable,
|
|
33
|
+
Variables,
|
|
34
|
+
} from '../util/RelayRuntimeTypes';
|
|
35
|
+
|
|
36
|
+
export type GraphQLSubscriptionConfig<TSubscriptionPayload> = {|
|
|
37
|
+
configs?: Array<DeclarativeMutationConfig>,
|
|
38
|
+
cacheConfig?: CacheConfig,
|
|
39
|
+
subscription: GraphQLTaggedNode,
|
|
40
|
+
variables: Variables,
|
|
41
|
+
onCompleted?: ?() => void,
|
|
42
|
+
onError?: ?(error: Error) => void,
|
|
43
|
+
onNext?: ?(response: ?TSubscriptionPayload) => void,
|
|
44
|
+
updater?: ?SelectorStoreUpdater,
|
|
45
|
+
|};
|
|
46
|
+
|
|
47
|
+
function requestSubscription<TSubscriptionPayload>(
|
|
48
|
+
environment: IEnvironment,
|
|
49
|
+
config: GraphQLSubscriptionConfig<TSubscriptionPayload>,
|
|
50
|
+
): Disposable {
|
|
51
|
+
const subscription = getRequest(config.subscription);
|
|
52
|
+
if (subscription.params.operationKind !== 'subscription') {
|
|
53
|
+
throw new Error('requestSubscription: Must use Subscription operation');
|
|
54
|
+
}
|
|
55
|
+
const {
|
|
56
|
+
configs,
|
|
57
|
+
onCompleted,
|
|
58
|
+
onError,
|
|
59
|
+
onNext,
|
|
60
|
+
variables,
|
|
61
|
+
cacheConfig,
|
|
62
|
+
} = config;
|
|
63
|
+
const operation = createOperationDescriptor(subscription, variables);
|
|
64
|
+
|
|
65
|
+
warning(
|
|
66
|
+
!(config.updater && configs),
|
|
67
|
+
'requestSubscription: Expected only one of `updater` and `configs` to be provided',
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
const {updater} = configs
|
|
71
|
+
? RelayDeclarativeMutationConfig.convert(
|
|
72
|
+
configs,
|
|
73
|
+
subscription,
|
|
74
|
+
null /* optimisticUpdater */,
|
|
75
|
+
config.updater,
|
|
76
|
+
)
|
|
77
|
+
: config;
|
|
78
|
+
|
|
79
|
+
const sub = environment
|
|
80
|
+
.execute({
|
|
81
|
+
operation,
|
|
82
|
+
updater,
|
|
83
|
+
cacheConfig,
|
|
84
|
+
})
|
|
85
|
+
.map(() => {
|
|
86
|
+
const data = environment.lookup(operation.fragment).data;
|
|
87
|
+
// $FlowFixMe
|
|
88
|
+
return (data: TSubscriptionPayload);
|
|
89
|
+
})
|
|
90
|
+
.subscribe({
|
|
91
|
+
next: onNext,
|
|
92
|
+
error: onError,
|
|
93
|
+
complete: onCompleted,
|
|
94
|
+
});
|
|
95
|
+
return {
|
|
96
|
+
dispose: sub.unsubscribe,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
module.exports = requestSubscription;
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
* @emails oncall+relay
|
|
8
|
+
* @flow strict
|
|
9
|
+
* @format
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
// flowlint ambiguous-object-type:error
|
|
13
|
+
|
|
14
|
+
'use strict';
|
|
15
|
+
|
|
16
|
+
export interface JSResourceReference<+T> {
|
|
17
|
+
+getModuleId: () => string;
|
|
18
|
+
+getModuleIfRequired: () => ?T;
|
|
19
|
+
+load: () => Promise<T>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,191 @@
|
|
|
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-local
|
|
8
|
+
* @format
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
// flowlint ambiguous-object-type:error
|
|
12
|
+
|
|
13
|
+
'use strict';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Represents a single operation used to processing and normalize runtime
|
|
17
|
+
* request results.
|
|
18
|
+
*/
|
|
19
|
+
export type NormalizationOperation = {|
|
|
20
|
+
+kind: 'Operation',
|
|
21
|
+
+name: string,
|
|
22
|
+
+argumentDefinitions: $ReadOnlyArray<NormalizationLocalArgumentDefinition>,
|
|
23
|
+
+selections: $ReadOnlyArray<NormalizationSelection>,
|
|
24
|
+
|};
|
|
25
|
+
|
|
26
|
+
export type NormalizationHandle =
|
|
27
|
+
| NormalizationScalarHandle
|
|
28
|
+
| NormalizationLinkedHandle;
|
|
29
|
+
|
|
30
|
+
export type NormalizationLinkedHandle = {|
|
|
31
|
+
+kind: 'LinkedHandle',
|
|
32
|
+
+alias: ?string,
|
|
33
|
+
+name: string,
|
|
34
|
+
+args: ?$ReadOnlyArray<NormalizationArgument>,
|
|
35
|
+
+handle: string,
|
|
36
|
+
+key: string,
|
|
37
|
+
// T45504512: new connection model
|
|
38
|
+
// NOTE: this property is optional because it's expected to be rarely used
|
|
39
|
+
+dynamicKey?: ?NormalizationArgument,
|
|
40
|
+
+filters: ?$ReadOnlyArray<string>,
|
|
41
|
+
|};
|
|
42
|
+
|
|
43
|
+
export type NormalizationScalarHandle = {|
|
|
44
|
+
+kind: 'ScalarHandle',
|
|
45
|
+
+alias: ?string,
|
|
46
|
+
+name: string,
|
|
47
|
+
+args: ?$ReadOnlyArray<NormalizationArgument>,
|
|
48
|
+
+handle: string,
|
|
49
|
+
+key: string,
|
|
50
|
+
// T45504512: new connection model
|
|
51
|
+
// NOTE: this property is optional because it's expected to be rarely used
|
|
52
|
+
+dynamicKey?: ?NormalizationArgument,
|
|
53
|
+
+filters: ?$ReadOnlyArray<string>,
|
|
54
|
+
|};
|
|
55
|
+
|
|
56
|
+
export type NormalizationArgument =
|
|
57
|
+
| NormalizationListValueArgument
|
|
58
|
+
| NormalizationLiteralArgument
|
|
59
|
+
| NormalizationObjectValueArgument
|
|
60
|
+
| NormalizationVariableArgument;
|
|
61
|
+
|
|
62
|
+
export type NormalizationCondition = {|
|
|
63
|
+
+kind: 'Condition',
|
|
64
|
+
+passingValue: boolean,
|
|
65
|
+
+condition: string,
|
|
66
|
+
+selections: $ReadOnlyArray<NormalizationSelection>,
|
|
67
|
+
|};
|
|
68
|
+
|
|
69
|
+
export type NormalizationClientExtension = {|
|
|
70
|
+
+kind: 'ClientExtension',
|
|
71
|
+
+selections: $ReadOnlyArray<NormalizationSelection>,
|
|
72
|
+
|};
|
|
73
|
+
|
|
74
|
+
export type NormalizationField =
|
|
75
|
+
| NormalizationScalarField
|
|
76
|
+
| NormalizationLinkedField;
|
|
77
|
+
|
|
78
|
+
export type NormalizationInlineFragment = {|
|
|
79
|
+
+kind: 'InlineFragment',
|
|
80
|
+
+selections: $ReadOnlyArray<NormalizationSelection>,
|
|
81
|
+
+type: string,
|
|
82
|
+
|};
|
|
83
|
+
|
|
84
|
+
export type NormalizationLinkedField = {|
|
|
85
|
+
+kind: 'LinkedField',
|
|
86
|
+
+alias: ?string,
|
|
87
|
+
+name: string,
|
|
88
|
+
+storageKey: ?string,
|
|
89
|
+
+args: ?$ReadOnlyArray<NormalizationArgument>,
|
|
90
|
+
+concreteType: ?string,
|
|
91
|
+
+plural: boolean,
|
|
92
|
+
+selections: $ReadOnlyArray<NormalizationSelection>,
|
|
93
|
+
|};
|
|
94
|
+
|
|
95
|
+
export type NormalizationModuleImport = {|
|
|
96
|
+
+kind: 'ModuleImport',
|
|
97
|
+
+documentName: string,
|
|
98
|
+
+fragmentPropName: string,
|
|
99
|
+
+fragmentName: string,
|
|
100
|
+
|};
|
|
101
|
+
|
|
102
|
+
export type NormalizationListValueArgument = {|
|
|
103
|
+
+kind: 'ListValue',
|
|
104
|
+
+name: string,
|
|
105
|
+
+items: $ReadOnlyArray<NormalizationArgument | null>,
|
|
106
|
+
|};
|
|
107
|
+
|
|
108
|
+
export type NormalizationLiteralArgument = {|
|
|
109
|
+
+kind: 'Literal',
|
|
110
|
+
+name: string,
|
|
111
|
+
+type?: ?string,
|
|
112
|
+
+value: mixed,
|
|
113
|
+
|};
|
|
114
|
+
|
|
115
|
+
export type NormalizationLocalArgumentDefinition = {|
|
|
116
|
+
+kind: 'LocalArgument',
|
|
117
|
+
+name: string,
|
|
118
|
+
+type: string,
|
|
119
|
+
+defaultValue: mixed,
|
|
120
|
+
|};
|
|
121
|
+
|
|
122
|
+
export type NormalizationNode =
|
|
123
|
+
| NormalizationClientExtension
|
|
124
|
+
| NormalizationCondition
|
|
125
|
+
| NormalizationDefer
|
|
126
|
+
| NormalizationInlineFragment
|
|
127
|
+
| NormalizationLinkedField
|
|
128
|
+
| NormalizationOperation
|
|
129
|
+
| NormalizationSplitOperation
|
|
130
|
+
| NormalizationStream;
|
|
131
|
+
|
|
132
|
+
export type NormalizationScalarField = {|
|
|
133
|
+
+kind: 'ScalarField',
|
|
134
|
+
+alias: ?string,
|
|
135
|
+
+name: string,
|
|
136
|
+
+args: ?$ReadOnlyArray<NormalizationArgument>,
|
|
137
|
+
+storageKey: ?string,
|
|
138
|
+
|};
|
|
139
|
+
|
|
140
|
+
export type NormalizationSelection =
|
|
141
|
+
| NormalizationCondition
|
|
142
|
+
| NormalizationClientExtension
|
|
143
|
+
| NormalizationDefer
|
|
144
|
+
| NormalizationField
|
|
145
|
+
| NormalizationHandle
|
|
146
|
+
| NormalizationInlineFragment
|
|
147
|
+
| NormalizationModuleImport
|
|
148
|
+
| NormalizationStream;
|
|
149
|
+
|
|
150
|
+
export type NormalizationSplitOperation = {|
|
|
151
|
+
+kind: 'SplitOperation',
|
|
152
|
+
+name: string,
|
|
153
|
+
+metadata: ?{+[key: string]: mixed, ...},
|
|
154
|
+
+selections: $ReadOnlyArray<NormalizationSelection>,
|
|
155
|
+
|};
|
|
156
|
+
|
|
157
|
+
export type NormalizationStream = {|
|
|
158
|
+
+if: string | null,
|
|
159
|
+
+kind: 'Stream',
|
|
160
|
+
+label: string,
|
|
161
|
+
+useCustomizedBatch: string | null,
|
|
162
|
+
+metadata: ?{+[key: string]: mixed, ...},
|
|
163
|
+
+selections: $ReadOnlyArray<NormalizationSelection>,
|
|
164
|
+
|};
|
|
165
|
+
|
|
166
|
+
export type NormalizationDefer = {|
|
|
167
|
+
+if: string | null,
|
|
168
|
+
+kind: 'Defer',
|
|
169
|
+
+label: string,
|
|
170
|
+
+selections: $ReadOnlyArray<NormalizationSelection>,
|
|
171
|
+
|};
|
|
172
|
+
|
|
173
|
+
export type NormalizationVariableArgument = {|
|
|
174
|
+
+kind: 'Variable',
|
|
175
|
+
+name: string,
|
|
176
|
+
+type?: ?string,
|
|
177
|
+
+variableName: string,
|
|
178
|
+
|};
|
|
179
|
+
|
|
180
|
+
export type NormalizationObjectValueArgument = {|
|
|
181
|
+
+kind: 'ObjectValue',
|
|
182
|
+
+name: string,
|
|
183
|
+
+fields: $ReadOnlyArray<NormalizationArgument>,
|
|
184
|
+
|};
|
|
185
|
+
|
|
186
|
+
export type NormalizationSelectableNode =
|
|
187
|
+
| NormalizationDefer
|
|
188
|
+
| NormalizationLinkedField
|
|
189
|
+
| NormalizationOperation
|
|
190
|
+
| NormalizationSplitOperation
|
|
191
|
+
| NormalizationStream;
|
|
@@ -0,0 +1,208 @@
|
|
|
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-local
|
|
8
|
+
* @format
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
// flowlint ambiguous-object-type:error
|
|
12
|
+
|
|
13
|
+
'use strict';
|
|
14
|
+
|
|
15
|
+
import type {ConnectionMetadata} from '../handlers/connection/ConnectionHandler';
|
|
16
|
+
import type {ConcreteRequest} from './RelayConcreteNode';
|
|
17
|
+
|
|
18
|
+
export type ReaderFragmentSpread = {|
|
|
19
|
+
+kind: 'FragmentSpread',
|
|
20
|
+
+name: string,
|
|
21
|
+
+args: ?$ReadOnlyArray<ReaderArgument>,
|
|
22
|
+
|};
|
|
23
|
+
|
|
24
|
+
export type ReaderInlineDataFragmentSpread = {|
|
|
25
|
+
+kind: 'InlineDataFragmentSpread',
|
|
26
|
+
+name: string,
|
|
27
|
+
+selections: $ReadOnlyArray<ReaderSelection>,
|
|
28
|
+
|};
|
|
29
|
+
|
|
30
|
+
export type ReaderFragment = {|
|
|
31
|
+
+kind: 'Fragment',
|
|
32
|
+
+name: string,
|
|
33
|
+
+type: string,
|
|
34
|
+
+metadata: ?{|
|
|
35
|
+
+connection?: $ReadOnlyArray<ConnectionMetadata>,
|
|
36
|
+
+mask?: boolean,
|
|
37
|
+
+plural?: boolean,
|
|
38
|
+
+refetch?: ReaderRefetchMetadata,
|
|
39
|
+
|},
|
|
40
|
+
+argumentDefinitions: $ReadOnlyArray<ReaderArgumentDefinition>,
|
|
41
|
+
+selections: $ReadOnlyArray<ReaderSelection>,
|
|
42
|
+
|};
|
|
43
|
+
|
|
44
|
+
// Marker type for a @refetchable fragment
|
|
45
|
+
export type ReaderRefetchableFragment = {|
|
|
46
|
+
...ReaderFragment,
|
|
47
|
+
+metadata: {|
|
|
48
|
+
+connection?: [ConnectionMetadata],
|
|
49
|
+
+refetch: ReaderRefetchMetadata,
|
|
50
|
+
|},
|
|
51
|
+
|};
|
|
52
|
+
|
|
53
|
+
// Marker Type for a @refetchable fragment with a single use of @connection
|
|
54
|
+
export type ReaderPaginationFragment = {|
|
|
55
|
+
...ReaderFragment,
|
|
56
|
+
+metadata: {|
|
|
57
|
+
+connection: [ConnectionMetadata],
|
|
58
|
+
+refetch: {|
|
|
59
|
+
...ReaderRefetchMetadata,
|
|
60
|
+
connection: ReaderPaginationMetadata,
|
|
61
|
+
|},
|
|
62
|
+
|},
|
|
63
|
+
|};
|
|
64
|
+
|
|
65
|
+
export type ReaderRefetchMetadata = {|
|
|
66
|
+
+connection: ?ReaderPaginationMetadata,
|
|
67
|
+
+operation: string | ConcreteRequest,
|
|
68
|
+
+fragmentPathInResult: Array<string>,
|
|
69
|
+
+identifierField?: ?string,
|
|
70
|
+
|};
|
|
71
|
+
|
|
72
|
+
// Stricter form of ConnectionMetadata
|
|
73
|
+
export type ReaderPaginationMetadata = {|
|
|
74
|
+
+backward: {|
|
|
75
|
+
+count: string,
|
|
76
|
+
+cursor: string,
|
|
77
|
+
|} | null,
|
|
78
|
+
+forward: {|
|
|
79
|
+
+count: string,
|
|
80
|
+
+cursor: string,
|
|
81
|
+
|} | null,
|
|
82
|
+
+path: $ReadOnlyArray<string>,
|
|
83
|
+
|};
|
|
84
|
+
|
|
85
|
+
export type ReaderInlineDataFragment = {|
|
|
86
|
+
+kind: 'InlineDataFragment',
|
|
87
|
+
+name: string,
|
|
88
|
+
|};
|
|
89
|
+
|
|
90
|
+
export type ReaderArgument =
|
|
91
|
+
| ReaderListValueArgument
|
|
92
|
+
| ReaderLiteralArgument
|
|
93
|
+
| ReaderObjectValueArgument
|
|
94
|
+
| ReaderVariableArgument;
|
|
95
|
+
|
|
96
|
+
export type ReaderArgumentDefinition = ReaderLocalArgument | ReaderRootArgument;
|
|
97
|
+
|
|
98
|
+
export type ReaderCondition = {|
|
|
99
|
+
+kind: 'Condition',
|
|
100
|
+
+passingValue: boolean,
|
|
101
|
+
+condition: string,
|
|
102
|
+
+selections: $ReadOnlyArray<ReaderSelection>,
|
|
103
|
+
|};
|
|
104
|
+
|
|
105
|
+
export type ReaderClientExtension = {|
|
|
106
|
+
+kind: 'ClientExtension',
|
|
107
|
+
+selections: $ReadOnlyArray<ReaderSelection>,
|
|
108
|
+
|};
|
|
109
|
+
|
|
110
|
+
export type ReaderField = ReaderScalarField | ReaderLinkedField;
|
|
111
|
+
|
|
112
|
+
export type ReaderRootArgument = {|
|
|
113
|
+
+kind: 'RootArgument',
|
|
114
|
+
+name: string,
|
|
115
|
+
+type: ?string,
|
|
116
|
+
|};
|
|
117
|
+
|
|
118
|
+
export type ReaderInlineFragment = {|
|
|
119
|
+
+kind: 'InlineFragment',
|
|
120
|
+
+selections: $ReadOnlyArray<ReaderSelection>,
|
|
121
|
+
+type: string,
|
|
122
|
+
|};
|
|
123
|
+
|
|
124
|
+
export type ReaderLinkedField = {|
|
|
125
|
+
+kind: 'LinkedField',
|
|
126
|
+
+alias: ?string,
|
|
127
|
+
+name: string,
|
|
128
|
+
+storageKey: ?string,
|
|
129
|
+
+args: ?$ReadOnlyArray<ReaderArgument>,
|
|
130
|
+
+concreteType: ?string,
|
|
131
|
+
+plural: boolean,
|
|
132
|
+
+selections: $ReadOnlyArray<ReaderSelection>,
|
|
133
|
+
|};
|
|
134
|
+
|
|
135
|
+
export type ReaderModuleImport = {|
|
|
136
|
+
+kind: 'ModuleImport',
|
|
137
|
+
+documentName: string,
|
|
138
|
+
+fragmentPropName: string,
|
|
139
|
+
+fragmentName: string,
|
|
140
|
+
|};
|
|
141
|
+
|
|
142
|
+
export type ReaderListValueArgument = {|
|
|
143
|
+
+kind: 'ListValue',
|
|
144
|
+
+name: string,
|
|
145
|
+
+items: $ReadOnlyArray<ReaderArgument | null>,
|
|
146
|
+
|};
|
|
147
|
+
|
|
148
|
+
export type ReaderLiteralArgument = {|
|
|
149
|
+
+kind: 'Literal',
|
|
150
|
+
+name: string,
|
|
151
|
+
+type?: ?string,
|
|
152
|
+
+value: mixed,
|
|
153
|
+
|};
|
|
154
|
+
|
|
155
|
+
export type ReaderLocalArgument = {|
|
|
156
|
+
+kind: 'LocalArgument',
|
|
157
|
+
+name: string,
|
|
158
|
+
+type: string,
|
|
159
|
+
+defaultValue: mixed,
|
|
160
|
+
|};
|
|
161
|
+
|
|
162
|
+
export type ReaderObjectValueArgument = {|
|
|
163
|
+
+kind: 'ObjectValue',
|
|
164
|
+
+name: string,
|
|
165
|
+
+fields: $ReadOnlyArray<ReaderArgument>,
|
|
166
|
+
|};
|
|
167
|
+
|
|
168
|
+
export type ReaderNode =
|
|
169
|
+
| ReaderCondition
|
|
170
|
+
| ReaderLinkedField
|
|
171
|
+
| ReaderFragment
|
|
172
|
+
| ReaderInlineFragment;
|
|
173
|
+
|
|
174
|
+
export type ReaderScalarField = {|
|
|
175
|
+
+kind: 'ScalarField',
|
|
176
|
+
+alias: ?string,
|
|
177
|
+
+name: string,
|
|
178
|
+
+args: ?$ReadOnlyArray<ReaderArgument>,
|
|
179
|
+
+storageKey: ?string,
|
|
180
|
+
|};
|
|
181
|
+
|
|
182
|
+
export type ReaderDefer = {|
|
|
183
|
+
+kind: 'Defer',
|
|
184
|
+
+selections: $ReadOnlyArray<ReaderSelection>,
|
|
185
|
+
|};
|
|
186
|
+
|
|
187
|
+
export type ReaderStream = {|
|
|
188
|
+
+kind: 'Stream',
|
|
189
|
+
+selections: $ReadOnlyArray<ReaderSelection>,
|
|
190
|
+
|};
|
|
191
|
+
|
|
192
|
+
export type ReaderSelection =
|
|
193
|
+
| ReaderCondition
|
|
194
|
+
| ReaderClientExtension
|
|
195
|
+
| ReaderDefer
|
|
196
|
+
| ReaderField
|
|
197
|
+
| ReaderFragmentSpread
|
|
198
|
+
| ReaderInlineDataFragmentSpread
|
|
199
|
+
| ReaderInlineFragment
|
|
200
|
+
| ReaderModuleImport
|
|
201
|
+
| ReaderStream;
|
|
202
|
+
|
|
203
|
+
export type ReaderVariableArgument = {|
|
|
204
|
+
+kind: 'Variable',
|
|
205
|
+
+name: string,
|
|
206
|
+
+type?: ?string,
|
|
207
|
+
+variableName: string,
|
|
208
|
+
|};
|