relay-runtime 12.0.0 → 13.0.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/LICENSE +1 -1
- package/README.md +67 -0
- package/handlers/RelayDefaultHandlerProvider.js.flow +3 -3
- package/handlers/connection/ConnectionHandler.js.flow +9 -18
- package/handlers/connection/ConnectionInterface.js.flow +1 -1
- package/handlers/connection/MutationHandlers.js.flow +8 -12
- package/index.js +2 -2
- package/index.js.flow +43 -34
- package/lib/handlers/RelayDefaultHandlerProvider.js +1 -1
- package/lib/handlers/connection/ConnectionHandler.js +13 -19
- package/lib/handlers/connection/ConnectionInterface.js +1 -1
- package/lib/handlers/connection/MutationHandlers.js +4 -7
- package/lib/index.js +49 -46
- package/lib/multi-actor-environment/ActorIdentifier.js +1 -1
- package/lib/multi-actor-environment/ActorSpecificEnvironment.js +9 -5
- package/lib/multi-actor-environment/ActorUtils.js +1 -1
- package/lib/multi-actor-environment/MultiActorEnvironment.js +36 -23
- package/lib/multi-actor-environment/MultiActorEnvironmentTypes.js +1 -1
- package/lib/multi-actor-environment/index.js +3 -3
- package/lib/mutations/RelayDeclarativeMutationConfig.js +5 -2
- package/lib/mutations/RelayRecordProxy.js +4 -3
- package/lib/mutations/RelayRecordSourceMutator.js +4 -3
- package/lib/mutations/RelayRecordSourceProxy.js +13 -5
- package/lib/mutations/RelayRecordSourceSelectorProxy.js +13 -5
- package/lib/mutations/applyOptimisticMutation.js +7 -7
- package/lib/mutations/commitLocalUpdate.js +1 -1
- package/lib/mutations/commitMutation.js +16 -15
- package/lib/mutations/readUpdatableQuery_EXPERIMENTAL.js +242 -0
- package/lib/mutations/validateMutation.js +7 -7
- package/lib/network/ConvertToExecuteFunction.js +3 -2
- package/lib/network/RelayNetwork.js +4 -3
- package/lib/network/RelayNetworkTypes.js +1 -1
- package/lib/network/RelayObservable.js +2 -4
- package/lib/network/RelayQueryResponseCache.js +3 -3
- package/lib/network/wrapNetworkWithLogObserver.js +3 -2
- package/lib/query/GraphQLTag.js +3 -2
- package/lib/query/PreloadableQueryRegistry.js +1 -1
- package/lib/query/fetchQuery.js +7 -6
- package/lib/query/fetchQueryInternal.js +1 -1
- package/lib/query/fetchQuery_DEPRECATED.js +3 -2
- package/lib/store/ClientID.js +8 -2
- package/lib/store/DataChecker.js +17 -18
- package/lib/store/OperationExecutor.js +14 -14
- package/lib/store/RelayConcreteVariables.js +7 -10
- package/lib/store/RelayExperimentalGraphResponseHandler.js +153 -0
- package/lib/store/RelayExperimentalGraphResponseTransform.js +391 -0
- package/lib/store/RelayModernEnvironment.js +67 -43
- package/lib/store/RelayModernFragmentSpecResolver.js +9 -9
- package/lib/store/RelayModernOperationDescriptor.js +3 -2
- package/lib/store/RelayModernRecord.js +13 -12
- package/lib/store/RelayModernSelector.js +15 -9
- package/lib/store/RelayModernStore.js +15 -16
- package/lib/store/RelayOperationTracker.js +1 -1
- package/lib/store/RelayOptimisticRecordSource.js +1 -1
- package/lib/store/RelayPublishQueue.js +12 -6
- package/lib/store/RelayReader.js +131 -40
- package/lib/store/RelayRecordSource.js +1 -1
- package/lib/store/RelayRecordState.js +1 -1
- package/lib/store/RelayReferenceMarker.js +11 -12
- package/lib/store/RelayResponseNormalizer.js +26 -23
- package/lib/store/RelayStoreReactFlightUtils.js +4 -4
- package/lib/store/RelayStoreSubscriptions.js +7 -5
- package/lib/store/RelayStoreTypes.js +1 -1
- package/lib/store/RelayStoreUtils.js +6 -6
- package/lib/store/ResolverCache.js +7 -7
- package/lib/store/ResolverFragments.js +12 -8
- 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 +6 -5
- package/lib/store/cloneRelayScalarHandleSourceField.js +6 -5
- package/lib/store/createFragmentSpecResolver.js +1 -1
- package/lib/store/createRelayContext.js +4 -2
- 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 +7 -3
- package/lib/subscription/requestSubscription.js +4 -6
- 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 +2 -1
- package/lib/util/RelayDefaultHandleKey.js +1 -1
- package/lib/util/RelayError.js +1 -1
- package/lib/util/RelayFeatureFlags.js +8 -3
- package/lib/util/RelayProfiler.js +1 -1
- package/lib/util/RelayReplaySubject.js +1 -1
- package/lib/util/RelayRuntimeTypes.js +1 -7
- package/lib/util/StringInterner.js +71 -0
- package/lib/util/createPayloadFor3DField.js +1 -1
- package/lib/util/deepFreeze.js +1 -1
- package/lib/util/generateID.js +1 -1
- package/lib/util/getAllRootVariables.js +29 -0
- package/lib/util/getFragmentIdentifier.js +16 -8
- package/lib/util/getOperation.js +3 -2
- package/lib/util/getPaginationMetadata.js +1 -1
- package/lib/util/getPaginationVariables.js +3 -4
- package/lib/util/getPendingOperationsForFragment.js +1 -1
- package/lib/util/getRefetchMetadata.js +1 -1
- package/lib/util/getRelayHandleKey.js +3 -3
- package/lib/util/getRequestIdentifier.js +3 -3
- 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/multi-actor-environment/ActorIdentifier.js.flow +1 -1
- package/multi-actor-environment/ActorSpecificEnvironment.js.flow +28 -20
- package/multi-actor-environment/ActorUtils.js.flow +3 -3
- package/multi-actor-environment/MultiActorEnvironment.js.flow +46 -25
- package/multi-actor-environment/MultiActorEnvironmentTypes.js.flow +28 -12
- package/multi-actor-environment/index.js.flow +2 -3
- package/mutations/RelayDeclarativeMutationConfig.js.flow +33 -28
- package/mutations/RelayRecordProxy.js.flow +5 -6
- package/mutations/RelayRecordSourceMutator.js.flow +5 -7
- package/mutations/RelayRecordSourceProxy.js.flow +20 -11
- package/mutations/RelayRecordSourceSelectorProxy.js.flow +16 -6
- package/mutations/applyOptimisticMutation.js.flow +14 -15
- package/mutations/commitLocalUpdate.js.flow +2 -2
- package/mutations/commitMutation.js.flow +36 -49
- package/mutations/readUpdatableQuery_EXPERIMENTAL.js.flow +318 -0
- package/mutations/validateMutation.js.flow +20 -18
- package/network/ConvertToExecuteFunction.js.flow +3 -3
- package/network/RelayNetwork.js.flow +5 -6
- package/network/RelayNetworkTypes.js.flow +1 -1
- package/network/RelayObservable.js.flow +2 -4
- package/network/RelayQueryResponseCache.js.flow +4 -4
- package/network/wrapNetworkWithLogObserver.js.flow +9 -9
- package/package.json +2 -2
- package/query/GraphQLTag.js.flow +11 -11
- package/query/PreloadableQueryRegistry.js.flow +5 -3
- package/query/fetchQuery.js.flow +19 -19
- package/query/fetchQueryInternal.js.flow +7 -10
- package/query/fetchQuery_DEPRECATED.js.flow +7 -7
- package/relay-runtime.js +2 -2
- package/relay-runtime.min.js +3 -3
- package/store/ClientID.js.flow +10 -3
- package/store/DataChecker.js.flow +21 -30
- package/store/OperationExecutor.js.flow +55 -63
- package/store/RelayConcreteVariables.js.flow +5 -11
- package/store/RelayExperimentalGraphResponseHandler.js.flow +121 -0
- package/store/RelayExperimentalGraphResponseTransform.js.flow +470 -0
- package/store/RelayModernEnvironment.js.flow +57 -28
- package/store/RelayModernFragmentSpecResolver.js.flow +18 -20
- package/store/RelayModernOperationDescriptor.js.flow +11 -12
- package/store/RelayModernRecord.js.flow +20 -13
- package/store/RelayModernSelector.js.flow +25 -15
- package/store/RelayModernStore.js.flow +22 -26
- package/store/RelayOperationTracker.js.flow +12 -18
- package/store/RelayOptimisticRecordSource.js.flow +3 -3
- package/store/RelayPublishQueue.js.flow +43 -24
- package/store/RelayReader.js.flow +181 -68
- package/store/RelayRecordSource.js.flow +3 -3
- package/store/RelayRecordState.js.flow +1 -1
- package/store/RelayReferenceMarker.js.flow +13 -16
- package/store/RelayResponseNormalizer.js.flow +44 -42
- package/store/RelayStoreReactFlightUtils.js.flow +4 -5
- package/store/RelayStoreSubscriptions.js.flow +10 -9
- package/store/RelayStoreTypes.js.flow +73 -30
- package/store/RelayStoreUtils.js.flow +9 -10
- package/store/ResolverCache.js.flow +17 -15
- package/store/ResolverFragments.js.flow +18 -25
- package/store/StoreInspector.js.flow +3 -3
- package/store/TypeID.js.flow +2 -2
- package/store/ViewerPattern.js.flow +3 -3
- package/store/cloneRelayHandleSourceField.js.flow +6 -7
- package/store/cloneRelayScalarHandleSourceField.js.flow +6 -7
- package/store/createFragmentSpecResolver.js.flow +4 -5
- package/store/createRelayContext.js.flow +3 -3
- 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 +7 -8
- package/store/readInlineData.js.flow +8 -9
- package/subscription/requestSubscription.js.flow +16 -25
- package/util/JSResourceTypes.flow.js.flow +1 -1
- package/util/NormalizationNode.js.flow +1 -1
- package/util/ReaderNode.js.flow +10 -1
- package/util/RelayConcreteNode.js.flow +4 -1
- package/util/RelayDefaultHandleKey.js.flow +1 -1
- package/util/RelayError.js.flow +1 -1
- package/util/RelayFeatureFlags.js.flow +15 -5
- package/util/RelayProfiler.js.flow +1 -1
- package/util/RelayReplaySubject.js.flow +3 -4
- package/util/RelayRuntimeTypes.js.flow +70 -3
- package/util/StringInterner.js.flow +69 -0
- package/util/createPayloadFor3DField.js.flow +4 -4
- package/util/deepFreeze.js.flow +1 -1
- package/util/generateID.js.flow +1 -1
- package/util/getAllRootVariables.js.flow +36 -0
- package/util/getFragmentIdentifier.js.flow +28 -16
- package/util/getOperation.js.flow +3 -3
- package/util/getPaginationMetadata.js.flow +6 -11
- package/util/getPaginationVariables.js.flow +6 -10
- package/util/getPendingOperationsForFragment.js.flow +3 -3
- package/util/getRefetchMetadata.js.flow +8 -12
- package/util/getRelayHandleKey.js.flow +2 -3
- package/util/getRequestIdentifier.js.flow +4 -4
- 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 +2 -2
- package/util/stableCopy.js.flow +1 -1
- package/util/withDuration.js.flow +1 -1
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,67 @@
|
|
|
1
|
+
Relay Runtime
|
|
2
|
+
---
|
|
3
|
+
|
|
4
|
+
A set of Relay APIs responsible for data fetching, reading and normalization of
|
|
5
|
+
the GraphQL data.
|
|
6
|
+
|
|
7
|
+
Example:
|
|
8
|
+
|
|
9
|
+
```js
|
|
10
|
+
|
|
11
|
+
// @flow strict-local
|
|
12
|
+
|
|
13
|
+
import type {FetchFunction} from 'relay-runtime';
|
|
14
|
+
|
|
15
|
+
const {
|
|
16
|
+
Environment,
|
|
17
|
+
Network,
|
|
18
|
+
Observable,
|
|
19
|
+
RecordSource,
|
|
20
|
+
Store,
|
|
21
|
+
fetchQuery,
|
|
22
|
+
graphql,
|
|
23
|
+
} = require('relay-runtime');
|
|
24
|
+
|
|
25
|
+
const fetchFn: FetchFunction = function (request, variables) {
|
|
26
|
+
return new Observable.create(source => {
|
|
27
|
+
fetch('/my-graphql-api', {
|
|
28
|
+
method: 'POST',
|
|
29
|
+
body: JSON.stringify({
|
|
30
|
+
text: request.text,
|
|
31
|
+
variables,
|
|
32
|
+
}),
|
|
33
|
+
})
|
|
34
|
+
.then(response => response.json())
|
|
35
|
+
.then(data => source.next(data));
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const network = Network.create(fetchFn);
|
|
40
|
+
const store = new Store(new RecordSource());
|
|
41
|
+
const environment = new Environment({
|
|
42
|
+
network,
|
|
43
|
+
store,
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
fetchQuery(
|
|
47
|
+
environment,
|
|
48
|
+
graphql`
|
|
49
|
+
query AppQuery($id: ID!) {
|
|
50
|
+
user(id: $id) {
|
|
51
|
+
name
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
`,
|
|
55
|
+
{id: 'my-node-id'},
|
|
56
|
+
).subscribe({
|
|
57
|
+
error: error => {
|
|
58
|
+
console.error(error);
|
|
59
|
+
},
|
|
60
|
+
next: data => {
|
|
61
|
+
console.log(data);
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
For complete API reference, visit https://relay.dev/.
|
|
@@ -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.
|
|
@@ -12,12 +12,12 @@
|
|
|
12
12
|
|
|
13
13
|
'use strict';
|
|
14
14
|
|
|
15
|
+
import type {Handler} from '../store/RelayStoreTypes';
|
|
16
|
+
|
|
15
17
|
const ConnectionHandler = require('./connection/ConnectionHandler');
|
|
16
18
|
const MutationHandlers = require('./connection/MutationHandlers');
|
|
17
|
-
|
|
18
19
|
const invariant = require('invariant');
|
|
19
20
|
|
|
20
|
-
import type {Handler} from '../store/RelayStoreTypes';
|
|
21
21
|
export type HandlerProvider = (name: string) => ?Handler;
|
|
22
22
|
|
|
23
23
|
function RelayDefaultHandlerProvider(handle: string): Handler {
|
|
@@ -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.
|
|
@@ -12,23 +12,21 @@
|
|
|
12
12
|
|
|
13
13
|
'use strict';
|
|
14
14
|
|
|
15
|
-
const ConnectionInterface = require('./ConnectionInterface');
|
|
16
|
-
|
|
17
|
-
const getRelayHandleKey = require('../../util/getRelayHandleKey');
|
|
18
|
-
const invariant = require('invariant');
|
|
19
|
-
const warning = require('warning');
|
|
20
|
-
|
|
21
|
-
const {generateClientID} = require('../../store/ClientID');
|
|
22
|
-
const {getStableStorageKey} = require('../../store/RelayStoreUtils');
|
|
23
|
-
|
|
24
15
|
import type {
|
|
25
16
|
HandleFieldPayload,
|
|
26
|
-
RecordProxy,
|
|
27
17
|
ReadOnlyRecordProxy,
|
|
18
|
+
RecordProxy,
|
|
28
19
|
RecordSourceProxy,
|
|
29
20
|
} from '../../store/RelayStoreTypes';
|
|
30
21
|
import type {DataID, Variables} from '../../util/RelayRuntimeTypes';
|
|
31
22
|
|
|
23
|
+
const {generateClientID} = require('../../store/ClientID');
|
|
24
|
+
const {getStableStorageKey} = require('../../store/RelayStoreUtils');
|
|
25
|
+
const getRelayHandleKey = require('../../util/getRelayHandleKey');
|
|
26
|
+
const ConnectionInterface = require('./ConnectionInterface');
|
|
27
|
+
const invariant = require('invariant');
|
|
28
|
+
const warning = require('warning');
|
|
29
|
+
|
|
32
30
|
export type ConnectionMetadata = {
|
|
33
31
|
path: ?Array<string>,
|
|
34
32
|
direction: ?('forward' | 'backward' | 'bidirectional'),
|
|
@@ -146,12 +144,10 @@ function update(store: RecordSourceProxy, payload: HandleFieldPayload): void {
|
|
|
146
144
|
let nextEdges = [];
|
|
147
145
|
const args = payload.args;
|
|
148
146
|
if (prevEdges && serverEdges) {
|
|
149
|
-
// $FlowFixMe[prop-missing]
|
|
150
147
|
if (args.after != null) {
|
|
151
148
|
// Forward pagination from the end of the connection: append edges
|
|
152
149
|
if (
|
|
153
150
|
clientPageInfo &&
|
|
154
|
-
// $FlowFixMe[prop-missing]
|
|
155
151
|
args.after === clientPageInfo.getValue(END_CURSOR)
|
|
156
152
|
) {
|
|
157
153
|
const nodeIDs = new Set();
|
|
@@ -167,12 +163,10 @@ function update(store: RecordSourceProxy, payload: HandleFieldPayload): void {
|
|
|
167
163
|
);
|
|
168
164
|
return;
|
|
169
165
|
}
|
|
170
|
-
// $FlowFixMe[prop-missing]
|
|
171
166
|
} else if (args.before != null) {
|
|
172
167
|
// Backward pagination from the start of the connection: prepend edges
|
|
173
168
|
if (
|
|
174
169
|
clientPageInfo &&
|
|
175
|
-
// $FlowFixMe[prop-missing]
|
|
176
170
|
args.before === clientPageInfo.getValue(START_CURSOR)
|
|
177
171
|
) {
|
|
178
172
|
const nodeIDs = new Set();
|
|
@@ -204,12 +198,10 @@ function update(store: RecordSourceProxy, payload: HandleFieldPayload): void {
|
|
|
204
198
|
}
|
|
205
199
|
// Page info should be updated even if no new edge were returned.
|
|
206
200
|
if (clientPageInfo && serverPageInfo) {
|
|
207
|
-
// $FlowFixMe[prop-missing]
|
|
208
201
|
if (args.after == null && args.before == null) {
|
|
209
202
|
// The connection was refetched from the beginning/end: replace
|
|
210
203
|
// page_info
|
|
211
204
|
clientPageInfo.copyFieldsFrom(serverPageInfo);
|
|
212
|
-
// $FlowFixMe[prop-missing]
|
|
213
205
|
} else if (args.before != null || (args.after == null && args.last)) {
|
|
214
206
|
clientPageInfo.setValue(
|
|
215
207
|
!!serverPageInfo.getValue(HAS_PREV_PAGE),
|
|
@@ -219,7 +211,6 @@ function update(store: RecordSourceProxy, payload: HandleFieldPayload): void {
|
|
|
219
211
|
if (typeof startCursor === 'string') {
|
|
220
212
|
clientPageInfo.setValue(startCursor, START_CURSOR);
|
|
221
213
|
}
|
|
222
|
-
// $FlowFixMe[prop-missing]
|
|
223
214
|
} else if (args.after != null || (args.before == null && args.first)) {
|
|
224
215
|
clientPageInfo.setValue(
|
|
225
216
|
!!serverPageInfo.getValue(HAS_NEXT_PAGE),
|
|
@@ -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.
|
|
@@ -12,19 +12,18 @@
|
|
|
12
12
|
|
|
13
13
|
'use strict';
|
|
14
14
|
|
|
15
|
-
const ConnectionHandler = require('./ConnectionHandler');
|
|
16
|
-
const ConnectionInterface = require('./ConnectionInterface');
|
|
17
|
-
|
|
18
|
-
const invariant = require('invariant');
|
|
19
|
-
const warning = require('warning');
|
|
20
|
-
|
|
21
15
|
import type {
|
|
22
|
-
RecordProxy,
|
|
23
16
|
HandleFieldPayload,
|
|
24
|
-
RecordSourceProxy,
|
|
25
17
|
Handler,
|
|
18
|
+
RecordProxy,
|
|
19
|
+
RecordSourceProxy,
|
|
26
20
|
} from '../../store/RelayStoreTypes';
|
|
27
21
|
|
|
22
|
+
const ConnectionHandler = require('./ConnectionHandler');
|
|
23
|
+
const ConnectionInterface = require('./ConnectionInterface');
|
|
24
|
+
const invariant = require('invariant');
|
|
25
|
+
const warning = require('warning');
|
|
26
|
+
|
|
28
27
|
const DeleteRecordHandler = {
|
|
29
28
|
update: (store: RecordSourceProxy, payload: HandleFieldPayload) => {
|
|
30
29
|
const record = store.get(payload.dataID);
|
|
@@ -51,7 +50,6 @@ const DeleteEdgeHandler = {
|
|
|
51
50
|
if (record == null) {
|
|
52
51
|
return;
|
|
53
52
|
}
|
|
54
|
-
// $FlowFixMe[prop-missing]
|
|
55
53
|
const {connections} = payload.handleArgs;
|
|
56
54
|
invariant(
|
|
57
55
|
connections != null,
|
|
@@ -101,7 +99,6 @@ function edgeUpdater(
|
|
|
101
99
|
if (record == null) {
|
|
102
100
|
return;
|
|
103
101
|
}
|
|
104
|
-
// $FlowFixMe[prop-missing]
|
|
105
102
|
const {connections} = payload.handleArgs;
|
|
106
103
|
invariant(
|
|
107
104
|
connections != null,
|
|
@@ -174,7 +171,6 @@ function nodeUpdater(
|
|
|
174
171
|
if (record == null) {
|
|
175
172
|
return;
|
|
176
173
|
}
|
|
177
|
-
// $FlowFixMe[prop-missing]
|
|
178
174
|
const {connections, edgeTypeName} = payload.handleArgs;
|
|
179
175
|
invariant(
|
|
180
176
|
connections != null,
|
package/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Relay
|
|
2
|
+
* Relay v13.0.0
|
|
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.
|
|
@@ -14,41 +14,43 @@
|
|
|
14
14
|
|
|
15
15
|
const ConnectionHandler = require('./handlers/connection/ConnectionHandler');
|
|
16
16
|
const ConnectionInterface = require('./handlers/connection/ConnectionInterface');
|
|
17
|
-
const GraphQLTag = require('./query/GraphQLTag');
|
|
18
17
|
const MutationHandlers = require('./handlers/connection/MutationHandlers');
|
|
18
|
+
const RelayDefaultHandlerProvider = require('./handlers/RelayDefaultHandlerProvider');
|
|
19
|
+
const applyOptimisticMutation = require('./mutations/applyOptimisticMutation');
|
|
20
|
+
const commitLocalUpdate = require('./mutations/commitLocalUpdate');
|
|
21
|
+
const commitMutation = require('./mutations/commitMutation');
|
|
22
|
+
const RelayDeclarativeMutationConfig = require('./mutations/RelayDeclarativeMutationConfig');
|
|
23
|
+
const RelayNetwork = require('./network/RelayNetwork');
|
|
24
|
+
const RelayObservable = require('./network/RelayObservable');
|
|
25
|
+
const RelayQueryResponseCache = require('./network/RelayQueryResponseCache');
|
|
26
|
+
const fetchQuery = require('./query/fetchQuery');
|
|
27
|
+
const fetchQuery_DEPRECATED = require('./query/fetchQuery_DEPRECATED');
|
|
28
|
+
const fetchQueryInternal = require('./query/fetchQueryInternal');
|
|
29
|
+
const GraphQLTag = require('./query/GraphQLTag');
|
|
19
30
|
const PreloadableQueryRegistry = require('./query/PreloadableQueryRegistry');
|
|
20
|
-
const
|
|
31
|
+
const {
|
|
32
|
+
generateClientID,
|
|
33
|
+
generateUniqueClientID,
|
|
34
|
+
isClientID,
|
|
35
|
+
} = require('./store/ClientID');
|
|
36
|
+
const createFragmentSpecResolver = require('./store/createFragmentSpecResolver');
|
|
37
|
+
const createRelayContext = require('./store/createRelayContext');
|
|
38
|
+
const isRelayModernEnvironment = require('./store/isRelayModernEnvironment');
|
|
39
|
+
const readInlineData = require('./store/readInlineData');
|
|
21
40
|
const RelayConcreteVariables = require('./store/RelayConcreteVariables');
|
|
22
|
-
const RelayDeclarativeMutationConfig = require('./mutations/RelayDeclarativeMutationConfig');
|
|
23
|
-
const RelayDefaultHandleKey = require('./util/RelayDefaultHandleKey');
|
|
24
|
-
const RelayDefaultHandlerProvider = require('./handlers/RelayDefaultHandlerProvider');
|
|
25
|
-
const RelayError = require('./util/RelayError');
|
|
26
|
-
const RelayFeatureFlags = require('./util/RelayFeatureFlags');
|
|
27
41
|
const RelayModernEnvironment = require('./store/RelayModernEnvironment');
|
|
28
42
|
const RelayModernOperationDescriptor = require('./store/RelayModernOperationDescriptor');
|
|
29
43
|
const RelayModernRecord = require('./store/RelayModernRecord');
|
|
30
44
|
const RelayModernSelector = require('./store/RelayModernSelector');
|
|
31
45
|
const RelayModernStore = require('./store/RelayModernStore');
|
|
32
|
-
const RelayNetwork = require('./network/RelayNetwork');
|
|
33
|
-
const RelayObservable = require('./network/RelayObservable');
|
|
34
46
|
const RelayOperationTracker = require('./store/RelayOperationTracker');
|
|
35
|
-
const RelayProfiler = require('./util/RelayProfiler');
|
|
36
|
-
const RelayQueryResponseCache = require('./network/RelayQueryResponseCache');
|
|
37
47
|
const RelayRecordSource = require('./store/RelayRecordSource');
|
|
38
|
-
const RelayReplaySubject = require('./util/RelayReplaySubject');
|
|
39
48
|
const RelayStoreUtils = require('./store/RelayStoreUtils');
|
|
49
|
+
const ResolverFragments = require('./store/ResolverFragments');
|
|
40
50
|
const ViewerPattern = require('./store/ViewerPattern');
|
|
41
|
-
|
|
42
|
-
const applyOptimisticMutation = require('./mutations/applyOptimisticMutation');
|
|
43
|
-
const commitLocalUpdate = require('./mutations/commitLocalUpdate');
|
|
44
|
-
const commitMutation = require('./mutations/commitMutation');
|
|
45
|
-
const createFragmentSpecResolver = require('./store/createFragmentSpecResolver');
|
|
51
|
+
const requestSubscription = require('./subscription/requestSubscription');
|
|
46
52
|
const createPayloadFor3DField = require('./util/createPayloadFor3DField');
|
|
47
|
-
const createRelayContext = require('./store/createRelayContext');
|
|
48
53
|
const deepFreeze = require('./util/deepFreeze');
|
|
49
|
-
const fetchQuery = require('./query/fetchQuery');
|
|
50
|
-
const fetchQueryInternal = require('./query/fetchQueryInternal');
|
|
51
|
-
const fetchQuery_DEPRECATED = require('./query/fetchQuery_DEPRECATED');
|
|
52
54
|
const getFragmentIdentifier = require('./util/getFragmentIdentifier');
|
|
53
55
|
const getPaginationMetadata = require('./util/getPaginationMetadata');
|
|
54
56
|
const getPaginationVariables = require('./util/getPaginationVariables');
|
|
@@ -58,20 +60,17 @@ const getRelayHandleKey = require('./util/getRelayHandleKey');
|
|
|
58
60
|
const getRequestIdentifier = require('./util/getRequestIdentifier');
|
|
59
61
|
const getValueAtPath = require('./util/getValueAtPath');
|
|
60
62
|
const isPromise = require('./util/isPromise');
|
|
61
|
-
const isRelayModernEnvironment = require('./store/isRelayModernEnvironment');
|
|
62
63
|
const isScalarAndEqual = require('./util/isScalarAndEqual');
|
|
63
|
-
const readInlineData = require('./store/readInlineData');
|
|
64
64
|
const recycleNodesInto = require('./util/recycleNodesInto');
|
|
65
|
+
const RelayConcreteNode = require('./util/RelayConcreteNode');
|
|
66
|
+
const RelayDefaultHandleKey = require('./util/RelayDefaultHandleKey');
|
|
67
|
+
const RelayError = require('./util/RelayError');
|
|
68
|
+
const RelayFeatureFlags = require('./util/RelayFeatureFlags');
|
|
69
|
+
const RelayProfiler = require('./util/RelayProfiler');
|
|
70
|
+
const RelayReplaySubject = require('./util/RelayReplaySubject');
|
|
65
71
|
const reportMissingRequiredFields = require('./util/reportMissingRequiredFields');
|
|
66
|
-
const requestSubscription = require('./subscription/requestSubscription');
|
|
67
72
|
const stableCopy = require('./util/stableCopy');
|
|
68
73
|
|
|
69
|
-
const {
|
|
70
|
-
generateClientID,
|
|
71
|
-
generateUniqueClientID,
|
|
72
|
-
isClientID,
|
|
73
|
-
} = require('./store/ClientID');
|
|
74
|
-
|
|
75
74
|
export type {ConnectionMetadata} from './handlers/connection/ConnectionHandler';
|
|
76
75
|
export type {
|
|
77
76
|
EdgeRecord,
|
|
@@ -87,7 +86,6 @@ export type {OptimisticMutationConfig} from './mutations/applyOptimisticMutation
|
|
|
87
86
|
export type {
|
|
88
87
|
DEPRECATED_MutationConfig,
|
|
89
88
|
MutationConfig,
|
|
90
|
-
MutationParameters,
|
|
91
89
|
} from './mutations/commitMutation';
|
|
92
90
|
export type {
|
|
93
91
|
ExecuteFunction,
|
|
@@ -121,7 +119,9 @@ export type {RecordState} from './store/RelayRecordState';
|
|
|
121
119
|
export type {
|
|
122
120
|
ExecuteMutationConfig,
|
|
123
121
|
FragmentMap,
|
|
124
|
-
FragmentReference
|
|
122
|
+
// DEPRECATED: use FragmentType instead of FragmentReference
|
|
123
|
+
FragmentType as FragmentReference,
|
|
124
|
+
FragmentType,
|
|
125
125
|
FragmentSpecResolver,
|
|
126
126
|
HandleFieldPayload,
|
|
127
127
|
IEnvironment,
|
|
@@ -131,6 +131,7 @@ export type {
|
|
|
131
131
|
MissingFieldHandler,
|
|
132
132
|
MissingRequiredFields,
|
|
133
133
|
ModuleImportPointer,
|
|
134
|
+
MutationParameters,
|
|
134
135
|
NormalizationSelector,
|
|
135
136
|
OperationAvailability,
|
|
136
137
|
OperationDescriptor,
|
|
@@ -179,8 +180,8 @@ export type {
|
|
|
179
180
|
NormalizationSplitOperation,
|
|
180
181
|
NormalizationStream,
|
|
181
182
|
NormalizationTypeDiscriminator,
|
|
183
|
+
NormalizationOperation,
|
|
182
184
|
} from './util/NormalizationNode';
|
|
183
|
-
export type {NormalizationOperation} from './util/NormalizationNode';
|
|
184
185
|
export type {
|
|
185
186
|
ReaderArgument,
|
|
186
187
|
ReaderArgumentDefinition,
|
|
@@ -210,7 +211,14 @@ export type {
|
|
|
210
211
|
Disposable,
|
|
211
212
|
FetchPolicy,
|
|
212
213
|
FetchQueryFetchPolicy,
|
|
214
|
+
Fragment,
|
|
215
|
+
GraphQLSubscription,
|
|
216
|
+
InlineFragment,
|
|
217
|
+
Mutation,
|
|
218
|
+
Operation,
|
|
213
219
|
OperationType,
|
|
220
|
+
Query,
|
|
221
|
+
RefetchableFragment,
|
|
214
222
|
RenderPolicy,
|
|
215
223
|
Variables,
|
|
216
224
|
VariablesOf,
|
|
@@ -345,6 +353,7 @@ module.exports = {
|
|
|
345
353
|
getPendingOperationsForFragment: getPendingOperationsForFragment,
|
|
346
354
|
getValueAtPath: getValueAtPath,
|
|
347
355
|
__internal: {
|
|
356
|
+
ResolverFragments,
|
|
348
357
|
OperationTracker: RelayOperationTracker,
|
|
349
358
|
createRelayContext: createRelayContext,
|
|
350
359
|
getOperationVariables: RelayConcreteVariables.getOperationVariables,
|
|
@@ -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,20 +10,20 @@
|
|
|
10
10
|
// flowlint ambiguous-object-type:error
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
|
-
var
|
|
13
|
+
var _require = require('../../store/ClientID'),
|
|
14
|
+
generateClientID = _require.generateClientID;
|
|
15
|
+
|
|
16
|
+
var _require2 = require('../../store/RelayStoreUtils'),
|
|
17
|
+
getStableStorageKey = _require2.getStableStorageKey;
|
|
14
18
|
|
|
15
19
|
var getRelayHandleKey = require('../../util/getRelayHandleKey');
|
|
16
20
|
|
|
21
|
+
var ConnectionInterface = require('./ConnectionInterface');
|
|
22
|
+
|
|
17
23
|
var invariant = require('invariant');
|
|
18
24
|
|
|
19
25
|
var warning = require("fbjs/lib/warning");
|
|
20
26
|
|
|
21
|
-
var _require = require('../../store/ClientID'),
|
|
22
|
-
generateClientID = _require.generateClientID;
|
|
23
|
-
|
|
24
|
-
var _require2 = require('../../store/RelayStoreUtils'),
|
|
25
|
-
getStableStorageKey = _require2.getStableStorageKey;
|
|
26
|
-
|
|
27
27
|
var CONNECTION = 'connection'; // Per-instance incrementing index used to generate unique edge IDs
|
|
28
28
|
|
|
29
29
|
var NEXT_EDGE_INDEX = '__connection_next_edge_index';
|
|
@@ -133,23 +133,19 @@ function update(store, payload) {
|
|
|
133
133
|
var args = payload.args;
|
|
134
134
|
|
|
135
135
|
if (prevEdges && _serverEdges) {
|
|
136
|
-
// $FlowFixMe[prop-missing]
|
|
137
136
|
if (args.after != null) {
|
|
138
137
|
// Forward pagination from the end of the connection: append edges
|
|
139
|
-
if (clientPageInfo &&
|
|
140
|
-
args.after === clientPageInfo.getValue(END_CURSOR)) {
|
|
138
|
+
if (clientPageInfo && args.after === clientPageInfo.getValue(END_CURSOR)) {
|
|
141
139
|
var nodeIDs = new Set();
|
|
142
140
|
mergeEdges(prevEdges, nextEdges, nodeIDs);
|
|
143
141
|
mergeEdges(_serverEdges, nextEdges, nodeIDs);
|
|
144
142
|
} else {
|
|
145
143
|
process.env.NODE_ENV !== "production" ? warning(false, 'Relay: Unexpected after cursor `%s`, edges must ' + 'be fetched from the end of the list (`%s`).', args.after, clientPageInfo && clientPageInfo.getValue(END_CURSOR)) : void 0;
|
|
146
144
|
return;
|
|
147
|
-
}
|
|
148
|
-
|
|
145
|
+
}
|
|
149
146
|
} else if (args.before != null) {
|
|
150
147
|
// Backward pagination from the start of the connection: prepend edges
|
|
151
|
-
if (clientPageInfo &&
|
|
152
|
-
args.before === clientPageInfo.getValue(START_CURSOR)) {
|
|
148
|
+
if (clientPageInfo && args.before === clientPageInfo.getValue(START_CURSOR)) {
|
|
153
149
|
var _nodeIDs = new Set();
|
|
154
150
|
|
|
155
151
|
mergeEdges(_serverEdges, nextEdges, _nodeIDs);
|
|
@@ -176,19 +172,17 @@ function update(store, payload) {
|
|
|
176
172
|
|
|
177
173
|
|
|
178
174
|
if (clientPageInfo && serverPageInfo) {
|
|
179
|
-
// $FlowFixMe[prop-missing]
|
|
180
175
|
if (args.after == null && args.before == null) {
|
|
181
176
|
// The connection was refetched from the beginning/end: replace
|
|
182
177
|
// page_info
|
|
183
|
-
clientPageInfo.copyFieldsFrom(serverPageInfo);
|
|
178
|
+
clientPageInfo.copyFieldsFrom(serverPageInfo);
|
|
184
179
|
} else if (args.before != null || args.after == null && args.last) {
|
|
185
180
|
clientPageInfo.setValue(!!serverPageInfo.getValue(HAS_PREV_PAGE), HAS_PREV_PAGE);
|
|
186
181
|
var startCursor = serverPageInfo.getValue(START_CURSOR);
|
|
187
182
|
|
|
188
183
|
if (typeof startCursor === 'string') {
|
|
189
184
|
clientPageInfo.setValue(startCursor, START_CURSOR);
|
|
190
|
-
}
|
|
191
|
-
|
|
185
|
+
}
|
|
192
186
|
} else if (args.after != null || args.before == null && args.first) {
|
|
193
187
|
clientPageInfo.setValue(!!serverPageInfo.getValue(HAS_NEXT_PAGE), HAS_NEXT_PAGE);
|
|
194
188
|
var endCursor = serverPageInfo.getValue(END_CURSOR);
|
|
@@ -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.
|
|
@@ -47,8 +47,7 @@ var DeleteEdgeHandler = {
|
|
|
47
47
|
|
|
48
48
|
if (record == null) {
|
|
49
49
|
return;
|
|
50
|
-
}
|
|
51
|
-
|
|
50
|
+
}
|
|
52
51
|
|
|
53
52
|
var connections = payload.handleArgs.connections;
|
|
54
53
|
!(connections != null) ? process.env.NODE_ENV !== "production" ? invariant(false, 'MutationHandlers: Expected connection IDs to be specified.') : invariant(false) : void 0;
|
|
@@ -101,8 +100,7 @@ function edgeUpdater(insertFn) {
|
|
|
101
100
|
|
|
102
101
|
if (record == null) {
|
|
103
102
|
return;
|
|
104
|
-
}
|
|
105
|
-
|
|
103
|
+
}
|
|
106
104
|
|
|
107
105
|
var connections = payload.handleArgs.connections;
|
|
108
106
|
!(connections != null) ? process.env.NODE_ENV !== "production" ? invariant(false, 'MutationHandlers: Expected connection IDs to be specified.') : invariant(false) : void 0;
|
|
@@ -205,8 +203,7 @@ function nodeUpdater(insertFn) {
|
|
|
205
203
|
|
|
206
204
|
if (record == null) {
|
|
207
205
|
return;
|
|
208
|
-
}
|
|
209
|
-
|
|
206
|
+
}
|
|
210
207
|
|
|
211
208
|
var _payload$handleArgs = payload.handleArgs,
|
|
212
209
|
connections = _payload$handleArgs.connections,
|