relay-runtime 9.0.0 → 9.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/handlers/RelayDefaultHandlerProvider.js.flow +34 -0
- package/handlers/connection/ConnectionHandler.js.flow +549 -0
- package/handlers/connection/ConnectionInterface.js.flow +92 -0
- package/index.js +1 -1
- package/index.js.flow +314 -0
- package/lib/handlers/connection/ConnectionHandler.js +1 -3
- package/lib/index.js +1 -2
- package/lib/mutations/RelayDeclarativeMutationConfig.js +22 -45
- package/lib/mutations/RelayRecordProxy.js +1 -3
- package/lib/mutations/RelayRecordSourceMutator.js +1 -3
- package/lib/mutations/RelayRecordSourceProxy.js +1 -3
- package/lib/mutations/RelayRecordSourceSelectorProxy.js +1 -3
- package/lib/mutations/commitMutation.js +2 -0
- package/lib/mutations/validateMutation.js +13 -4
- package/lib/network/RelayObservable.js +9 -9
- package/lib/network/RelayQueryResponseCache.js +8 -6
- package/lib/query/fetchQueryInternal.js +1 -8
- package/lib/store/DataChecker.js +23 -51
- package/lib/store/RelayConcreteVariables.js +6 -2
- package/lib/store/RelayModernEnvironment.js +30 -12
- package/lib/store/RelayModernFragmentSpecResolver.js +9 -13
- package/lib/store/RelayModernQueryExecutor.js +73 -37
- package/lib/store/RelayModernRecord.js +14 -9
- package/lib/store/RelayModernStore.js +107 -70
- package/lib/store/RelayOperationTracker.js +35 -78
- package/lib/store/RelayOptimisticRecordSource.js +7 -5
- package/lib/store/RelayPublishQueue.js +1 -3
- package/lib/store/RelayReader.js +1 -3
- package/lib/store/RelayRecordSource.js +1 -3
- package/lib/store/RelayRecordSourceMapImpl.js +13 -18
- package/lib/store/RelayReferenceMarker.js +2 -6
- package/lib/store/RelayResponseNormalizer.js +9 -10
- package/lib/store/StoreInspector.js +7 -5
- package/lib/store/normalizeRelayPayload.js +6 -2
- package/lib/subscription/requestSubscription.js +4 -2
- package/lib/util/RelayFeatureFlags.js +1 -1
- package/lib/util/RelayReplaySubject.js +1 -3
- package/lib/util/createPayloadFor3DField.js +7 -2
- package/mutations/RelayDeclarativeMutationConfig.js.flow +380 -0
- package/mutations/RelayRecordProxy.js.flow +165 -0
- package/mutations/RelayRecordSourceMutator.js.flow +238 -0
- package/mutations/RelayRecordSourceProxy.js.flow +164 -0
- package/mutations/RelayRecordSourceSelectorProxy.js.flow +119 -0
- package/mutations/applyOptimisticMutation.js.flow +76 -0
- package/mutations/commitLocalUpdate.js.flow +24 -0
- package/mutations/commitMutation.js.flow +184 -0
- package/mutations/validateMutation.js.flow +211 -0
- package/network/ConvertToExecuteFunction.js.flow +49 -0
- package/network/RelayNetwork.js.flow +84 -0
- package/network/RelayNetworkTypes.js.flow +123 -0
- package/network/RelayObservable.js.flow +634 -0
- package/network/RelayQueryResponseCache.js.flow +111 -0
- package/package.json +1 -1
- package/query/GraphQLTag.js.flow +166 -0
- package/query/fetchQuery.js.flow +47 -0
- package/query/fetchQueryInternal.js.flow +349 -0
- package/relay-runtime.js +2 -2
- package/relay-runtime.min.js +2 -2
- package/store/ClientID.js.flow +43 -0
- package/store/DataChecker.js.flow +426 -0
- package/store/RelayConcreteVariables.js.flow +96 -0
- package/store/RelayModernEnvironment.js.flow +526 -0
- package/store/RelayModernFragmentSpecResolver.js.flow +426 -0
- package/store/RelayModernOperationDescriptor.js.flow +88 -0
- package/store/RelayModernQueryExecutor.js.flow +1327 -0
- package/store/RelayModernRecord.js.flow +403 -0
- package/store/RelayModernSelector.js.flow +444 -0
- package/store/RelayModernStore.js.flow +757 -0
- package/store/RelayOperationTracker.js.flow +164 -0
- package/store/RelayOptimisticRecordSource.js.flow +119 -0
- package/store/RelayPublishQueue.js.flow +401 -0
- package/store/RelayReader.js.flow +376 -0
- package/store/RelayRecordSource.js.flow +29 -0
- package/store/RelayRecordSourceMapImpl.js.flow +87 -0
- package/store/RelayRecordState.js.flow +37 -0
- package/store/RelayReferenceMarker.js.flow +236 -0
- package/store/RelayResponseNormalizer.js.flow +556 -0
- package/store/RelayStoreTypes.js.flow +873 -0
- package/store/RelayStoreUtils.js.flow +218 -0
- package/store/StoreInspector.js.flow +173 -0
- package/store/ViewerPattern.js.flow +26 -0
- package/store/cloneRelayHandleSourceField.js.flow +66 -0
- package/store/createFragmentSpecResolver.js.flow +55 -0
- package/store/createRelayContext.js.flow +44 -0
- package/store/defaultGetDataID.js.flow +27 -0
- package/store/hasOverlappingIDs.js.flow +34 -0
- package/store/isRelayModernEnvironment.js.flow +27 -0
- package/store/normalizeRelayPayload.js.flow +51 -0
- package/store/readInlineData.js.flow +75 -0
- package/subscription/requestSubscription.js.flow +100 -0
- package/util/JSResourceTypes.flow.js.flow +20 -0
- package/util/NormalizationNode.js.flow +191 -0
- package/util/ReaderNode.js.flow +208 -0
- package/util/RelayConcreteNode.js.flow +80 -0
- package/util/RelayDefaultHandleKey.js.flow +17 -0
- package/util/RelayError.js.flow +33 -0
- package/util/RelayFeatureFlags.js.flow +30 -0
- package/util/RelayProfiler.js.flow +284 -0
- package/util/RelayReplaySubject.js.flow +134 -0
- package/util/RelayRuntimeTypes.js.flow +70 -0
- package/util/createPayloadFor3DField.js.flow +43 -0
- package/util/deepFreeze.js.flow +36 -0
- package/util/generateID.js.flow +21 -0
- package/util/getFragmentIdentifier.js.flow +52 -0
- package/util/getRelayHandleKey.js.flow +41 -0
- package/util/getRequestIdentifier.js.flow +41 -0
- package/util/isPromise.js.flow +21 -0
- package/util/isScalarAndEqual.js.flow +26 -0
- package/util/recycleNodesInto.js.flow +80 -0
- package/util/resolveImmediate.js.flow +30 -0
- package/util/stableCopy.js.flow +35 -0
|
@@ -0,0 +1,123 @@
|
|
|
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 {RequestParameters} from '../util/RelayConcreteNode';
|
|
16
|
+
import type {CacheConfig, Variables} from '../util/RelayRuntimeTypes';
|
|
17
|
+
import type RelayObservable, {ObservableFromValue} from './RelayObservable';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* An interface for fetching the data for one or more (possibly interdependent)
|
|
21
|
+
* queries.
|
|
22
|
+
*/
|
|
23
|
+
export type INetwork = {|
|
|
24
|
+
execute: ExecuteFunction,
|
|
25
|
+
|};
|
|
26
|
+
export type LogRequestInfoFunction = mixed => void;
|
|
27
|
+
|
|
28
|
+
export type PayloadData = {[key: string]: mixed, ...};
|
|
29
|
+
|
|
30
|
+
export type PayloadError = {
|
|
31
|
+
message: string,
|
|
32
|
+
locations?: Array<{
|
|
33
|
+
line: number,
|
|
34
|
+
column: number,
|
|
35
|
+
...
|
|
36
|
+
}>,
|
|
37
|
+
// Not officially part of the spec, but used at Facebook
|
|
38
|
+
severity?: 'CRITICAL' | 'ERROR' | 'WARNING',
|
|
39
|
+
...
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export type PayloadExtensions = {[key: string]: mixed, ...};
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* The shape of a GraphQL response as dictated by the
|
|
46
|
+
* [spec](https://graphql.github.io/graphql-spec/June2018/#sec-Response-Format)
|
|
47
|
+
*/
|
|
48
|
+
export type GraphQLResponseWithData = {|
|
|
49
|
+
+data: PayloadData,
|
|
50
|
+
+errors?: Array<PayloadError>,
|
|
51
|
+
+extensions?: PayloadExtensions,
|
|
52
|
+
+label?: string,
|
|
53
|
+
+path?: Array<string | number>,
|
|
54
|
+
|};
|
|
55
|
+
|
|
56
|
+
export type GraphQLResponseWithoutData = {|
|
|
57
|
+
+data?: ?PayloadData,
|
|
58
|
+
+errors: Array<PayloadError>,
|
|
59
|
+
+extensions?: PayloadExtensions,
|
|
60
|
+
+label?: string,
|
|
61
|
+
+path?: Array<string | number>,
|
|
62
|
+
|};
|
|
63
|
+
|
|
64
|
+
export type GraphQLResponseWithExtensionsOnly = {|
|
|
65
|
+
// Per https://spec.graphql.org/June2018/#sec-Errors
|
|
66
|
+
// > If the data entry in the response is not present, the errors entry
|
|
67
|
+
// > in the response must not be empty. It must contain at least one error
|
|
68
|
+
// This means a payload has to have either a data key or an errors key:
|
|
69
|
+
// but the spec leaves room for the combination of data: null plus extensions
|
|
70
|
+
// since `data: null` is a *required* output if there was an error during
|
|
71
|
+
// execution, but the inverse is not described in the sepc: `data: null`
|
|
72
|
+
// does not necessarily indicate that there was an error.
|
|
73
|
+
+data: null,
|
|
74
|
+
+extensions: PayloadExtensions,
|
|
75
|
+
|};
|
|
76
|
+
|
|
77
|
+
export type GraphQLSingularResponse =
|
|
78
|
+
| GraphQLResponseWithData
|
|
79
|
+
| GraphQLResponseWithExtensionsOnly
|
|
80
|
+
| GraphQLResponseWithoutData;
|
|
81
|
+
|
|
82
|
+
export type GraphQLResponse =
|
|
83
|
+
| GraphQLSingularResponse
|
|
84
|
+
| $ReadOnlyArray<GraphQLSingularResponse>;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* A function that returns an Observable representing the response of executing
|
|
88
|
+
* a GraphQL operation.
|
|
89
|
+
*/
|
|
90
|
+
export type ExecuteFunction = (
|
|
91
|
+
request: RequestParameters,
|
|
92
|
+
variables: Variables,
|
|
93
|
+
cacheConfig: CacheConfig,
|
|
94
|
+
uploadables?: ?UploadableMap,
|
|
95
|
+
logRequestInfo?: ?LogRequestInfoFunction,
|
|
96
|
+
) => RelayObservable<GraphQLResponse>;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* A function that executes a GraphQL operation with request/response semantics.
|
|
100
|
+
*
|
|
101
|
+
* May return an Observable or Promise of a plain GraphQL server response, or
|
|
102
|
+
* a composed ExecutePayload object supporting additional metadata.
|
|
103
|
+
*/
|
|
104
|
+
export type FetchFunction = (
|
|
105
|
+
request: RequestParameters,
|
|
106
|
+
variables: Variables,
|
|
107
|
+
cacheConfig: CacheConfig,
|
|
108
|
+
uploadables: ?UploadableMap,
|
|
109
|
+
logRequestInfo?: ?LogRequestInfoFunction,
|
|
110
|
+
) => ObservableFromValue<GraphQLResponse>;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* A function that executes a GraphQL subscription operation, returning zero or
|
|
114
|
+
* more raw server responses over time.
|
|
115
|
+
*/
|
|
116
|
+
export type SubscribeFunction = (
|
|
117
|
+
request: RequestParameters,
|
|
118
|
+
variables: Variables,
|
|
119
|
+
cacheConfig: CacheConfig,
|
|
120
|
+
) => RelayObservable<GraphQLResponse>;
|
|
121
|
+
|
|
122
|
+
export type Uploadable = File | Blob;
|
|
123
|
+
export type UploadableMap = {[key: string]: Uploadable, ...};
|