relay-runtime 8.0.0 → 10.0.1

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.
Files changed (135) hide show
  1. package/handlers/RelayDefaultHandlerProvider.js.flow +41 -0
  2. package/handlers/connection/ConnectionHandler.js.flow +549 -0
  3. package/handlers/connection/ConnectionInterface.js.flow +92 -0
  4. package/handlers/connection/MutationHandlers.js.flow +88 -0
  5. package/index.js +1 -1
  6. package/index.js.flow +320 -0
  7. package/lib/handlers/RelayDefaultHandlerProvider.js +13 -2
  8. package/lib/handlers/connection/{RelayConnectionHandler.js → ConnectionHandler.js} +33 -35
  9. package/lib/handlers/connection/{RelayConnectionInterface.js → ConnectionInterface.js} +2 -2
  10. package/lib/handlers/connection/MutationHandlers.js +86 -0
  11. package/lib/index.js +15 -19
  12. package/lib/mutations/RelayDeclarativeMutationConfig.js +29 -52
  13. package/lib/mutations/RelayRecordProxy.js +1 -3
  14. package/lib/mutations/RelayRecordSourceMutator.js +2 -9
  15. package/lib/mutations/RelayRecordSourceProxy.js +2 -4
  16. package/lib/mutations/RelayRecordSourceSelectorProxy.js +1 -13
  17. package/lib/mutations/commitMutation.js +13 -3
  18. package/lib/mutations/validateMutation.js +16 -9
  19. package/lib/network/RelayObservable.js +9 -9
  20. package/lib/network/RelayQueryResponseCache.js +8 -6
  21. package/lib/query/PreloadableQueryRegistry.js +70 -0
  22. package/lib/query/fetchQueryInternal.js +31 -23
  23. package/lib/store/DataChecker.js +122 -110
  24. package/lib/store/RelayConcreteVariables.js +6 -2
  25. package/lib/store/RelayModernEnvironment.js +121 -67
  26. package/lib/store/RelayModernFragmentSpecResolver.js +12 -16
  27. package/lib/store/RelayModernQueryExecutor.js +389 -314
  28. package/lib/store/RelayModernRecord.js +14 -9
  29. package/lib/store/RelayModernSelector.js +7 -3
  30. package/lib/store/RelayModernStore.js +289 -484
  31. package/lib/store/RelayOperationTracker.js +35 -78
  32. package/lib/store/RelayOptimisticRecordSource.js +7 -5
  33. package/lib/store/RelayPublishQueue.js +6 -33
  34. package/lib/store/RelayReader.js +113 -45
  35. package/lib/store/RelayRecordSource.js +2 -9
  36. package/lib/store/RelayRecordSourceMapImpl.js +13 -18
  37. package/lib/store/RelayReferenceMarker.js +40 -60
  38. package/lib/store/RelayResponseNormalizer.js +158 -193
  39. package/lib/store/RelayStoreUtils.js +1 -0
  40. package/lib/store/StoreInspector.js +8 -8
  41. package/lib/store/TypeID.js +28 -0
  42. package/lib/store/cloneRelayScalarHandleSourceField.js +44 -0
  43. package/lib/store/normalizeRelayPayload.js +6 -2
  44. package/lib/store/readInlineData.js +1 -1
  45. package/lib/subscription/requestSubscription.js +5 -3
  46. package/lib/util/RelayConcreteNode.js +9 -6
  47. package/lib/util/RelayError.js +39 -9
  48. package/lib/util/RelayFeatureFlags.js +2 -5
  49. package/lib/util/RelayReplaySubject.js +3 -3
  50. package/lib/util/createPayloadFor3DField.js +7 -2
  51. package/lib/util/getRequestIdentifier.js +2 -2
  52. package/lib/util/recycleNodesInto.js +2 -6
  53. package/mutations/RelayDeclarativeMutationConfig.js.flow +380 -0
  54. package/mutations/RelayRecordProxy.js.flow +165 -0
  55. package/mutations/RelayRecordSourceMutator.js.flow +238 -0
  56. package/mutations/RelayRecordSourceProxy.js.flow +164 -0
  57. package/mutations/RelayRecordSourceSelectorProxy.js.flow +119 -0
  58. package/mutations/applyOptimisticMutation.js.flow +76 -0
  59. package/mutations/commitLocalUpdate.js.flow +24 -0
  60. package/mutations/commitMutation.js.flow +182 -0
  61. package/mutations/validateMutation.js.flow +213 -0
  62. package/network/ConvertToExecuteFunction.js.flow +49 -0
  63. package/network/RelayNetwork.js.flow +84 -0
  64. package/network/RelayNetworkTypes.js.flow +123 -0
  65. package/network/RelayObservable.js.flow +634 -0
  66. package/network/RelayQueryResponseCache.js.flow +111 -0
  67. package/package.json +1 -1
  68. package/query/GraphQLTag.js.flow +166 -0
  69. package/query/PreloadableQueryRegistry.js.flow +65 -0
  70. package/query/fetchQuery.js.flow +47 -0
  71. package/query/fetchQueryInternal.js.flow +348 -0
  72. package/relay-runtime.js +2 -2
  73. package/relay-runtime.min.js +2 -2
  74. package/store/ClientID.js.flow +43 -0
  75. package/store/DataChecker.js.flow +502 -0
  76. package/store/RelayConcreteVariables.js.flow +96 -0
  77. package/store/RelayModernEnvironment.js.flow +551 -0
  78. package/store/RelayModernFragmentSpecResolver.js.flow +426 -0
  79. package/store/RelayModernOperationDescriptor.js.flow +88 -0
  80. package/store/RelayModernQueryExecutor.js.flow +1321 -0
  81. package/store/RelayModernRecord.js.flow +403 -0
  82. package/store/RelayModernSelector.js.flow +455 -0
  83. package/store/RelayModernStore.js.flow +842 -0
  84. package/store/RelayOperationTracker.js.flow +164 -0
  85. package/store/RelayOptimisticRecordSource.js.flow +119 -0
  86. package/store/RelayPublishQueue.js.flow +401 -0
  87. package/store/RelayReader.js.flow +473 -0
  88. package/store/RelayRecordSource.js.flow +29 -0
  89. package/store/RelayRecordSourceMapImpl.js.flow +87 -0
  90. package/store/RelayRecordState.js.flow +37 -0
  91. package/store/RelayReferenceMarker.js.flow +257 -0
  92. package/store/RelayResponseNormalizer.js.flow +680 -0
  93. package/store/RelayStoreTypes.js.flow +899 -0
  94. package/store/RelayStoreUtils.js.flow +219 -0
  95. package/store/StoreInspector.js.flow +171 -0
  96. package/store/TypeID.js.flow +28 -0
  97. package/store/ViewerPattern.js.flow +26 -0
  98. package/store/cloneRelayHandleSourceField.js.flow +66 -0
  99. package/store/cloneRelayScalarHandleSourceField.js.flow +62 -0
  100. package/store/createFragmentSpecResolver.js.flow +55 -0
  101. package/store/createRelayContext.js.flow +44 -0
  102. package/store/defaultGetDataID.js.flow +27 -0
  103. package/store/hasOverlappingIDs.js.flow +34 -0
  104. package/store/isRelayModernEnvironment.js.flow +27 -0
  105. package/store/normalizeRelayPayload.js.flow +51 -0
  106. package/store/readInlineData.js.flow +75 -0
  107. package/subscription/requestSubscription.js.flow +100 -0
  108. package/util/JSResourceTypes.flow.js.flow +20 -0
  109. package/util/NormalizationNode.js.flow +198 -0
  110. package/util/ReaderNode.js.flow +208 -0
  111. package/util/RelayConcreteNode.js.flow +93 -0
  112. package/util/RelayDefaultHandleKey.js.flow +17 -0
  113. package/util/RelayError.js.flow +62 -0
  114. package/util/RelayFeatureFlags.js.flow +30 -0
  115. package/util/RelayProfiler.js.flow +284 -0
  116. package/util/RelayReplaySubject.js.flow +135 -0
  117. package/util/RelayRuntimeTypes.js.flow +72 -0
  118. package/util/createPayloadFor3DField.js.flow +43 -0
  119. package/util/deepFreeze.js.flow +36 -0
  120. package/util/generateID.js.flow +21 -0
  121. package/util/getFragmentIdentifier.js.flow +52 -0
  122. package/util/getRelayHandleKey.js.flow +41 -0
  123. package/util/getRequestIdentifier.js.flow +42 -0
  124. package/util/isPromise.js.flow +21 -0
  125. package/util/isScalarAndEqual.js.flow +26 -0
  126. package/util/recycleNodesInto.js.flow +76 -0
  127. package/util/resolveImmediate.js.flow +30 -0
  128. package/util/stableCopy.js.flow +35 -0
  129. package/lib/handlers/RelayDefaultMissingFieldHandlers.js +0 -26
  130. package/lib/handlers/getRelayDefaultMissingFieldHandlers.js +0 -36
  131. package/lib/query/RelayModernGraphQLTag.js +0 -104
  132. package/lib/store/RelayConnection.js +0 -37
  133. package/lib/store/RelayConnectionResolver.js +0 -178
  134. package/lib/store/RelayRecordSourceObjectImpl.js +0 -79
  135. package/lib/util/getFragmentSpecIdentifier.js +0 -27
