relay-runtime 13.0.0-rc.1 → 13.0.2
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 +64 -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 +27 -18
- 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 +13 -4
- package/lib/store/RelayExperimentalGraphResponseHandler.js +3 -3
- package/lib/store/RelayExperimentalGraphResponseTransform.js +54 -22
- 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 +5 -3
- package/lib/store/RelayReader.js +56 -16
- 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 +2 -1
- package/lib/store/ResolverCache.js +11 -3
- 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 +49 -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 +9 -20
- package/mutations/readUpdatableQuery_EXPERIMENTAL.js.flow +57 -50
- package/mutations/validateMutation.js.flow +1 -1
- package/network/ConvertToExecuteFunction.js.flow +1 -1
- package/network/RelayNetwork.js.flow +11 -4
- package/network/RelayNetworkTypes.js.flow +2 -2
- 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 +13 -3
- package/store/RelayExperimentalGraphResponseHandler.js.flow +3 -6
- package/store/RelayExperimentalGraphResponseTransform.js.flow +51 -22
- 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 +9 -2
- package/store/RelayReader.js.flow +79 -39
- 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 +4 -3
- package/store/RelayStoreUtils.js.flow +2 -1
- package/store/ResolverCache.js.flow +19 -6
- 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 +8 -14
- 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 +5 -3
- 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 +64 -0
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
3
|
+
Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
## Relay Runtime
|
|
2
|
+
|
|
3
|
+
A set of Relay APIs responsible for data fetching, reading and normalization of
|
|
4
|
+
the GraphQL data.
|
|
5
|
+
|
|
6
|
+
Example:
|
|
7
|
+
|
|
8
|
+
```js
|
|
9
|
+
// @flow strict-local
|
|
10
|
+
|
|
11
|
+
import type {FetchFunction} from 'relay-runtime';
|
|
12
|
+
|
|
13
|
+
const {
|
|
14
|
+
Environment,
|
|
15
|
+
Network,
|
|
16
|
+
Observable,
|
|
17
|
+
RecordSource,
|
|
18
|
+
Store,
|
|
19
|
+
fetchQuery,
|
|
20
|
+
graphql,
|
|
21
|
+
} = require('relay-runtime');
|
|
22
|
+
|
|
23
|
+
const fetchFn: FetchFunction = function (request, variables) {
|
|
24
|
+
return new Observable.create(source => {
|
|
25
|
+
fetch('/my-graphql-api', {
|
|
26
|
+
method: 'POST',
|
|
27
|
+
body: JSON.stringify({
|
|
28
|
+
text: request.text,
|
|
29
|
+
variables,
|
|
30
|
+
}),
|
|
31
|
+
})
|
|
32
|
+
.then(response => response.json())
|
|
33
|
+
.then(data => source.next(data));
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const network = Network.create(fetchFn);
|
|
38
|
+
const store = new Store(new RecordSource());
|
|
39
|
+
const environment = new Environment({
|
|
40
|
+
network,
|
|
41
|
+
store,
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
fetchQuery(
|
|
45
|
+
environment,
|
|
46
|
+
graphql`
|
|
47
|
+
query AppQuery($id: ID!) {
|
|
48
|
+
user(id: $id) {
|
|
49
|
+
name
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
`,
|
|
53
|
+
{id: 'my-node-id'},
|
|
54
|
+
).subscribe({
|
|
55
|
+
error: error => {
|
|
56
|
+
console.error(error);
|
|
57
|
+
},
|
|
58
|
+
next: data => {
|
|
59
|
+
console.log(data);
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
For complete API reference, visit https://relay.dev/.
|
package/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Relay v13.0.
|
|
2
|
+
* Relay v13.0.2
|
|
3
3
|
*
|
|
4
|
-
* Copyright (c)
|
|
4
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
5
5
|
*
|
|
6
6
|
* This source code is licensed under the MIT license found in the
|
|
7
7
|
* LICENSE file in the root directory of this source tree.
|
package/index.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.
|
|
@@ -46,6 +46,7 @@ const RelayModernStore = require('./store/RelayModernStore');
|
|
|
46
46
|
const RelayOperationTracker = require('./store/RelayOperationTracker');
|
|
47
47
|
const RelayRecordSource = require('./store/RelayRecordSource');
|
|
48
48
|
const RelayStoreUtils = require('./store/RelayStoreUtils');
|
|
49
|
+
const ResolverFragments = require('./store/ResolverFragments');
|
|
49
50
|
const ViewerPattern = require('./store/ViewerPattern');
|
|
50
51
|
const requestSubscription = require('./subscription/requestSubscription');
|
|
51
52
|
const createPayloadFor3DField = require('./util/createPayloadFor3DField');
|
|
@@ -69,6 +70,7 @@ const RelayProfiler = require('./util/RelayProfiler');
|
|
|
69
70
|
const RelayReplaySubject = require('./util/RelayReplaySubject');
|
|
70
71
|
const reportMissingRequiredFields = require('./util/reportMissingRequiredFields');
|
|
71
72
|
const stableCopy = require('./util/stableCopy');
|
|
73
|
+
const withProvidedVariables = require('./util/withProvidedVariables');
|
|
72
74
|
|
|
73
75
|
export type {ConnectionMetadata} from './handlers/connection/ConnectionHandler';
|
|
74
76
|
export type {
|
|
@@ -352,6 +354,7 @@ module.exports = {
|
|
|
352
354
|
getPendingOperationsForFragment: getPendingOperationsForFragment,
|
|
353
355
|
getValueAtPath: getValueAtPath,
|
|
354
356
|
__internal: {
|
|
357
|
+
ResolverFragments,
|
|
355
358
|
OperationTracker: RelayOperationTracker,
|
|
356
359
|
createRelayContext: createRelayContext,
|
|
357
360
|
getOperationVariables: RelayConcreteVariables.getOperationVariables,
|
|
@@ -360,5 +363,6 @@ module.exports = {
|
|
|
360
363
|
getPromiseForActiveRequest: fetchQueryInternal.getPromiseForActiveRequest,
|
|
361
364
|
getObservableForActiveRequest:
|
|
362
365
|
fetchQueryInternal.getObservableForActiveRequest,
|
|
366
|
+
withProvidedVariables: withProvidedVariables,
|
|
363
367
|
},
|
|
364
368
|
};
|
package/lib/index.js
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.
|
|
@@ -73,6 +73,8 @@ var RelayRecordSource = require('./store/RelayRecordSource');
|
|
|
73
73
|
|
|
74
74
|
var RelayStoreUtils = require('./store/RelayStoreUtils');
|
|
75
75
|
|
|
76
|
+
var ResolverFragments = require('./store/ResolverFragments');
|
|
77
|
+
|
|
76
78
|
var ViewerPattern = require('./store/ViewerPattern');
|
|
77
79
|
|
|
78
80
|
var requestSubscription = require('./subscription/requestSubscription');
|
|
@@ -119,6 +121,8 @@ var reportMissingRequiredFields = require('./util/reportMissingRequiredFields');
|
|
|
119
121
|
|
|
120
122
|
var stableCopy = require('./util/stableCopy');
|
|
121
123
|
|
|
124
|
+
var withProvidedVariables = require('./util/withProvidedVariables');
|
|
125
|
+
|
|
122
126
|
// As early as possible, check for the existence of the JavaScript globals which
|
|
123
127
|
// Relay Runtime relies upon, and produce a clear message if they do not exist.
|
|
124
128
|
if (process.env.NODE_ENV !== "production") {
|
|
@@ -230,12 +234,14 @@ module.exports = {
|
|
|
230
234
|
getPendingOperationsForFragment: getPendingOperationsForFragment,
|
|
231
235
|
getValueAtPath: getValueAtPath,
|
|
232
236
|
__internal: {
|
|
237
|
+
ResolverFragments: ResolverFragments,
|
|
233
238
|
OperationTracker: RelayOperationTracker,
|
|
234
239
|
createRelayContext: createRelayContext,
|
|
235
240
|
getOperationVariables: RelayConcreteVariables.getOperationVariables,
|
|
236
241
|
fetchQuery: fetchQueryInternal.fetchQuery,
|
|
237
242
|
fetchQueryDeduped: fetchQueryInternal.fetchQueryDeduped,
|
|
238
243
|
getPromiseForActiveRequest: fetchQueryInternal.getPromiseForActiveRequest,
|
|
239
|
-
getObservableForActiveRequest: fetchQueryInternal.getObservableForActiveRequest
|
|
244
|
+
getObservableForActiveRequest: fetchQueryInternal.getObservableForActiveRequest,
|
|
245
|
+
withProvidedVariables: withProvidedVariables
|
|
240
246
|
}
|
|
241
247
|
};
|
|
@@ -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.
|
|
@@ -21,7 +21,7 @@ var _require = require('../query/GraphQLTag'),
|
|
|
21
21
|
var _require2 = require('../store/RelayStoreUtils'),
|
|
22
22
|
getArgumentValues = _require2.getArgumentValues;
|
|
23
23
|
|
|
24
|
-
var nonUpdatableKeys = ['id', '__id', '__typename'];
|
|
24
|
+
var nonUpdatableKeys = ['id', '__id', '__typename', 'js'];
|
|
25
25
|
|
|
26
26
|
function readUpdatableQuery_EXPERIMENTAL(query, variables, proxy) {
|
|
27
27
|
// TODO assert that the concrete request is an updatable query
|
|
@@ -37,7 +37,7 @@ function readUpdatableQuery_EXPERIMENTAL(query, variables, proxy) {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
function updateProxyFromSelections(mutableUpdatableProxy, recordProxy, queryVariables, selections, root) {
|
|
40
|
-
var _selection$
|
|
40
|
+
var _selection$alias3;
|
|
41
41
|
|
|
42
42
|
var _iterator = (0, _createForOfIteratorHelper2["default"])(selections),
|
|
43
43
|
_step;
|
|
@@ -48,21 +48,23 @@ function updateProxyFromSelections(mutableUpdatableProxy, recordProxy, queryVari
|
|
|
48
48
|
|
|
49
49
|
switch (selection.kind) {
|
|
50
50
|
case 'LinkedField':
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
51
|
+
if (selection.plural) {
|
|
52
|
+
Object.defineProperty(mutableUpdatableProxy, (_selection$alias = selection.alias) !== null && _selection$alias !== void 0 ? _selection$alias : selection.name, {
|
|
53
|
+
// $FlowFixMe[incompatible-call] these getters and setters have different types on purpose
|
|
54
|
+
get: createGetterForPluralLinkedField(selection, queryVariables, recordProxy, root),
|
|
55
|
+
set: createSetterForPluralLinkedField(selection, queryVariables, recordProxy, root)
|
|
56
|
+
});
|
|
57
|
+
} else {
|
|
58
|
+
Object.defineProperty(mutableUpdatableProxy, (_selection$alias2 = selection.alias) !== null && _selection$alias2 !== void 0 ? _selection$alias2 : selection.name, {
|
|
59
|
+
get: createGetterForSingularLinkedField(selection, queryVariables, recordProxy, root),
|
|
60
|
+
set: createSetterForSingularLinkedField(selection, queryVariables, recordProxy, root)
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
|
|
62
64
|
break;
|
|
63
65
|
|
|
64
66
|
case 'ScalarField':
|
|
65
|
-
var scalarFieldName = (_selection$
|
|
67
|
+
var scalarFieldName = (_selection$alias3 = selection.alias) !== null && _selection$alias3 !== void 0 ? _selection$alias3 : selection.name;
|
|
66
68
|
Object.defineProperty(mutableUpdatableProxy, scalarFieldName, {
|
|
67
69
|
get: function get() {
|
|
68
70
|
var _selection$args;
|
|
@@ -92,6 +94,10 @@ function updateProxyFromSelections(mutableUpdatableProxy, recordProxy, queryVari
|
|
|
92
94
|
|
|
93
95
|
break;
|
|
94
96
|
|
|
97
|
+
case 'ClientExtension':
|
|
98
|
+
updateProxyFromSelections(mutableUpdatableProxy, recordProxy, queryVariables, selection.selections, root);
|
|
99
|
+
break;
|
|
100
|
+
|
|
95
101
|
case 'FragmentSpread':
|
|
96
102
|
// Explicitly ignore
|
|
97
103
|
break;
|
|
@@ -102,6 +108,10 @@ function updateProxyFromSelections(mutableUpdatableProxy, recordProxy, queryVari
|
|
|
102
108
|
};
|
|
103
109
|
|
|
104
110
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
111
|
+
var _selection$alias;
|
|
112
|
+
|
|
113
|
+
var _selection$alias2;
|
|
114
|
+
|
|
105
115
|
_loop();
|
|
106
116
|
}
|
|
107
117
|
} catch (err) {
|
|
@@ -118,8 +128,7 @@ function createSetterForPluralLinkedField(selection, queryVariables, recordProxy
|
|
|
118
128
|
var variables = getArgumentValues((_selection$args3 = selection.args) !== null && _selection$args3 !== void 0 ? _selection$args3 : [], queryVariables);
|
|
119
129
|
|
|
120
130
|
if (newValue == null) {
|
|
121
|
-
|
|
122
|
-
recordProxy.setValue(null, selection.name, variables);
|
|
131
|
+
throw new Error('Do not assign null to plural linked fields; assign an empty array instead.');
|
|
123
132
|
} else {
|
|
124
133
|
var recordProxies = newValue.map(function (item) {
|
|
125
134
|
if (item == null) {
|
|
@@ -154,7 +163,7 @@ function createSetterForSingularLinkedField(selection, queryVariables, recordPro
|
|
|
154
163
|
|
|
155
164
|
if (newValue == null) {
|
|
156
165
|
// $FlowFixMe[unclear-type] No good way to type these variables
|
|
157
|
-
recordProxy.setValue(
|
|
166
|
+
recordProxy.setValue(newValue, selection.name, variables);
|
|
158
167
|
} else {
|
|
159
168
|
var __id = newValue.__id;
|
|
160
169
|
|
|
@@ -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.
|
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
// flowlint ambiguous-object-type:error
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
|
+
var withProvidedVariables = require('../util/withProvidedVariables');
|
|
14
|
+
|
|
13
15
|
var _require = require('./ConvertToExecuteFunction'),
|
|
14
16
|
convertFetch = _require.convertFetch;
|
|
15
17
|
|
|
@@ -25,22 +27,24 @@ function create(fetchFn, subscribe) {
|
|
|
25
27
|
var observeFetch = convertFetch(fetchFn);
|
|
26
28
|
|
|
27
29
|
function execute(request, variables, cacheConfig, uploadables, logRequestInfo) {
|
|
30
|
+
var operationVariables = withProvidedVariables(variables, request.providedVariables);
|
|
31
|
+
|
|
28
32
|
if (request.operationKind === 'subscription') {
|
|
29
33
|
!subscribe ? process.env.NODE_ENV !== "production" ? invariant(false, 'RelayNetwork: This network layer does not support Subscriptions. ' + 'To use Subscriptions, provide a custom network layer.') : invariant(false) : void 0;
|
|
30
34
|
!!uploadables ? process.env.NODE_ENV !== "production" ? invariant(false, 'RelayNetwork: Cannot provide uploadables while subscribing.') : invariant(false) : void 0;
|
|
31
|
-
return subscribe(request,
|
|
35
|
+
return subscribe(request, operationVariables, cacheConfig);
|
|
32
36
|
}
|
|
33
37
|
|
|
34
38
|
var pollInterval = cacheConfig.poll;
|
|
35
39
|
|
|
36
40
|
if (pollInterval != null) {
|
|
37
41
|
!!uploadables ? process.env.NODE_ENV !== "production" ? invariant(false, 'RelayNetwork: Cannot provide uploadables while polling.') : invariant(false) : void 0;
|
|
38
|
-
return observeFetch(request,
|
|
42
|
+
return observeFetch(request, operationVariables, {
|
|
39
43
|
force: true
|
|
40
44
|
}).poll(pollInterval);
|
|
41
45
|
}
|
|
42
46
|
|
|
43
|
-
return observeFetch(request,
|
|
47
|
+
return observeFetch(request, operationVariables, cacheConfig, uploadables, logRequestInfo);
|
|
44
48
|
}
|
|
45
49
|
|
|
46
50
|
return {
|
package/lib/query/GraphQLTag.js
CHANGED
package/lib/query/fetchQuery.js
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.
|
|
@@ -122,6 +122,9 @@ function fetchQuery(environment, query, variables, options) {
|
|
|
122
122
|
if (snapshot.missingRequiredFields != null) {
|
|
123
123
|
reportMissingRequiredFields(environment, snapshot.missingRequiredFields);
|
|
124
124
|
}
|
|
125
|
+
/* $FlowFixMe[incompatible-return] we assume readData returns the right
|
|
126
|
+
* data just having written it from network or checked availability. */
|
|
127
|
+
|
|
125
128
|
|
|
126
129
|
return snapshot.data;
|
|
127
130
|
}
|
package/lib/store/ClientID.js
CHANGED
package/lib/store/DataChecker.js
CHANGED