relay-runtime 13.0.0-rc.0 → 13.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.
- package/LICENSE +1 -1
- package/README.md +67 -0
- package/handlers/RelayDefaultHandlerProvider.js.flow +1 -1
- package/handlers/connection/ConnectionHandler.js.flow +1 -1
- package/handlers/connection/ConnectionInterface.js.flow +1 -1
- package/handlers/connection/MutationHandlers.js.flow +1 -1
- package/index.js +2 -2
- package/index.js.flow +5 -1
- package/lib/handlers/RelayDefaultHandlerProvider.js +1 -1
- package/lib/handlers/connection/ConnectionHandler.js +1 -1
- package/lib/handlers/connection/ConnectionInterface.js +1 -1
- package/lib/handlers/connection/MutationHandlers.js +1 -1
- package/lib/index.js +8 -2
- package/lib/multi-actor-environment/ActorIdentifier.js +1 -1
- package/lib/multi-actor-environment/ActorSpecificEnvironment.js +1 -1
- package/lib/multi-actor-environment/ActorUtils.js +1 -1
- package/lib/multi-actor-environment/MultiActorEnvironment.js +1 -1
- package/lib/multi-actor-environment/MultiActorEnvironmentTypes.js +1 -1
- package/lib/multi-actor-environment/index.js +1 -1
- package/lib/mutations/RelayDeclarativeMutationConfig.js +1 -1
- package/lib/mutations/RelayRecordProxy.js +1 -1
- package/lib/mutations/RelayRecordSourceMutator.js +1 -1
- package/lib/mutations/RelayRecordSourceProxy.js +1 -1
- package/lib/mutations/RelayRecordSourceSelectorProxy.js +1 -1
- package/lib/mutations/applyOptimisticMutation.js +1 -1
- package/lib/mutations/commitLocalUpdate.js +1 -1
- package/lib/mutations/commitMutation.js +1 -1
- package/lib/mutations/readUpdatableQuery_EXPERIMENTAL.js +25 -16
- package/lib/mutations/validateMutation.js +1 -1
- package/lib/network/ConvertToExecuteFunction.js +1 -1
- package/lib/network/RelayNetwork.js +8 -4
- package/lib/network/RelayNetworkTypes.js +1 -1
- package/lib/network/RelayObservable.js +1 -1
- package/lib/network/RelayQueryResponseCache.js +1 -1
- package/lib/network/wrapNetworkWithLogObserver.js +1 -1
- package/lib/query/GraphQLTag.js +1 -1
- package/lib/query/PreloadableQueryRegistry.js +1 -1
- package/lib/query/fetchQuery.js +4 -1
- package/lib/query/fetchQueryInternal.js +1 -1
- package/lib/query/fetchQuery_DEPRECATED.js +1 -1
- package/lib/store/ClientID.js +1 -1
- package/lib/store/DataChecker.js +1 -1
- package/lib/store/OperationExecutor.js +1 -1
- package/lib/store/RelayConcreteVariables.js +14 -4
- package/lib/store/RelayExperimentalGraphResponseHandler.js +153 -0
- package/lib/store/RelayExperimentalGraphResponseTransform.js +391 -0
- package/lib/store/RelayModernEnvironment.js +1 -1
- package/lib/store/RelayModernFragmentSpecResolver.js +1 -1
- package/lib/store/RelayModernOperationDescriptor.js +2 -2
- package/lib/store/RelayModernRecord.js +1 -1
- package/lib/store/RelayModernSelector.js +1 -1
- package/lib/store/RelayModernStore.js +1 -1
- package/lib/store/RelayOperationTracker.js +1 -1
- package/lib/store/RelayOptimisticRecordSource.js +1 -1
- package/lib/store/RelayPublishQueue.js +1 -1
- package/lib/store/RelayReader.js +1 -3
- package/lib/store/RelayRecordSource.js +1 -1
- package/lib/store/RelayRecordState.js +1 -1
- package/lib/store/RelayReferenceMarker.js +1 -1
- package/lib/store/RelayResponseNormalizer.js +1 -1
- package/lib/store/RelayStoreReactFlightUtils.js +1 -1
- package/lib/store/RelayStoreSubscriptions.js +1 -1
- package/lib/store/RelayStoreTypes.js +1 -1
- package/lib/store/RelayStoreUtils.js +1 -1
- package/lib/store/ResolverCache.js +1 -1
- package/lib/store/ResolverFragments.js +3 -3
- package/lib/store/StoreInspector.js +1 -1
- package/lib/store/TypeID.js +1 -1
- package/lib/store/ViewerPattern.js +1 -1
- package/lib/store/cloneRelayHandleSourceField.js +1 -1
- package/lib/store/cloneRelayScalarHandleSourceField.js +1 -1
- package/lib/store/createFragmentSpecResolver.js +1 -1
- package/lib/store/createRelayContext.js +1 -1
- package/lib/store/defaultGetDataID.js +1 -1
- package/lib/store/defaultRequiredFieldLogger.js +1 -1
- package/lib/store/hasOverlappingIDs.js +1 -1
- package/lib/store/isRelayModernEnvironment.js +1 -1
- package/lib/store/normalizeRelayPayload.js +1 -1
- package/lib/store/readInlineData.js +1 -1
- package/lib/subscription/requestSubscription.js +1 -3
- package/lib/util/JSResourceTypes.flow.js +1 -1
- package/lib/util/NormalizationNode.js +1 -1
- package/lib/util/ReaderNode.js +1 -1
- package/lib/util/RelayConcreteNode.js +1 -1
- package/lib/util/RelayDefaultHandleKey.js +1 -1
- package/lib/util/RelayError.js +1 -1
- package/lib/util/RelayFeatureFlags.js +1 -2
- package/lib/util/RelayProfiler.js +1 -1
- package/lib/util/RelayReplaySubject.js +1 -1
- package/lib/util/RelayRuntimeTypes.js +1 -1
- package/lib/util/StringInterner.js +1 -1
- package/lib/util/createPayloadFor3DField.js +1 -1
- package/lib/util/deepFreeze.js +1 -1
- package/lib/util/generateID.js +1 -1
- package/lib/util/getFragmentIdentifier.js +1 -1
- package/lib/util/getOperation.js +1 -1
- package/lib/util/getPaginationMetadata.js +1 -1
- package/lib/util/getPaginationVariables.js +1 -1
- package/lib/util/getPendingOperationsForFragment.js +1 -1
- package/lib/util/getRefetchMetadata.js +1 -1
- package/lib/util/getRelayHandleKey.js +1 -1
- package/lib/util/getRequestIdentifier.js +1 -1
- package/lib/util/getValueAtPath.js +1 -1
- package/lib/util/isEmptyObject.js +1 -1
- package/lib/util/isPromise.js +1 -1
- package/lib/util/isScalarAndEqual.js +1 -1
- package/lib/util/recycleNodesInto.js +1 -1
- package/lib/util/registerEnvironmentWithDevTools.js +1 -1
- package/lib/util/reportMissingRequiredFields.js +1 -1
- package/lib/util/resolveImmediate.js +1 -1
- package/lib/util/stableCopy.js +1 -1
- package/lib/util/withDuration.js +1 -1
- package/lib/util/withProvidedVariables.js +29 -0
- package/multi-actor-environment/ActorIdentifier.js.flow +1 -1
- package/multi-actor-environment/ActorSpecificEnvironment.js.flow +1 -1
- package/multi-actor-environment/ActorUtils.js.flow +1 -1
- package/multi-actor-environment/MultiActorEnvironment.js.flow +1 -1
- package/multi-actor-environment/MultiActorEnvironmentTypes.js.flow +1 -1
- package/multi-actor-environment/index.js.flow +1 -1
- package/mutations/RelayDeclarativeMutationConfig.js.flow +1 -2
- package/mutations/RelayRecordProxy.js.flow +1 -1
- package/mutations/RelayRecordSourceMutator.js.flow +1 -1
- package/mutations/RelayRecordSourceProxy.js.flow +1 -1
- package/mutations/RelayRecordSourceSelectorProxy.js.flow +1 -1
- package/mutations/applyOptimisticMutation.js.flow +1 -1
- package/mutations/commitLocalUpdate.js.flow +1 -1
- package/mutations/commitMutation.js.flow +1 -1
- package/mutations/readUpdatableQuery_EXPERIMENTAL.js.flow +55 -48
- package/mutations/validateMutation.js.flow +1 -1
- package/network/ConvertToExecuteFunction.js.flow +1 -1
- package/network/RelayNetwork.js.flow +8 -4
- package/network/RelayNetworkTypes.js.flow +1 -1
- package/network/RelayObservable.js.flow +1 -1
- package/network/RelayQueryResponseCache.js.flow +1 -1
- package/network/wrapNetworkWithLogObserver.js.flow +2 -3
- package/package.json +2 -2
- package/query/GraphQLTag.js.flow +2 -2
- package/query/PreloadableQueryRegistry.js.flow +3 -2
- package/query/fetchQuery.js.flow +16 -12
- package/query/fetchQueryInternal.js.flow +1 -1
- package/query/fetchQuery_DEPRECATED.js.flow +1 -1
- package/relay-runtime.js +2 -2
- package/relay-runtime.min.js +3 -3
- package/store/ClientID.js.flow +1 -1
- package/store/DataChecker.js.flow +1 -1
- package/store/OperationExecutor.js.flow +1 -1
- package/store/RelayConcreteVariables.js.flow +14 -3
- package/store/RelayExperimentalGraphResponseHandler.js.flow +121 -0
- package/store/RelayExperimentalGraphResponseTransform.js.flow +470 -0
- package/store/RelayModernEnvironment.js.flow +1 -1
- package/store/RelayModernFragmentSpecResolver.js.flow +1 -1
- package/store/RelayModernOperationDescriptor.js.flow +6 -2
- package/store/RelayModernRecord.js.flow +1 -1
- package/store/RelayModernSelector.js.flow +1 -1
- package/store/RelayModernStore.js.flow +1 -2
- package/store/RelayOperationTracker.js.flow +1 -1
- package/store/RelayOptimisticRecordSource.js.flow +1 -1
- package/store/RelayPublishQueue.js.flow +1 -1
- package/store/RelayReader.js.flow +1 -8
- package/store/RelayRecordSource.js.flow +1 -1
- package/store/RelayRecordState.js.flow +1 -1
- package/store/RelayReferenceMarker.js.flow +1 -1
- package/store/RelayResponseNormalizer.js.flow +1 -1
- package/store/RelayStoreReactFlightUtils.js.flow +1 -1
- package/store/RelayStoreSubscriptions.js.flow +1 -1
- package/store/RelayStoreTypes.js.flow +1 -1
- package/store/RelayStoreUtils.js.flow +1 -1
- package/store/ResolverCache.js.flow +1 -1
- package/store/ResolverFragments.js.flow +3 -3
- package/store/StoreInspector.js.flow +1 -1
- package/store/TypeID.js.flow +1 -1
- package/store/ViewerPattern.js.flow +1 -1
- package/store/cloneRelayHandleSourceField.js.flow +1 -1
- package/store/cloneRelayScalarHandleSourceField.js.flow +1 -1
- package/store/createFragmentSpecResolver.js.flow +1 -1
- package/store/createRelayContext.js.flow +1 -1
- package/store/defaultGetDataID.js.flow +1 -1
- package/store/defaultRequiredFieldLogger.js.flow +1 -1
- package/store/hasOverlappingIDs.js.flow +1 -1
- package/store/isRelayModernEnvironment.js.flow +1 -1
- package/store/normalizeRelayPayload.js.flow +1 -1
- package/store/readInlineData.js.flow +1 -1
- package/subscription/requestSubscription.js.flow +1 -2
- package/util/JSResourceTypes.flow.js.flow +1 -1
- package/util/NormalizationNode.js.flow +1 -1
- package/util/ReaderNode.js.flow +1 -1
- package/util/RelayConcreteNode.js.flow +3 -1
- package/util/RelayDefaultHandleKey.js.flow +1 -1
- package/util/RelayError.js.flow +1 -1
- package/util/RelayFeatureFlags.js.flow +1 -3
- package/util/RelayProfiler.js.flow +1 -1
- package/util/RelayReplaySubject.js.flow +1 -1
- package/util/RelayRuntimeTypes.js.flow +1 -1
- package/util/StringInterner.js.flow +1 -1
- package/util/createPayloadFor3DField.js.flow +1 -1
- package/util/deepFreeze.js.flow +1 -1
- package/util/generateID.js.flow +1 -1
- package/util/getFragmentIdentifier.js.flow +1 -1
- package/util/getOperation.js.flow +1 -1
- package/util/getPaginationMetadata.js.flow +3 -6
- package/util/getPaginationVariables.js.flow +1 -1
- package/util/getPendingOperationsForFragment.js.flow +1 -1
- package/util/getRefetchMetadata.js.flow +3 -6
- package/util/getRelayHandleKey.js.flow +1 -1
- package/util/getRequestIdentifier.js.flow +1 -1
- package/util/getValueAtPath.js.flow +1 -1
- package/util/isEmptyObject.js.flow +1 -1
- package/util/isPromise.js.flow +1 -1
- package/util/isScalarAndEqual.js.flow +1 -1
- package/util/recycleNodesInto.js.flow +1 -1
- package/util/registerEnvironmentWithDevTools.js.flow +1 -1
- package/util/reportMissingRequiredFields.js.flow +1 -1
- package/util/resolveImmediate.js.flow +1 -1
- package/util/stableCopy.js.flow +1 -1
- package/util/withDuration.js.flow +1 -1
- package/util/withProvidedVariables.js.flow +36 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -55,50 +55,46 @@ function updateProxyFromSelections<TQuery: OperationType>(
|
|
|
55
55
|
for (const selection of selections) {
|
|
56
56
|
switch (selection.kind) {
|
|
57
57
|
case 'LinkedField':
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
get,
|
|
99
|
-
set,
|
|
100
|
-
},
|
|
101
|
-
);
|
|
58
|
+
if (selection.plural) {
|
|
59
|
+
Object.defineProperty(
|
|
60
|
+
mutableUpdatableProxy,
|
|
61
|
+
selection.alias ?? selection.name,
|
|
62
|
+
{
|
|
63
|
+
// $FlowFixMe[incompatible-call] these getters and setters have different types on purpose
|
|
64
|
+
get: createGetterForPluralLinkedField(
|
|
65
|
+
selection,
|
|
66
|
+
queryVariables,
|
|
67
|
+
recordProxy,
|
|
68
|
+
root,
|
|
69
|
+
),
|
|
70
|
+
set: createSetterForPluralLinkedField(
|
|
71
|
+
selection,
|
|
72
|
+
queryVariables,
|
|
73
|
+
recordProxy,
|
|
74
|
+
root,
|
|
75
|
+
),
|
|
76
|
+
},
|
|
77
|
+
);
|
|
78
|
+
} else {
|
|
79
|
+
Object.defineProperty(
|
|
80
|
+
mutableUpdatableProxy,
|
|
81
|
+
selection.alias ?? selection.name,
|
|
82
|
+
{
|
|
83
|
+
get: createGetterForSingularLinkedField(
|
|
84
|
+
selection,
|
|
85
|
+
queryVariables,
|
|
86
|
+
recordProxy,
|
|
87
|
+
root,
|
|
88
|
+
),
|
|
89
|
+
set: createSetterForSingularLinkedField(
|
|
90
|
+
selection,
|
|
91
|
+
queryVariables,
|
|
92
|
+
recordProxy,
|
|
93
|
+
root,
|
|
94
|
+
),
|
|
95
|
+
},
|
|
96
|
+
);
|
|
97
|
+
}
|
|
102
98
|
break;
|
|
103
99
|
case 'ScalarField':
|
|
104
100
|
const scalarFieldName = selection.alias ?? selection.name;
|
|
@@ -145,6 +141,15 @@ function updateProxyFromSelections<TQuery: OperationType>(
|
|
|
145
141
|
);
|
|
146
142
|
}
|
|
147
143
|
break;
|
|
144
|
+
case 'ClientExtension':
|
|
145
|
+
updateProxyFromSelections(
|
|
146
|
+
mutableUpdatableProxy,
|
|
147
|
+
recordProxy,
|
|
148
|
+
queryVariables,
|
|
149
|
+
selection.selections,
|
|
150
|
+
root,
|
|
151
|
+
);
|
|
152
|
+
break;
|
|
148
153
|
case 'FragmentSpread':
|
|
149
154
|
// Explicitly ignore
|
|
150
155
|
break;
|
|
@@ -162,11 +167,12 @@ function createSetterForPluralLinkedField<TQuery: OperationType>(
|
|
|
162
167
|
recordProxy: RecordProxy,
|
|
163
168
|
root: RecordSourceProxy,
|
|
164
169
|
) {
|
|
165
|
-
return function set(newValue:
|
|
170
|
+
return function set(newValue: $ReadOnlyArray<{__id: string, ...}>) {
|
|
166
171
|
const variables = getArgumentValues(selection.args ?? [], queryVariables);
|
|
167
172
|
if (newValue == null) {
|
|
168
|
-
|
|
169
|
-
|
|
173
|
+
throw new Error(
|
|
174
|
+
'Do not assign null to plural linked fields; assign an empty array instead.',
|
|
175
|
+
);
|
|
170
176
|
} else {
|
|
171
177
|
const recordProxies = newValue.map(item => {
|
|
172
178
|
if (item == null) {
|
|
@@ -197,6 +203,7 @@ function createSetterForPluralLinkedField<TQuery: OperationType>(
|
|
|
197
203
|
}
|
|
198
204
|
};
|
|
199
205
|
}
|
|
206
|
+
|
|
200
207
|
function createSetterForSingularLinkedField<TQuery: OperationType>(
|
|
201
208
|
selection: ReaderLinkedField,
|
|
202
209
|
queryVariables: TQuery['variables'],
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -24,6 +24,7 @@ import type {
|
|
|
24
24
|
} from './RelayNetworkTypes';
|
|
25
25
|
import type RelayObservable from './RelayObservable';
|
|
26
26
|
|
|
27
|
+
const withProvidedVariables = require('../util/withProvidedVariables');
|
|
27
28
|
const {convertFetch} = require('./ConvertToExecuteFunction');
|
|
28
29
|
const invariant = require('invariant');
|
|
29
30
|
|
|
@@ -45,6 +46,7 @@ function create(
|
|
|
45
46
|
uploadables?: ?UploadableMap,
|
|
46
47
|
logRequestInfo: ?LogRequestInfoFunction,
|
|
47
48
|
): RelayObservable<GraphQLResponse> {
|
|
49
|
+
const operationVariables = withProvidedVariables(variables, request);
|
|
48
50
|
if (request.operationKind === 'subscription') {
|
|
49
51
|
invariant(
|
|
50
52
|
subscribe,
|
|
@@ -56,7 +58,7 @@ function create(
|
|
|
56
58
|
!uploadables,
|
|
57
59
|
'RelayNetwork: Cannot provide uploadables while subscribing.',
|
|
58
60
|
);
|
|
59
|
-
return subscribe(request,
|
|
61
|
+
return subscribe(request, operationVariables, cacheConfig);
|
|
60
62
|
}
|
|
61
63
|
|
|
62
64
|
const pollInterval = cacheConfig.poll;
|
|
@@ -65,12 +67,14 @@ function create(
|
|
|
65
67
|
!uploadables,
|
|
66
68
|
'RelayNetwork: Cannot provide uploadables while polling.',
|
|
67
69
|
);
|
|
68
|
-
return observeFetch(request,
|
|
70
|
+
return observeFetch(request, operationVariables, {force: true}).poll(
|
|
71
|
+
pollInterval,
|
|
72
|
+
);
|
|
69
73
|
}
|
|
70
74
|
|
|
71
75
|
return observeFetch(
|
|
72
76
|
request,
|
|
73
|
-
|
|
77
|
+
operationVariables,
|
|
74
78
|
cacheConfig,
|
|
75
79
|
uploadables,
|
|
76
80
|
logRequestInfo,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -11,8 +11,6 @@
|
|
|
11
11
|
// flowlint ambiguous-object-type:error
|
|
12
12
|
|
|
13
13
|
'use strict';
|
|
14
|
-
import type {Subscription} from './RelayObservable';
|
|
15
|
-
|
|
16
14
|
import type ActorSpecificEnvironment from '../multi-actor-environment/ActorSpecificEnvironment';
|
|
17
15
|
import type RelayModernEnvironment from '../store/RelayModernEnvironment';
|
|
18
16
|
import type {RequestParameters} from '../util/RelayConcreteNode';
|
|
@@ -23,6 +21,7 @@ import type {
|
|
|
23
21
|
UploadableMap,
|
|
24
22
|
} from './RelayNetworkTypes';
|
|
25
23
|
import type RelayObservable from './RelayObservable';
|
|
24
|
+
import type {Subscription} from './RelayObservable';
|
|
26
25
|
|
|
27
26
|
const generateID = require('../util/generateID');
|
|
28
27
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "relay-runtime",
|
|
3
3
|
"description": "A core runtime for building GraphQL-driven applications.",
|
|
4
|
-
"version": "13.0.
|
|
4
|
+
"version": "13.0.1",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"graphql",
|
|
7
7
|
"relay"
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"repository": "facebook/relay",
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"@babel/runtime": "^7.0.0",
|
|
15
|
-
"fbjs": "^3.0.
|
|
15
|
+
"fbjs": "^3.0.2",
|
|
16
16
|
"invariant": "^2.2.4"
|
|
17
17
|
},
|
|
18
18
|
"directories": {
|
package/query/GraphQLTag.js.flow
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -39,7 +39,7 @@ export type GraphQLTaggedNode =
|
|
|
39
39
|
* Runtime function to correspond to the `graphql` tagged template function.
|
|
40
40
|
* All calls to this function should be transformed by the plugin.
|
|
41
41
|
*/
|
|
42
|
-
function graphql(strings: Array<string>):
|
|
42
|
+
function graphql(strings: Array<string>): any {
|
|
43
43
|
invariant(
|
|
44
44
|
false,
|
|
45
45
|
'graphql: Unexpected invocation at runtime. Either the Babel transform ' +
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
import type {ConcreteRequest
|
|
14
|
+
import type {ConcreteRequest} from '../util/RelayConcreteNode';
|
|
15
|
+
import type {Disposable} from '../util/RelayRuntimeTypes';
|
|
15
16
|
|
|
16
17
|
type Callback = (concreteRequest: ConcreteRequest) => void;
|
|
17
18
|
|
package/query/fetchQuery.js.flow
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -14,15 +14,17 @@
|
|
|
14
14
|
'use strict';
|
|
15
15
|
|
|
16
16
|
import type {
|
|
17
|
-
CacheConfig,
|
|
18
|
-
FetchQueryFetchPolicy,
|
|
19
|
-
GraphQLTaggedNode,
|
|
20
17
|
IEnvironment,
|
|
21
18
|
OperationDescriptor,
|
|
22
|
-
OperationType,
|
|
23
19
|
Snapshot,
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
} from '../store/RelayStoreTypes';
|
|
21
|
+
import type {
|
|
22
|
+
CacheConfig,
|
|
23
|
+
FetchQueryFetchPolicy,
|
|
24
|
+
OperationType,
|
|
25
|
+
Query,
|
|
26
|
+
Variables,
|
|
27
|
+
} from '../util/RelayRuntimeTypes';
|
|
26
28
|
|
|
27
29
|
const RelayObservable = require('../network/RelayObservable');
|
|
28
30
|
const {
|
|
@@ -110,15 +112,15 @@ const invariant = require('invariant');
|
|
|
110
112
|
* ```
|
|
111
113
|
* NOTE: When using .toPromise(), the request cannot be cancelled.
|
|
112
114
|
*/
|
|
113
|
-
function fetchQuery<
|
|
115
|
+
function fetchQuery<TVariables: Variables, TData, TRawResponse>(
|
|
114
116
|
environment: IEnvironment,
|
|
115
|
-
query:
|
|
116
|
-
variables:
|
|
117
|
+
query: Query<TVariables, TData, TRawResponse>,
|
|
118
|
+
variables: TVariables,
|
|
117
119
|
options?: $ReadOnly<{|
|
|
118
120
|
fetchPolicy?: FetchQueryFetchPolicy,
|
|
119
121
|
networkCacheConfig?: CacheConfig,
|
|
120
122
|
|}>,
|
|
121
|
-
): RelayObservable<
|
|
123
|
+
): RelayObservable<TData> {
|
|
122
124
|
const queryNode = getRequest(query);
|
|
123
125
|
invariant(
|
|
124
126
|
queryNode.params.operationKind === 'query',
|
|
@@ -135,10 +137,12 @@ function fetchQuery<TQuery: OperationType>(
|
|
|
135
137
|
);
|
|
136
138
|
const fetchPolicy = options?.fetchPolicy ?? 'network-only';
|
|
137
139
|
|
|
138
|
-
function readData(snapshot: Snapshot) {
|
|
140
|
+
function readData(snapshot: Snapshot): TData {
|
|
139
141
|
if (snapshot.missingRequiredFields != null) {
|
|
140
142
|
reportMissingRequiredFields(environment, snapshot.missingRequiredFields);
|
|
141
143
|
}
|
|
144
|
+
/* $FlowFixMe[incompatible-return] we assume readData returns the right
|
|
145
|
+
* data just having written it from network or checked availability. */
|
|
142
146
|
return snapshot.data;
|
|
143
147
|
}
|
|
144
148
|
|