relay-runtime 9.0.0 → 10.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 +47 -0
- package/handlers/connection/ConnectionHandler.js.flow +549 -0
- package/handlers/connection/ConnectionInterface.js.flow +92 -0
- package/handlers/connection/MutationHandlers.js.flow +199 -0
- package/index.js +1 -1
- package/index.js.flow +335 -0
- package/lib/handlers/RelayDefaultHandlerProvider.js +20 -0
- package/lib/handlers/connection/ConnectionHandler.js +1 -3
- package/lib/handlers/connection/MutationHandlers.js +212 -0
- package/lib/index.js +14 -2
- package/lib/mutations/RelayDeclarativeMutationConfig.js +22 -45
- package/lib/mutations/RelayRecordProxy.js +1 -3
- package/lib/mutations/RelayRecordSourceMutator.js +1 -3
- package/lib/mutations/RelayRecordSourceProxy.js +1 -3
- package/lib/mutations/RelayRecordSourceSelectorProxy.js +1 -3
- package/lib/mutations/commitMutation.js +2 -3
- package/lib/mutations/validateMutation.js +40 -9
- package/lib/network/RelayObservable.js +9 -9
- package/lib/network/RelayQueryResponseCache.js +8 -6
- package/lib/query/GraphQLTag.js +2 -1
- package/lib/query/PreloadableQueryRegistry.js +70 -0
- package/lib/query/fetchQuery.js +2 -3
- package/lib/query/fetchQueryInternal.js +5 -14
- package/lib/store/DataChecker.js +200 -71
- package/lib/store/RelayConcreteVariables.js +6 -2
- package/lib/store/RelayModernEnvironment.js +124 -65
- package/lib/store/RelayModernFragmentSpecResolver.js +19 -14
- package/lib/store/RelayModernOperationDescriptor.js +6 -5
- package/lib/store/RelayModernQueryExecutor.js +122 -73
- package/lib/store/RelayModernRecord.js +14 -9
- package/lib/store/RelayModernSelector.js +6 -2
- package/lib/store/RelayModernStore.js +281 -131
- package/lib/store/RelayOperationTracker.js +35 -78
- package/lib/store/RelayOptimisticRecordSource.js +7 -5
- package/lib/store/RelayPublishQueue.js +2 -4
- package/lib/store/RelayReader.js +304 -52
- package/lib/store/RelayRecordSource.js +1 -3
- package/lib/store/RelayRecordSourceMapImpl.js +13 -18
- package/lib/store/RelayReferenceMarker.js +125 -14
- package/lib/store/RelayResponseNormalizer.js +261 -66
- package/lib/store/RelayStoreReactFlightUtils.js +47 -0
- package/lib/store/RelayStoreUtils.js +1 -0
- package/lib/store/StoreInspector.js +8 -8
- package/lib/store/TypeID.js +28 -0
- package/lib/store/cloneRelayScalarHandleSourceField.js +44 -0
- package/lib/store/defaultRequiredFieldLogger.js +18 -0
- package/lib/store/normalizeRelayPayload.js +6 -2
- package/lib/store/readInlineData.js +1 -1
- package/lib/subscription/requestSubscription.js +4 -3
- package/lib/util/NormalizationNode.js +1 -5
- package/lib/util/RelayConcreteNode.js +11 -6
- package/lib/util/RelayError.js +39 -9
- package/lib/util/RelayFeatureFlags.js +6 -3
- package/lib/util/RelayReplaySubject.js +3 -3
- package/lib/util/createPayloadFor3DField.js +7 -2
- package/lib/util/getFragmentIdentifier.js +12 -3
- package/lib/util/getOperation.js +33 -0
- package/lib/util/getRequestIdentifier.js +2 -2
- package/lib/util/isEmptyObject.js +25 -0
- package/lib/util/recycleNodesInto.js +6 -7
- package/lib/util/reportMissingRequiredFields.js +48 -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 +181 -0
- package/mutations/validateMutation.js.flow +242 -0
- package/network/ConvertToExecuteFunction.js.flow +49 -0
- package/network/RelayNetwork.js.flow +84 -0
- package/network/RelayNetworkTypes.js.flow +145 -0
- package/network/RelayObservable.js.flow +634 -0
- package/network/RelayQueryResponseCache.js.flow +111 -0
- package/package.json +2 -2
- package/query/GraphQLTag.js.flow +168 -0
- package/query/PreloadableQueryRegistry.js.flow +65 -0
- package/query/fetchQuery.js.flow +47 -0
- package/query/fetchQueryInternal.js.flow +343 -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 +568 -0
- package/store/RelayConcreteVariables.js.flow +96 -0
- package/store/RelayModernEnvironment.js.flow +571 -0
- package/store/RelayModernFragmentSpecResolver.js.flow +438 -0
- package/store/RelayModernOperationDescriptor.js.flow +92 -0
- package/store/RelayModernQueryExecutor.js.flow +1345 -0
- package/store/RelayModernRecord.js.flow +403 -0
- package/store/RelayModernSelector.js.flow +455 -0
- package/store/RelayModernStore.js.flow +858 -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 +638 -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 +324 -0
- package/store/RelayResponseNormalizer.js.flow +791 -0
- package/store/RelayStoreReactFlightUtils.js.flow +64 -0
- package/store/RelayStoreTypes.js.flow +958 -0
- package/store/RelayStoreUtils.js.flow +219 -0
- package/store/StoreInspector.js.flow +171 -0
- package/store/TypeID.js.flow +28 -0
- package/store/ViewerPattern.js.flow +26 -0
- package/store/cloneRelayHandleSourceField.js.flow +66 -0
- package/store/cloneRelayScalarHandleSourceField.js.flow +62 -0
- package/store/createFragmentSpecResolver.js.flow +55 -0
- package/store/createRelayContext.js.flow +44 -0
- package/store/defaultGetDataID.js.flow +27 -0
- package/store/defaultRequiredFieldLogger.js.flow +23 -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 +103 -0
- package/util/JSResourceTypes.flow.js.flow +20 -0
- package/util/NormalizationNode.js.flow +213 -0
- package/util/ReaderNode.js.flow +227 -0
- package/util/RelayConcreteNode.js.flow +99 -0
- package/util/RelayDefaultHandleKey.js.flow +17 -0
- package/util/RelayError.js.flow +62 -0
- package/util/RelayFeatureFlags.js.flow +37 -0
- package/util/RelayProfiler.js.flow +284 -0
- package/util/RelayReplaySubject.js.flow +135 -0
- package/util/RelayRuntimeTypes.js.flow +72 -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 +76 -0
- package/util/getOperation.js.flow +40 -0
- package/util/getRelayHandleKey.js.flow +41 -0
- package/util/getRequestIdentifier.js.flow +42 -0
- package/util/isEmptyObject.js.flow +25 -0
- package/util/isPromise.js.flow +21 -0
- package/util/isScalarAndEqual.js.flow +26 -0
- package/util/recycleNodesInto.js.flow +87 -0
- package/util/reportMissingRequiredFields.js.flow +51 -0
- package/util/resolveImmediate.js.flow +30 -0
- package/util/stableCopy.js.flow +35 -0
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
import type {RequiredFieldLogger} from './RelayStoreTypes';
|
|
14
|
+
|
|
15
|
+
const defaultRequiredFieldLogger: RequiredFieldLogger = event => {
|
|
16
|
+
if (__DEV__ && event.kind === 'missing_field.log') {
|
|
17
|
+
throw new Error(
|
|
18
|
+
'Relay Environment Configuration Error (dev only): `@required(action: LOG)` requires that the Relay Environment be configured with a `requiredFieldLogger`.',
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
module.exports = defaultRequiredFieldLogger;
|
|
@@ -0,0 +1,34 @@
|
|
|
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 {RecordMap, UpdatedRecords} from './RelayStoreTypes';
|
|
16
|
+
|
|
17
|
+
const hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
18
|
+
|
|
19
|
+
function hasOverlappingIDs(
|
|
20
|
+
seenRecords: RecordMap,
|
|
21
|
+
updatedRecordIDs: UpdatedRecords,
|
|
22
|
+
): boolean {
|
|
23
|
+
for (const key in seenRecords) {
|
|
24
|
+
if (
|
|
25
|
+
hasOwnProperty.call(seenRecords, key) &&
|
|
26
|
+
hasOwnProperty.call(updatedRecordIDs, key)
|
|
27
|
+
) {
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
module.exports = hasOverlappingIDs;
|
|
@@ -0,0 +1,27 @@
|
|
|
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
|
+
/**
|
|
16
|
+
* Determine if a given value is an object that implements the `Environment`
|
|
17
|
+
* interface defined in `RelayStoreTypes`.
|
|
18
|
+
*
|
|
19
|
+
* Use a sigil for detection to avoid a realm-specific instanceof check, and to
|
|
20
|
+
* aid in module tree-shaking to avoid requiring all of RelayRuntime just to
|
|
21
|
+
* detect its environment.
|
|
22
|
+
*/
|
|
23
|
+
function isRelayModernEnvironment(environment: mixed): boolean {
|
|
24
|
+
return Boolean(environment && (environment: any)['@@RelayModernEnvironment']);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
module.exports = isRelayModernEnvironment;
|
|
@@ -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[incompatible-use]
|
|
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,103 @@
|
|
|
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(
|
|
64
|
+
subscription,
|
|
65
|
+
variables,
|
|
66
|
+
cacheConfig,
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
warning(
|
|
70
|
+
!(config.updater && configs),
|
|
71
|
+
'requestSubscription: Expected only one of `updater` and `configs` to be provided',
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
const {updater} = configs
|
|
75
|
+
? RelayDeclarativeMutationConfig.convert(
|
|
76
|
+
configs,
|
|
77
|
+
subscription,
|
|
78
|
+
null /* optimisticUpdater */,
|
|
79
|
+
config.updater,
|
|
80
|
+
)
|
|
81
|
+
: config;
|
|
82
|
+
|
|
83
|
+
const sub = environment
|
|
84
|
+
.execute({
|
|
85
|
+
operation,
|
|
86
|
+
updater,
|
|
87
|
+
})
|
|
88
|
+
.map(() => {
|
|
89
|
+
const data = environment.lookup(operation.fragment).data;
|
|
90
|
+
// $FlowFixMe[incompatible-cast]
|
|
91
|
+
return (data: TSubscriptionPayload);
|
|
92
|
+
})
|
|
93
|
+
.subscribe({
|
|
94
|
+
next: onNext,
|
|
95
|
+
error: onError,
|
|
96
|
+
complete: onCompleted,
|
|
97
|
+
});
|
|
98
|
+
return {
|
|
99
|
+
dispose: sub.unsubscribe,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
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,213 @@
|
|
|
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 {ConcreteRequest} from './RelayConcreteNode';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Represents a single operation used to processing and normalize runtime
|
|
19
|
+
* request results.
|
|
20
|
+
*/
|
|
21
|
+
export type NormalizationOperation = {|
|
|
22
|
+
+kind: 'Operation',
|
|
23
|
+
+name: string,
|
|
24
|
+
+argumentDefinitions: $ReadOnlyArray<NormalizationLocalArgumentDefinition>,
|
|
25
|
+
+selections: $ReadOnlyArray<NormalizationSelection>,
|
|
26
|
+
|};
|
|
27
|
+
|
|
28
|
+
export type NormalizationHandle =
|
|
29
|
+
| NormalizationScalarHandle
|
|
30
|
+
| NormalizationLinkedHandle;
|
|
31
|
+
|
|
32
|
+
export type NormalizationLinkedHandle = {|
|
|
33
|
+
+kind: 'LinkedHandle',
|
|
34
|
+
+alias: ?string,
|
|
35
|
+
+name: string,
|
|
36
|
+
+args: ?$ReadOnlyArray<NormalizationArgument>,
|
|
37
|
+
+handle: string,
|
|
38
|
+
+key: string,
|
|
39
|
+
// NOTE: this property is optional because it's expected to be rarely used
|
|
40
|
+
+dynamicKey?: ?NormalizationArgument,
|
|
41
|
+
+filters: ?$ReadOnlyArray<string>,
|
|
42
|
+
+handleArgs?: $ReadOnlyArray<NormalizationArgument>,
|
|
43
|
+
|};
|
|
44
|
+
|
|
45
|
+
export type NormalizationScalarHandle = {|
|
|
46
|
+
+kind: 'ScalarHandle',
|
|
47
|
+
+alias: ?string,
|
|
48
|
+
+name: string,
|
|
49
|
+
+args: ?$ReadOnlyArray<NormalizationArgument>,
|
|
50
|
+
+handle: string,
|
|
51
|
+
+key: string,
|
|
52
|
+
// NOTE: this property is optional because it's expected to be rarely used
|
|
53
|
+
+dynamicKey?: ?NormalizationArgument,
|
|
54
|
+
+filters: ?$ReadOnlyArray<string>,
|
|
55
|
+
+handleArgs?: $ReadOnlyArray<NormalizationArgument>,
|
|
56
|
+
|};
|
|
57
|
+
|
|
58
|
+
export type NormalizationArgument =
|
|
59
|
+
| NormalizationListValueArgument
|
|
60
|
+
| NormalizationLiteralArgument
|
|
61
|
+
| NormalizationObjectValueArgument
|
|
62
|
+
| NormalizationVariableArgument;
|
|
63
|
+
|
|
64
|
+
export type NormalizationCondition = {|
|
|
65
|
+
+kind: 'Condition',
|
|
66
|
+
+passingValue: boolean,
|
|
67
|
+
+condition: string,
|
|
68
|
+
+selections: $ReadOnlyArray<NormalizationSelection>,
|
|
69
|
+
|};
|
|
70
|
+
|
|
71
|
+
export type NormalizationClientExtension = {|
|
|
72
|
+
+kind: 'ClientExtension',
|
|
73
|
+
+selections: $ReadOnlyArray<NormalizationSelection>,
|
|
74
|
+
|};
|
|
75
|
+
|
|
76
|
+
export type NormalizationField =
|
|
77
|
+
| NormalizationFlightField
|
|
78
|
+
| NormalizationScalarField
|
|
79
|
+
| NormalizationLinkedField;
|
|
80
|
+
|
|
81
|
+
export type NormalizationInlineFragment = {|
|
|
82
|
+
+kind: 'InlineFragment',
|
|
83
|
+
+selections: $ReadOnlyArray<NormalizationSelection>,
|
|
84
|
+
+type: string,
|
|
85
|
+
+abstractKey: ?string,
|
|
86
|
+
|};
|
|
87
|
+
|
|
88
|
+
export type NormalizationLinkedField = {|
|
|
89
|
+
+kind: 'LinkedField',
|
|
90
|
+
+alias: ?string,
|
|
91
|
+
+name: string,
|
|
92
|
+
+storageKey: ?string,
|
|
93
|
+
+args: ?$ReadOnlyArray<NormalizationArgument>,
|
|
94
|
+
+concreteType: ?string,
|
|
95
|
+
+plural: boolean,
|
|
96
|
+
+selections: $ReadOnlyArray<NormalizationSelection>,
|
|
97
|
+
|};
|
|
98
|
+
|
|
99
|
+
export type NormalizationModuleImport = {|
|
|
100
|
+
+kind: 'ModuleImport',
|
|
101
|
+
+documentName: string,
|
|
102
|
+
+fragmentPropName: string,
|
|
103
|
+
+fragmentName: string,
|
|
104
|
+
|};
|
|
105
|
+
|
|
106
|
+
export type NormalizationListValueArgument = {|
|
|
107
|
+
+kind: 'ListValue',
|
|
108
|
+
+name: string,
|
|
109
|
+
+items: $ReadOnlyArray<NormalizationArgument | null>,
|
|
110
|
+
|};
|
|
111
|
+
|
|
112
|
+
export type NormalizationLiteralArgument = {|
|
|
113
|
+
+kind: 'Literal',
|
|
114
|
+
+name: string,
|
|
115
|
+
+type?: ?string,
|
|
116
|
+
+value: mixed,
|
|
117
|
+
|};
|
|
118
|
+
|
|
119
|
+
export type NormalizationLocalArgumentDefinition = {|
|
|
120
|
+
+kind: 'LocalArgument',
|
|
121
|
+
+name: string,
|
|
122
|
+
+defaultValue: mixed,
|
|
123
|
+
|};
|
|
124
|
+
|
|
125
|
+
export type NormalizationNode =
|
|
126
|
+
| NormalizationClientExtension
|
|
127
|
+
| NormalizationCondition
|
|
128
|
+
| NormalizationDefer
|
|
129
|
+
| NormalizationInlineFragment
|
|
130
|
+
| NormalizationLinkedField
|
|
131
|
+
| NormalizationOperation
|
|
132
|
+
| NormalizationSplitOperation
|
|
133
|
+
| NormalizationStream;
|
|
134
|
+
|
|
135
|
+
export type NormalizationScalarField = {|
|
|
136
|
+
+kind: 'ScalarField',
|
|
137
|
+
+alias: ?string,
|
|
138
|
+
+name: string,
|
|
139
|
+
+args: ?$ReadOnlyArray<NormalizationArgument>,
|
|
140
|
+
+storageKey: ?string,
|
|
141
|
+
|};
|
|
142
|
+
|
|
143
|
+
export type NormalizationFlightField = {|
|
|
144
|
+
+kind: 'FlightField',
|
|
145
|
+
+alias: ?string,
|
|
146
|
+
+name: string,
|
|
147
|
+
+args: ?$ReadOnlyArray<NormalizationArgument>,
|
|
148
|
+
+storageKey: ?string,
|
|
149
|
+
|};
|
|
150
|
+
|
|
151
|
+
export type NormalizationTypeDiscriminator = {|
|
|
152
|
+
+kind: 'TypeDiscriminator',
|
|
153
|
+
+abstractKey: string,
|
|
154
|
+
|};
|
|
155
|
+
|
|
156
|
+
export type NormalizationSelection =
|
|
157
|
+
| NormalizationCondition
|
|
158
|
+
| NormalizationClientExtension
|
|
159
|
+
| NormalizationDefer
|
|
160
|
+
| NormalizationField
|
|
161
|
+
| NormalizationFlightField
|
|
162
|
+
| NormalizationHandle
|
|
163
|
+
| NormalizationInlineFragment
|
|
164
|
+
| NormalizationModuleImport
|
|
165
|
+
| NormalizationStream
|
|
166
|
+
| NormalizationTypeDiscriminator;
|
|
167
|
+
|
|
168
|
+
export type NormalizationSplitOperation = {|
|
|
169
|
+
+kind: 'SplitOperation',
|
|
170
|
+
+name: string,
|
|
171
|
+
+metadata: ?{+[key: string]: mixed, ...},
|
|
172
|
+
+selections: $ReadOnlyArray<NormalizationSelection>,
|
|
173
|
+
|};
|
|
174
|
+
|
|
175
|
+
export type NormalizationStream = {|
|
|
176
|
+
+if: string | null,
|
|
177
|
+
+kind: 'Stream',
|
|
178
|
+
+label: string,
|
|
179
|
+
+useCustomizedBatch: string | null,
|
|
180
|
+
+metadata: ?{+[key: string]: mixed, ...},
|
|
181
|
+
+selections: $ReadOnlyArray<NormalizationSelection>,
|
|
182
|
+
|};
|
|
183
|
+
|
|
184
|
+
export type NormalizationDefer = {|
|
|
185
|
+
+if: string | null,
|
|
186
|
+
+kind: 'Defer',
|
|
187
|
+
+label: string,
|
|
188
|
+
+selections: $ReadOnlyArray<NormalizationSelection>,
|
|
189
|
+
|};
|
|
190
|
+
|
|
191
|
+
export type NormalizationVariableArgument = {|
|
|
192
|
+
+kind: 'Variable',
|
|
193
|
+
+name: string,
|
|
194
|
+
+type?: ?string,
|
|
195
|
+
+variableName: string,
|
|
196
|
+
|};
|
|
197
|
+
|
|
198
|
+
export type NormalizationObjectValueArgument = {|
|
|
199
|
+
+kind: 'ObjectValue',
|
|
200
|
+
+name: string,
|
|
201
|
+
+fields: $ReadOnlyArray<NormalizationArgument>,
|
|
202
|
+
|};
|
|
203
|
+
|
|
204
|
+
export type NormalizationSelectableNode =
|
|
205
|
+
| NormalizationDefer
|
|
206
|
+
| NormalizationLinkedField
|
|
207
|
+
| NormalizationOperation
|
|
208
|
+
| NormalizationSplitOperation
|
|
209
|
+
| NormalizationStream;
|
|
210
|
+
|
|
211
|
+
export type NormalizationRootNode =
|
|
212
|
+
| ConcreteRequest
|
|
213
|
+
| NormalizationSplitOperation;
|