react-relay 2.0.0-rc.2 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/index.js +2 -2
- package/lib/ReactRelayContext.js +6 -3
- package/lib/ReactRelayFragmentContainer.js +48 -46
- package/lib/ReactRelayFragmentMockRenderer.js +5 -1
- package/lib/ReactRelayPaginationContainer.js +102 -68
- package/lib/ReactRelayQueryFetcher.js +54 -28
- package/lib/ReactRelayQueryRenderer.js +28 -20
- package/lib/ReactRelayRefetchContainer.js +70 -58
- package/lib/ReactRelayTestMocker.js +56 -43
- package/lib/ReactRelayTypes.js +1 -1
- package/lib/RelayContext.js +8 -2
- package/lib/assertFragmentMap.js +9 -7
- package/lib/buildReactRelayContainer.js +32 -23
- package/lib/index.js +41 -0
- package/lib/isRelayEnvironment.js +1 -1
- package/lib/isRelayVariables.js +1 -1
- package/lib/readContext.js +7 -4
- package/package.json +4 -4
- package/react-relay.js +2 -2
- package/react-relay.min.js +2 -2
- package/classic.js +0 -10
- package/compat.js +0 -10
- package/lib/ConcreteQuery.js +0 -10
- package/lib/GraphQLQueryRunner.js +0 -264
- package/lib/GraphQLRange.js +0 -1124
- package/lib/GraphQLSegment.js +0 -743
- package/lib/GraphQLStoreChangeEmitter.js +0 -141
- package/lib/GraphQLStoreQueryResolver.js +0 -288
- package/lib/GraphQLStoreRangeUtils.js +0 -126
- package/lib/QueryBuilder.js +0 -228
- package/lib/ReactRelayClassicExports.js +0 -29
- package/lib/ReactRelayCompatContainerBuilder.js +0 -175
- package/lib/ReactRelayCompatPublic.js +0 -28
- package/lib/ReactRelayContainerProfiler.js +0 -30
- package/lib/ReactRelayFragmentContainer-flowtest.js +0 -201
- package/lib/ReactRelayPaginationContainer-flowtest.js +0 -213
- package/lib/ReactRelayPublic.js +0 -29
- package/lib/ReactRelayRefetchContainer-flowtest.js +0 -191
- package/lib/RelayCacheProcessor.js +0 -196
- package/lib/RelayChangeTracker.js +0 -83
- package/lib/RelayClassicContainerUtils.js +0 -49
- package/lib/RelayClassicCore.js +0 -34
- package/lib/RelayClassicRecordState.js +0 -31
- package/lib/RelayCompatContainer.js +0 -25
- package/lib/RelayCompatEnvironment.js +0 -27
- package/lib/RelayCompatMutations.js +0 -133
- package/lib/RelayCompatPaginationContainer.js +0 -27
- package/lib/RelayCompatRefetchContainer.js +0 -27
- package/lib/RelayCompatTypes.js +0 -10
- package/lib/RelayContainer.js +0 -889
- package/lib/RelayContainerComparators.js +0 -75
- package/lib/RelayContainerProxy.js +0 -21
- package/lib/RelayDefaultNetworkLayer.js +0 -192
- package/lib/RelayEnvironment.js +0 -449
- package/lib/RelayEnvironmentTypes.js +0 -10
- package/lib/RelayFetchMode.js +0 -17
- package/lib/RelayFragmentPointer.js +0 -161
- package/lib/RelayFragmentReference.js +0 -249
- package/lib/RelayFragmentSpecResolver.js +0 -305
- package/lib/RelayGraphQLMutation.js +0 -288
- package/lib/RelayGraphQLTag.js +0 -42
- package/lib/RelayInternalTypes.js +0 -15
- package/lib/RelayInternals.js +0 -24
- package/lib/RelayMetaRoute.js +0 -35
- package/lib/RelayMockRenderer.js +0 -71
- package/lib/RelayModern-flowtest.js +0 -342
- package/lib/RelayModernFlowtest_badref.graphql.js +0 -10
- package/lib/RelayModernFlowtest_notref.graphql.js +0 -10
- package/lib/RelayModernFlowtest_user.graphql.js +0 -10
- package/lib/RelayModernFlowtest_users.graphql.js +0 -10
- package/lib/RelayMutation.js +0 -322
- package/lib/RelayMutationDebugPrinter.js +0 -47
- package/lib/RelayMutationQuery.js +0 -558
- package/lib/RelayMutationQueue.js +0 -530
- package/lib/RelayMutationRequest.js +0 -103
- package/lib/RelayMutationTracker.js +0 -113
- package/lib/RelayMutationTransaction.js +0 -92
- package/lib/RelayMutationTransactionStatus.js +0 -55
- package/lib/RelayNetworkDebug.js +0 -131
- package/lib/RelayNetworkLayer.js +0 -185
- package/lib/RelayNodeInterface.js +0 -104
- package/lib/RelayOperationDescriptor.js +0 -40
- package/lib/RelayOptimisticMutationUtils.js +0 -208
- package/lib/RelayPendingQueryTracker.js +0 -166
- package/lib/RelayPropTypes.js +0 -57
- package/lib/RelayPublic.js +0 -44
- package/lib/RelayQL.js +0 -128
- package/lib/RelayQuery.js +0 -1584
- package/lib/RelayQueryCaching.js +0 -33
- package/lib/RelayQueryConfig.js +0 -58
- package/lib/RelayQueryPath.js +0 -204
- package/lib/RelayQueryRequest.js +0 -103
- package/lib/RelayQueryTracker.js +0 -86
- package/lib/RelayQueryTransform.js +0 -91
- package/lib/RelayQueryVisitor.js +0 -93
- package/lib/RelayQueryWriter.js +0 -573
- package/lib/RelayReadyState.js +0 -83
- package/lib/RelayReadyStateRenderer.js +0 -145
- package/lib/RelayRecord.js +0 -75
- package/lib/RelayRecordStatusMap.js +0 -57
- package/lib/RelayRecordStore.js +0 -433
- package/lib/RelayRecordWriter.js +0 -601
- package/lib/RelayRefQueryDescriptor.js +0 -27
- package/lib/RelayRenderer.js +0 -268
- package/lib/RelayRootContainer.js +0 -125
- package/lib/RelayRoute.js +0 -92
- package/lib/RelayRouteFragment.js +0 -44
- package/lib/RelaySelector.js +0 -201
- package/lib/RelayShallowMock.js +0 -69
- package/lib/RelayStaticContainer.js +0 -38
- package/lib/RelayStore.js +0 -12
- package/lib/RelayStoreConstants.js +0 -20
- package/lib/RelayStoreData.js +0 -660
- package/lib/RelayTaskQueue.js +0 -189
- package/lib/RelayTypes.js +0 -13
- package/lib/RelayVariable.js +0 -32
- package/lib/RelayVariables.js +0 -92
- package/lib/buildRQL.js +0 -160
- package/lib/callsFromGraphQL.js +0 -74
- package/lib/callsToGraphQL.js +0 -34
- package/lib/checkRelayQueryData.js +0 -250
- package/lib/createRelayQuery.js +0 -17
- package/lib/dedent.js +0 -49
- package/lib/diffRelayQuery.js +0 -757
- package/lib/directivesToGraphQL.js +0 -39
- package/lib/filterRelayQuery.js +0 -29
- package/lib/findRelayQueryLeaves.js +0 -293
- package/lib/flattenRelayQuery.js +0 -121
- package/lib/flattenSplitRelayQueries.js +0 -44
- package/lib/forEachRootCallArg.js +0 -40
- package/lib/fromGraphQL.js +0 -48
- package/lib/generateClientEdgeID.js +0 -22
- package/lib/generateClientID.js +0 -27
- package/lib/generateConcreteFragmentID.js +0 -30
- package/lib/generateForceIndex.js +0 -24
- package/lib/generateRQLFieldAlias.js +0 -39
- package/lib/getRangeBehavior.js +0 -58
- package/lib/getRelayQueries.js +0 -83
- package/lib/intersectRelayQuery.js +0 -149
- package/lib/isClassicRelayContext.js +0 -20
- package/lib/isClassicRelayEnvironment.js +0 -20
- package/lib/isCompatibleRelayFragmentType.js +0 -27
- package/lib/isRelayContainer.js +0 -16
- package/lib/makeLegacyStringishComponentRef.js +0 -52
- package/lib/printRelayOSSQuery.js +0 -329
- package/lib/printRelayQuery.js +0 -26
- package/lib/rangeOperationToMetadataKey.js +0 -25
- package/lib/readRelayQueryData.js +0 -551
- package/lib/relayUnstableBatchedUpdates.js +0 -12
- package/lib/relayUnstableBatchedUpdates.native.js +0 -11
- package/lib/restoreRelayCacheData.js +0 -188
- package/lib/serializeRelayQueryCall.js +0 -42
- package/lib/splitDeferredRelayQueries.js +0 -298
- package/lib/stableStringify.js +0 -85
- package/lib/testEditDistance.js +0 -112
- package/lib/throwFailedPromise.js +0 -26
- package/lib/toGraphQL.js +0 -94
- package/lib/transformRelayQueryPayload.js +0 -145
- package/lib/validateMutationConfig.js +0 -117
- package/lib/validateRelayReadQuery.js +0 -112
- package/lib/writeRelayQueryPayload.js +0 -44
- package/lib/writeRelayUpdatePayload.js +0 -513
- package/react-relay-classic.js +0 -4
- package/react-relay-classic.min.js +0 -9
- package/react-relay-compat.js +0 -4
- package/react-relay-compat.min.js +0 -9
@@ -1,250 +0,0 @@
|
|
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
|
-
*
|
8
|
-
* @format
|
9
|
-
*/
|
10
|
-
'use strict';
|
11
|
-
|
12
|
-
var _inheritsLoose2 = require("@babel/runtime/helpers/interopRequireDefault")(require("@babel/runtime/helpers/inheritsLoose"));
|
13
|
-
|
14
|
-
/**
|
15
|
-
* @internal
|
16
|
-
*
|
17
|
-
* Traverses a query and data in the record store to determine whether we have
|
18
|
-
* enough data to satisfy the query.
|
19
|
-
*/
|
20
|
-
function checkRelayQueryData(store, query) {
|
21
|
-
var checker = new RelayQueryChecker(store);
|
22
|
-
var state = {
|
23
|
-
dataID: undefined,
|
24
|
-
rangeInfo: undefined,
|
25
|
-
result: true
|
26
|
-
};
|
27
|
-
checker.visit(query, state);
|
28
|
-
return state.result;
|
29
|
-
}
|
30
|
-
|
31
|
-
var RelayQueryChecker =
|
32
|
-
/*#__PURE__*/
|
33
|
-
function (_RelayQueryVisitor) {
|
34
|
-
(0, _inheritsLoose2["default"])(RelayQueryChecker, _RelayQueryVisitor);
|
35
|
-
|
36
|
-
function RelayQueryChecker(store) {
|
37
|
-
var _this;
|
38
|
-
|
39
|
-
_this = _RelayQueryVisitor.call(this) || this;
|
40
|
-
_this._store = store;
|
41
|
-
return _this;
|
42
|
-
}
|
43
|
-
/**
|
44
|
-
* Skip visiting children if result is already false.
|
45
|
-
*/
|
46
|
-
|
47
|
-
|
48
|
-
var _proto = RelayQueryChecker.prototype;
|
49
|
-
|
50
|
-
_proto.traverse = function traverse(node, state) {
|
51
|
-
var children = node.getChildren();
|
52
|
-
|
53
|
-
for (var ii = 0; ii < children.length; ii++) {
|
54
|
-
if (!state.result) {
|
55
|
-
return;
|
56
|
-
}
|
57
|
-
|
58
|
-
this.visit(children[ii], state);
|
59
|
-
}
|
60
|
-
};
|
61
|
-
|
62
|
-
_proto.visitRoot = function visitRoot(root, state) {
|
63
|
-
var _this2 = this;
|
64
|
-
|
65
|
-
var storageKey = root.getStorageKey();
|
66
|
-
|
67
|
-
require("./forEachRootCallArg")(root, function (_ref) {
|
68
|
-
var identifyingArgKey = _ref.identifyingArgKey;
|
69
|
-
|
70
|
-
var dataID = _this2._store.getDataID(storageKey, identifyingArgKey);
|
71
|
-
|
72
|
-
if (dataID == null) {
|
73
|
-
state.result = false;
|
74
|
-
} else {
|
75
|
-
var nextState = {
|
76
|
-
dataID: dataID,
|
77
|
-
rangeInfo: undefined,
|
78
|
-
result: true
|
79
|
-
};
|
80
|
-
|
81
|
-
_this2.traverse(root, nextState);
|
82
|
-
|
83
|
-
state.result = state.result && nextState.result;
|
84
|
-
}
|
85
|
-
});
|
86
|
-
};
|
87
|
-
|
88
|
-
_proto.visitFragment = function visitFragment(fragment, state) {
|
89
|
-
var dataID = state.dataID; // The dataID check is for Flow; it must be non-null to have gotten here.
|
90
|
-
|
91
|
-
if (dataID && require("./isCompatibleRelayFragmentType")(fragment, this._store.getType(dataID))) {
|
92
|
-
this.traverse(fragment, state);
|
93
|
-
}
|
94
|
-
};
|
95
|
-
|
96
|
-
_proto.visitField = function visitField(field, state) {
|
97
|
-
var dataID = state.dataID;
|
98
|
-
|
99
|
-
var recordState = dataID && this._store.getRecordState(dataID);
|
100
|
-
|
101
|
-
if (recordState === require("./RelayClassicRecordState").UNKNOWN) {
|
102
|
-
state.result = false;
|
103
|
-
return;
|
104
|
-
} else if (recordState === require("./RelayClassicRecordState").NONEXISTENT) {
|
105
|
-
return;
|
106
|
-
}
|
107
|
-
|
108
|
-
var _ConnectionInterface$ = require("relay-runtime").ConnectionInterface.get(),
|
109
|
-
EDGES = _ConnectionInterface$.EDGES,
|
110
|
-
PAGE_INFO = _ConnectionInterface$.PAGE_INFO;
|
111
|
-
|
112
|
-
var rangeInfo = state.rangeInfo;
|
113
|
-
|
114
|
-
if (rangeInfo && field.getSchemaName() === EDGES) {
|
115
|
-
this._checkEdges(field, state);
|
116
|
-
} else if (rangeInfo && field.getSchemaName() === PAGE_INFO) {
|
117
|
-
this._checkPageInfo(field, state);
|
118
|
-
} else if (!field.canHaveSubselections()) {
|
119
|
-
this._checkScalar(field, state);
|
120
|
-
} else if (field.isPlural()) {
|
121
|
-
this._checkPlural(field, state);
|
122
|
-
} else if (field.isConnection()) {
|
123
|
-
this._checkConnection(field, state);
|
124
|
-
} else {
|
125
|
-
this._checkLinkedField(field, state);
|
126
|
-
}
|
127
|
-
};
|
128
|
-
|
129
|
-
_proto._checkScalar = function _checkScalar(field, state) {
|
130
|
-
var fieldData = state.dataID && this._store.getField(state.dataID, field.getStorageKey());
|
131
|
-
|
132
|
-
if (fieldData === undefined) {
|
133
|
-
state.result = false;
|
134
|
-
}
|
135
|
-
};
|
136
|
-
|
137
|
-
_proto._checkPlural = function _checkPlural(field, state) {
|
138
|
-
var dataIDs = state.dataID && this._store.getLinkedRecordIDs(state.dataID, field.getStorageKey());
|
139
|
-
|
140
|
-
if (dataIDs === undefined) {
|
141
|
-
state.result = false;
|
142
|
-
return;
|
143
|
-
}
|
144
|
-
|
145
|
-
if (dataIDs) {
|
146
|
-
for (var ii = 0; ii < dataIDs.length; ii++) {
|
147
|
-
if (!state.result) {
|
148
|
-
break;
|
149
|
-
}
|
150
|
-
|
151
|
-
var nextState = {
|
152
|
-
dataID: dataIDs[ii],
|
153
|
-
rangeInfo: undefined,
|
154
|
-
result: true
|
155
|
-
};
|
156
|
-
this.traverse(field, nextState);
|
157
|
-
state.result = nextState.result;
|
158
|
-
}
|
159
|
-
}
|
160
|
-
};
|
161
|
-
|
162
|
-
_proto._checkConnection = function _checkConnection(field, state) {
|
163
|
-
var calls = field.getCallsWithValues();
|
164
|
-
|
165
|
-
var dataID = state.dataID && this._store.getLinkedRecordID(state.dataID, field.getStorageKey());
|
166
|
-
|
167
|
-
if (dataID === undefined) {
|
168
|
-
state.result = false;
|
169
|
-
return;
|
170
|
-
}
|
171
|
-
|
172
|
-
var nextState = {
|
173
|
-
dataID: dataID,
|
174
|
-
rangeInfo: null,
|
175
|
-
// Flow rejects `undefined` here
|
176
|
-
result: true
|
177
|
-
};
|
178
|
-
|
179
|
-
var metadata = this._store.getRangeMetadata(dataID, calls);
|
180
|
-
|
181
|
-
if (metadata) {
|
182
|
-
nextState.rangeInfo = metadata;
|
183
|
-
}
|
184
|
-
|
185
|
-
this.traverse(field, nextState);
|
186
|
-
state.result = state.result && nextState.result;
|
187
|
-
};
|
188
|
-
|
189
|
-
_proto._checkEdges = function _checkEdges(field, state) {
|
190
|
-
var rangeInfo = state.rangeInfo;
|
191
|
-
|
192
|
-
if (!rangeInfo) {
|
193
|
-
state.result = false;
|
194
|
-
return;
|
195
|
-
}
|
196
|
-
|
197
|
-
if (rangeInfo.diffCalls.length) {
|
198
|
-
state.result = false;
|
199
|
-
return;
|
200
|
-
}
|
201
|
-
|
202
|
-
var edges = rangeInfo.filteredEdges;
|
203
|
-
|
204
|
-
for (var ii = 0; ii < edges.length; ii++) {
|
205
|
-
if (!state.result) {
|
206
|
-
break;
|
207
|
-
}
|
208
|
-
|
209
|
-
var nextState = {
|
210
|
-
dataID: edges[ii].edgeID,
|
211
|
-
rangeInfo: undefined,
|
212
|
-
result: true
|
213
|
-
};
|
214
|
-
this.traverse(field, nextState);
|
215
|
-
state.result = nextState.result;
|
216
|
-
}
|
217
|
-
};
|
218
|
-
|
219
|
-
_proto._checkPageInfo = function _checkPageInfo(field, state) {
|
220
|
-
var rangeInfo = state.rangeInfo;
|
221
|
-
|
222
|
-
if (!rangeInfo || !rangeInfo.pageInfo) {
|
223
|
-
state.result = false;
|
224
|
-
return;
|
225
|
-
}
|
226
|
-
};
|
227
|
-
|
228
|
-
_proto._checkLinkedField = function _checkLinkedField(field, state) {
|
229
|
-
var dataID = state.dataID && this._store.getLinkedRecordID(state.dataID, field.getStorageKey());
|
230
|
-
|
231
|
-
if (dataID === undefined) {
|
232
|
-
state.result = false;
|
233
|
-
return;
|
234
|
-
}
|
235
|
-
|
236
|
-
if (dataID) {
|
237
|
-
var nextState = {
|
238
|
-
dataID: dataID,
|
239
|
-
rangeInfo: undefined,
|
240
|
-
result: true
|
241
|
-
};
|
242
|
-
this.traverse(field, nextState);
|
243
|
-
state.result = state.result && nextState.result;
|
244
|
-
}
|
245
|
-
};
|
246
|
-
|
247
|
-
return RelayQueryChecker;
|
248
|
-
}(require("./RelayQueryVisitor"));
|
249
|
-
|
250
|
-
module.exports = require("relay-runtime").RelayProfiler.instrument('checkRelayQueryData', checkRelayQueryData);
|
package/lib/createRelayQuery.js
DELETED
@@ -1,17 +0,0 @@
|
|
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
|
-
* strict-local
|
8
|
-
* @format
|
9
|
-
*/
|
10
|
-
'use strict';
|
11
|
-
|
12
|
-
function createRelayQuery(node, variables) {
|
13
|
-
!(typeof variables === 'object' && variables != null && !Array.isArray(variables)) ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'Relay.Query: Expected `variables` to be an object.') : require("fbjs/lib/invariant")(false) : void 0;
|
14
|
-
return require("./RelayQuery").Root.create(node, require("./RelayMetaRoute").get('$createRelayQuery'), variables);
|
15
|
-
}
|
16
|
-
|
17
|
-
module.exports = createRelayQuery;
|
package/lib/dedent.js
DELETED
@@ -1,49 +0,0 @@
|
|
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
|
-
* strict
|
8
|
-
* @format
|
9
|
-
*/
|
10
|
-
'use strict';
|
11
|
-
/**
|
12
|
-
* Strips leading indentation from a multi-line string, enabling you to use
|
13
|
-
* template literals in tests while maintaining nice nesting.
|
14
|
-
*
|
15
|
-
* An optional padding string can be supplied to force a fixed indent to be
|
16
|
-
* applied back after stripping.
|
17
|
-
*/
|
18
|
-
|
19
|
-
function dedent(string) {
|
20
|
-
var padding = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
21
|
-
var blankLine = /^\s*$/;
|
22
|
-
var lines = string.split('\n'); // Remove any entirely blank leading or trailing lines.
|
23
|
-
|
24
|
-
if (lines.length && lines[0].match(blankLine)) {
|
25
|
-
lines.shift();
|
26
|
-
}
|
27
|
-
|
28
|
-
if (lines.length && lines[lines.length - 1].match(blankLine)) {
|
29
|
-
lines.pop();
|
30
|
-
}
|
31
|
-
|
32
|
-
var minLeadingSpace = lines.reduce(function (acc, line) {
|
33
|
-
if (line.match(blankLine)) {
|
34
|
-
return acc;
|
35
|
-
}
|
36
|
-
|
37
|
-
var leadingWhitespace = line.match(/^(\s*)/);
|
38
|
-
return Math.min(acc, leadingWhitespace ? leadingWhitespace[1].length : 0);
|
39
|
-
}, Infinity);
|
40
|
-
return lines.map(function (line) {
|
41
|
-
if (line.match(blankLine)) {
|
42
|
-
return '';
|
43
|
-
}
|
44
|
-
|
45
|
-
return padding + line.slice(minLeadingSpace);
|
46
|
-
}).join('\n');
|
47
|
-
}
|
48
|
-
|
49
|
-
module.exports = dedent;
|