@@ -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,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[incompatible-cast]
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,198 @@
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
+ +handleArgs?: $ReadOnlyArray<NormalizationArgument>,
42
+ |};
43
+
44
+ export type NormalizationScalarHandle = {|
45
+ +kind: 'ScalarHandle',
46
+ +alias: ?string,
47
+ +name: string,
48
+ +args: ?$ReadOnlyArray<NormalizationArgument>,
49
+ +handle: string,
50
+ +key: string,
51
+ // T45504512: new connection model
52
+ // NOTE: this property is optional because it's expected to be rarely used
53
+ +dynamicKey?: ?NormalizationArgument,
54
+ +filters: ?$ReadOnlyArray<string>,
55
+ |};
56
+
57
+ export type NormalizationArgument =
58
+ | NormalizationListValueArgument
59
+ | NormalizationLiteralArgument
60
+ | NormalizationObjectValueArgument
61
+ | NormalizationVariableArgument;
62
+
63
+ export type NormalizationCondition = {|
64
+ +kind: 'Condition',
65
+ +passingValue: boolean,
66
+ +condition: string,
67
+ +selections: $ReadOnlyArray<NormalizationSelection>,
68
+ |};
69
+
70
+ export type NormalizationClientExtension = {|
71
+ +kind: 'ClientExtension',
72
+ +selections: $ReadOnlyArray<NormalizationSelection>,
73
+ |};
74
+
75
+ export type NormalizationField =
76
+ | NormalizationScalarField
77
+ | NormalizationLinkedField;
78
+
79
+ export type NormalizationInlineFragment = {|
80
+ +kind: 'InlineFragment',
81
+ +selections: $ReadOnlyArray<NormalizationSelection>,
82
+ +type: string,
83
+ +abstractKey: ?string,
84
+ |};
85
+
86
+ export type NormalizationLinkedField = {|
87
+ +kind: 'LinkedField',
88
+ +alias: ?string,
89
+ +name: string,
90
+ +storageKey: ?string,
91
+ +args: ?$ReadOnlyArray<NormalizationArgument>,
92
+ +concreteType: ?string,
93
+ +plural: boolean,
94
+ +selections: $ReadOnlyArray<NormalizationSelection>,
95
+ |};
96
+
97
+ export type NormalizationModuleImport = {|
98
+ +kind: 'ModuleImport',
99
+ +documentName: string,
100
+ +fragmentPropName: string,
101
+ +fragmentName: string,
102
+ |};
103
+
104
+ export type NormalizationListValueArgument = {|
105
+ +kind: 'ListValue',
106
+ +name: string,
107
+ +items: $ReadOnlyArray<NormalizationArgument | null>,
108
+ |};
109
+
110
+ export type NormalizationLiteralArgument = {|
111
+ +kind: 'Literal',
112
+ +name: string,
113
+ +type?: ?string,
114
+ +value: mixed,
115
+ |};
116
+
117
+ export type NormalizationLocalArgumentDefinition = {|
118
+ +kind: 'LocalArgument',
119
+ +name: string,
120
+ +defaultValue: mixed,
121
+ |};
122
+
123
+ export type NormalizationNode =
124
+ | NormalizationClientExtension
125
+ | NormalizationCondition
126
+ | NormalizationDefer
127
+ | NormalizationInlineFragment
128
+ | NormalizationLinkedField
129
+ | NormalizationOperation
130
+ | NormalizationSplitOperation
131
+ | NormalizationStream;
132
+
133
+ export type NormalizationScalarField = {|
134
+ +kind: 'ScalarField',
135
+ +alias: ?string,
136
+ +name: string,
137
+ +args: ?$ReadOnlyArray<NormalizationArgument>,
138
+ +storageKey: ?string,
139
+ |};
140
+
141
+ export type NormalizationTypeDiscriminator = {|
142
+ +kind: 'TypeDiscriminator',
143
+ +abstractKey: string,
144
+ |};
145
+
146
+ export type NormalizationSelection =
147
+ | NormalizationCondition
148
+ | NormalizationClientExtension
149
+ | NormalizationDefer
150
+ | NormalizationField
151
+ | NormalizationHandle
152
+ | NormalizationInlineFragment
153
+ | NormalizationModuleImport
154
+ | NormalizationStream
155
+ | NormalizationTypeDiscriminator;
156
+
157
+ export type NormalizationSplitOperation = {|
158
+ +kind: 'SplitOperation',
159
+ +name: string,
160
+ +metadata: ?{+[key: string]: mixed, ...},
161
+ +selections: $ReadOnlyArray<NormalizationSelection>,
162
+ |};
163
+
164
+ export type NormalizationStream = {|
165
+ +if: string | null,
166
+ +kind: 'Stream',
167
+ +label: string,
168
+ +useCustomizedBatch: string | null,
169
+ +metadata: ?{+[key: string]: mixed, ...},
170
+ +selections: $ReadOnlyArray<NormalizationSelection>,
171
+ |};
172
+
173
+ export type NormalizationDefer = {|
174
+ +if: string | null,
175
+ +kind: 'Defer',
176
+ +label: string,
177
+ +selections: $ReadOnlyArray<NormalizationSelection>,
178
+ |};
179
+
180
+ export type NormalizationVariableArgument = {|
181
+ +kind: 'Variable',
182
+ +name: string,
183
+ +type?: ?string,
184
+ +variableName: string,
185
+ |};
186
+
187
+ export type NormalizationObjectValueArgument = {|
188
+ +kind: 'ObjectValue',
189
+ +name: string,
190
+ +fields: $ReadOnlyArray<NormalizationArgument>,
191
+ |};
192
+
193
+ export type NormalizationSelectableNode =
194
+ | NormalizationDefer
195
+ | NormalizationLinkedField
196
+ | NormalizationOperation
197
+ | NormalizationSplitOperation
198
+ | 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
+ +abstractKey: ?string,
35
+ +metadata: ?{|
36
+ +connection?: $ReadOnlyArray<ConnectionMetadata>,
37
+ +mask?: boolean,
38
+ +plural?: boolean,
39
+ +refetch?: ReaderRefetchMetadata,
40
+ |},
41
+ +argumentDefinitions: $ReadOnlyArray<ReaderArgumentDefinition>,
42
+ +selections: $ReadOnlyArray<ReaderSelection>,
43
+ |};
44
+
45
+ // Marker type for a @refetchable fragment
46
+ export type ReaderRefetchableFragment = {|
47
+ ...ReaderFragment,
48
+ +metadata: {|
49
+ +connection?: [ConnectionMetadata],
50
+ +refetch: ReaderRefetchMetadata,
51
+ |},
52
+ |};
53
+
54
+ // Marker Type for a @refetchable fragment with a single use of @connection
55
+ export type ReaderPaginationFragment = {|
56
+ ...ReaderFragment,
57
+ +metadata: {|
58
+ +connection: [ConnectionMetadata],
59
+ +refetch: {|
60
+ ...ReaderRefetchMetadata,
61
+ connection: ReaderPaginationMetadata,
62
+ |},
63
+ |},
64
+ |};
65
+
66
+ export type ReaderRefetchMetadata = {|
67
+ +connection: ?ReaderPaginationMetadata,
68
+ +operation: string | ConcreteRequest,
69
+ +fragmentPathInResult: Array<string>,
70
+ +identifierField?: ?string,
71
+ |};
72
+
73
+ // Stricter form of ConnectionMetadata
74
+ export type ReaderPaginationMetadata = {|
75
+ +backward: {|
76
+ +count: string,
77
+ +cursor: string,
78
+ |} | null,
79
+ +forward: {|
80
+ +count: string,
81
+ +cursor: string,
82
+ |} | null,
83
+ +path: $ReadOnlyArray<string>,
84
+ |};
85
+
86
+ export type ReaderInlineDataFragment = {|
87
+ +kind: 'InlineDataFragment',
88
+ +name: string,
89
+ |};
90
+
91
+ export type ReaderArgument =
92
+ | ReaderListValueArgument
93
+ | ReaderLiteralArgument
94
+ | ReaderObjectValueArgument
95
+ | ReaderVariableArgument;
96
+
97
+ export type ReaderArgumentDefinition = ReaderLocalArgument | ReaderRootArgument;
98
+
99
+ export type ReaderCondition = {|
100
+ +kind: 'Condition',
101
+ +passingValue: boolean,
102
+ +condition: string,
103
+ +selections: $ReadOnlyArray<ReaderSelection>,
104
+ |};
105
+
106
+ export type ReaderClientExtension = {|
107
+ +kind: 'ClientExtension',
108
+ +selections: $ReadOnlyArray<ReaderSelection>,
109
+ |};
110
+
111
+ export type ReaderField = ReaderScalarField | ReaderLinkedField;
112
+
113
+ export type ReaderRootArgument = {|
114
+ +kind: 'RootArgument',
115
+ +name: string,
116
+ |};
117
+
118
+ export type ReaderInlineFragment = {|
119
+ +kind: 'InlineFragment',
120
+ +selections: $ReadOnlyArray<ReaderSelection>,
121
+ +type: string,
122
+ +abstractKey: ?string,
123
+ |};
124
+
125
+ export type ReaderLinkedField = {|
126
+ +kind: 'LinkedField',
127
+ +alias: ?string,
128
+ +name: string,
129
+ +storageKey: ?string,
130
+ +args: ?$ReadOnlyArray<ReaderArgument>,
131
+ +concreteType: ?string,
132
+ +plural: boolean,
133
+ +selections: $ReadOnlyArray<ReaderSelection>,
134
+ |};
135
+
136
+ export type ReaderModuleImport = {|
137
+ +kind: 'ModuleImport',
138
+ +documentName: string,
139
+ +fragmentPropName: string,
140
+ +fragmentName: string,
141
+ |};
142
+
143
+ export type ReaderListValueArgument = {|
144
+ +kind: 'ListValue',
145
+ +name: string,
146
+ +items: $ReadOnlyArray<ReaderArgument | null>,
147
+ |};
148
+
149
+ export type ReaderLiteralArgument = {|
150
+ +kind: 'Literal',
151
+ +name: string,
152
+ +type?: ?string,
153
+ +value: mixed,
154
+ |};
155
+
156
+ export type ReaderLocalArgument = {|
157
+ +kind: 'LocalArgument',
158
+ +name: 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
+ |};