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,329 +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 oneIndent = '';
|
13
|
-
var newLine = '';
|
14
|
-
|
15
|
-
if (process.env.NODE_ENV !== "production") {
|
16
|
-
oneIndent = ' ';
|
17
|
-
newLine = '\n';
|
18
|
-
}
|
19
|
-
|
20
|
-
var EMPTY_CHILDREN = ' {' + newLine + oneIndent + require("./RelayNodeInterface").TYPENAME + newLine + '}';
|
21
|
-
/**
|
22
|
-
* @internal
|
23
|
-
*
|
24
|
-
* `printRelayOSSQuery(query)` returns a string representation of the query. The
|
25
|
-
* supplied `node` must be flattened (and not contain fragments).
|
26
|
-
*/
|
27
|
-
|
28
|
-
function printRelayOSSQuery(node) {
|
29
|
-
var fragmentTexts = [];
|
30
|
-
var variableMap = new Map();
|
31
|
-
var printerState = {
|
32
|
-
fragmentCount: 0,
|
33
|
-
fragmentNameByHash: {},
|
34
|
-
fragmentNameByText: {},
|
35
|
-
fragmentTexts: fragmentTexts,
|
36
|
-
variableCount: 0,
|
37
|
-
variableMap: variableMap
|
38
|
-
};
|
39
|
-
var queryText = null;
|
40
|
-
|
41
|
-
if (node instanceof require("./RelayQuery").Root) {
|
42
|
-
queryText = printRoot(node, printerState);
|
43
|
-
} else if (node instanceof require("./RelayQuery").Operation) {
|
44
|
-
queryText = printOperation(node, printerState);
|
45
|
-
} else if (node instanceof require("./RelayQuery").Fragment) {
|
46
|
-
queryText = printFragment(node, printerState);
|
47
|
-
} else if (node instanceof require("./RelayQuery").OSSQuery) {
|
48
|
-
queryText = printOSSQuery(node, printerState);
|
49
|
-
}
|
50
|
-
|
51
|
-
!queryText ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'printRelayOSSQuery(): Unsupported node type, got `%s`.', node) : require("fbjs/lib/invariant")(false) : void 0;
|
52
|
-
var variables = {};
|
53
|
-
variableMap.forEach(function (variablesForType) {
|
54
|
-
variablesForType.forEach(function (_ref) {
|
55
|
-
var value = _ref.value,
|
56
|
-
variableID = _ref.variableID;
|
57
|
-
variables[variableID] = value;
|
58
|
-
});
|
59
|
-
});
|
60
|
-
return {
|
61
|
-
text: [queryText].concat(fragmentTexts).join(newLine.length ? newLine : ' '),
|
62
|
-
variables: variables
|
63
|
-
};
|
64
|
-
}
|
65
|
-
/**
|
66
|
-
* Prints a query with (potentially) multiple root fields.
|
67
|
-
*/
|
68
|
-
|
69
|
-
|
70
|
-
function printOSSQuery(query, printerState) {
|
71
|
-
var children = printChildren(query, printerState, oneIndent) || EMPTY_CHILDREN;
|
72
|
-
var directives = printDirectives(query); // Note: variable definitions must be processed *after* traversing children
|
73
|
-
|
74
|
-
var variableDefinitions = printVariableDefinitions(printerState);
|
75
|
-
return 'query ' + query.getName() + variableDefinitions + directives + children;
|
76
|
-
}
|
77
|
-
/**
|
78
|
-
* Prints the output of a classic Relay.QL query.
|
79
|
-
*/
|
80
|
-
|
81
|
-
|
82
|
-
function printRoot(node, printerState) {
|
83
|
-
!!node.getBatchCall() ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'printRelayOSSQuery(): Deferred queries are not supported.') : require("fbjs/lib/invariant")(false) : void 0;
|
84
|
-
var identifyingArg = node.getIdentifyingArg();
|
85
|
-
var identifyingArgName = identifyingArg && identifyingArg.name || null;
|
86
|
-
var identifyingArgType = identifyingArg && identifyingArg.type || null;
|
87
|
-
var identifyingArgValue = identifyingArg && identifyingArg.value || null;
|
88
|
-
var fieldName = node.getFieldName();
|
89
|
-
|
90
|
-
if (identifyingArgValue != null) {
|
91
|
-
!identifyingArgName ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'printRelayOSSQuery(): Expected an argument name for root field `%s`.', fieldName) : require("fbjs/lib/invariant")(false) : void 0;
|
92
|
-
var rootArgString = printArgument(identifyingArgName, identifyingArgValue, identifyingArgType, printerState);
|
93
|
-
|
94
|
-
if (rootArgString) {
|
95
|
-
fieldName += '(' + rootArgString + ')';
|
96
|
-
}
|
97
|
-
} // Note: children must be traversed before printing variable definitions
|
98
|
-
|
99
|
-
|
100
|
-
var children = printChildren(node, printerState, oneIndent);
|
101
|
-
var queryString = node.getName() + printVariableDefinitions(printerState);
|
102
|
-
fieldName += printDirectives(node);
|
103
|
-
|
104
|
-
if (children == null) {
|
105
|
-
return 'query ' + queryString + EMPTY_CHILDREN;
|
106
|
-
}
|
107
|
-
|
108
|
-
return 'query ' + queryString + ' {' + newLine + oneIndent + fieldName + children + newLine + '}';
|
109
|
-
}
|
110
|
-
|
111
|
-
function printOperation(node, printerState) {
|
112
|
-
var operationKind = node instanceof require("./RelayQuery").Mutation ? 'mutation' : 'subscription';
|
113
|
-
var call = node.getCall();
|
114
|
-
var inputString = printArgument(node.getCallVariableName(), call.value, node.getInputType(), printerState);
|
115
|
-
!inputString ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'printRelayOSSQuery(): Expected %s `%s` to have a value for `%s`.', operationKind, node.getName(), node.getCallVariableName()) : require("fbjs/lib/invariant")(false) : void 0; // Note: children must be traversed before printing variable definitions
|
116
|
-
|
117
|
-
var children = printChildren(node, printerState, oneIndent) || EMPTY_CHILDREN;
|
118
|
-
var operationString = node.getName() + printVariableDefinitions(printerState);
|
119
|
-
var fieldName = call.name + '(' + inputString + ')';
|
120
|
-
return operationKind + ' ' + operationString + ' {' + newLine + oneIndent + fieldName + children + newLine + '}';
|
121
|
-
}
|
122
|
-
|
123
|
-
function printVariableDefinitions(_ref2) {
|
124
|
-
var variableMap = _ref2.variableMap;
|
125
|
-
var argStrings = null;
|
126
|
-
variableMap.forEach(function (variablesForType, type) {
|
127
|
-
variablesForType.forEach(function (_ref3) {
|
128
|
-
var variableID = _ref3.variableID;
|
129
|
-
argStrings = argStrings || [];
|
130
|
-
argStrings.push('$' + variableID + ':' + type);
|
131
|
-
});
|
132
|
-
});
|
133
|
-
|
134
|
-
if (argStrings) {
|
135
|
-
return '(' + argStrings.join(',') + ')';
|
136
|
-
}
|
137
|
-
|
138
|
-
return '';
|
139
|
-
}
|
140
|
-
|
141
|
-
function printNonNullType(type) {
|
142
|
-
if (type[type.length - 1] === '!') {
|
143
|
-
return type;
|
144
|
-
}
|
145
|
-
|
146
|
-
return type + '!';
|
147
|
-
}
|
148
|
-
|
149
|
-
var isConditionDirective = function isConditionDirective(directive) {
|
150
|
-
return directive.name === 'include' || directive.name === 'skip';
|
151
|
-
};
|
152
|
-
|
153
|
-
var isNonConditionDirective = function isNonConditionDirective(directive) {
|
154
|
-
return !isConditionDirective(directive);
|
155
|
-
};
|
156
|
-
|
157
|
-
function printFragment(node, printerState) {
|
158
|
-
return 'fragment ' + node.getDebugName() + ' on ' + node.getType() + printDirectivesAndChildren(node, printerState);
|
159
|
-
}
|
160
|
-
|
161
|
-
function printChildren(node, printerState, indent) {
|
162
|
-
var childrenText = [];
|
163
|
-
var children = node.getChildren();
|
164
|
-
var fragments;
|
165
|
-
|
166
|
-
for (var ii = 0; ii < children.length; ii++) {
|
167
|
-
var child = children[ii];
|
168
|
-
|
169
|
-
if (child instanceof require("./RelayQuery").Field) {
|
170
|
-
var fieldText = child.getSchemaName();
|
171
|
-
var fieldCalls = child.getCallsWithValues();
|
172
|
-
|
173
|
-
if (fieldCalls.length) {
|
174
|
-
fieldText = child.getSerializationKey() + ':' + fieldText;
|
175
|
-
var argTexts = [];
|
176
|
-
|
177
|
-
for (var jj = 0; jj < fieldCalls.length; jj++) {
|
178
|
-
var _fieldCalls$jj = fieldCalls[jj],
|
179
|
-
name = _fieldCalls$jj.name,
|
180
|
-
value = _fieldCalls$jj.value;
|
181
|
-
var argText = printArgument(name, value, child.getCallType(name), printerState);
|
182
|
-
|
183
|
-
if (argText) {
|
184
|
-
argTexts.push(argText);
|
185
|
-
}
|
186
|
-
}
|
187
|
-
|
188
|
-
if (argTexts.length) {
|
189
|
-
fieldText += '(' + argTexts.join(',') + ')';
|
190
|
-
}
|
191
|
-
}
|
192
|
-
|
193
|
-
fieldText += printDirectives(child);
|
194
|
-
|
195
|
-
if (child.canHaveSubselections()) {
|
196
|
-
var childText = printChildren(child, printerState, indent + oneIndent);
|
197
|
-
|
198
|
-
if (childText != null) {
|
199
|
-
fieldText += childText;
|
200
|
-
childrenText.push(fieldText);
|
201
|
-
}
|
202
|
-
} else {
|
203
|
-
childrenText.push(fieldText);
|
204
|
-
}
|
205
|
-
} else if (child instanceof require("./RelayQuery").Fragment) {
|
206
|
-
if (child.getChildren().length) {
|
207
|
-
var fragmentNameByHash = printerState.fragmentNameByHash,
|
208
|
-
fragmentNameByText = printerState.fragmentNameByText,
|
209
|
-
fragmentTexts = printerState.fragmentTexts; // Avoid walking fragments if we have printed the same one before.
|
210
|
-
|
211
|
-
var _fragmentHash = child.getCompositeHash();
|
212
|
-
|
213
|
-
var fragmentName = void 0;
|
214
|
-
|
215
|
-
if (fragmentNameByHash.hasOwnProperty(_fragmentHash)) {
|
216
|
-
fragmentName = fragmentNameByHash[_fragmentHash];
|
217
|
-
} else {
|
218
|
-
// Avoid reprinting a fragment that is identical to another fragment.
|
219
|
-
var _fragmentText = child.getType() + printDirectivesAndChildren(child, printerState);
|
220
|
-
|
221
|
-
if (fragmentNameByText.hasOwnProperty(_fragmentText)) {
|
222
|
-
fragmentName = fragmentNameByText[_fragmentText];
|
223
|
-
} else {
|
224
|
-
fragmentName = 'F' + require("fbjs/lib/base62")(printerState.fragmentCount++);
|
225
|
-
fragmentNameByHash[_fragmentHash] = fragmentName;
|
226
|
-
fragmentNameByText[_fragmentText] = fragmentName;
|
227
|
-
fragmentTexts.push('fragment ' + fragmentName + ' on ' + _fragmentText);
|
228
|
-
}
|
229
|
-
}
|
230
|
-
|
231
|
-
if (!fragments || !fragments.hasOwnProperty(fragmentName)) {
|
232
|
-
fragments = fragments || {};
|
233
|
-
fragments[fragmentName] = true;
|
234
|
-
childrenText.push('...' + fragmentName);
|
235
|
-
}
|
236
|
-
}
|
237
|
-
} else {
|
238
|
-
!false ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'printRelayOSSQuery(): Expected a field or fragment, got `%s`.', child.constructor.name) : require("fbjs/lib/invariant")(false) : void 0;
|
239
|
-
}
|
240
|
-
}
|
241
|
-
|
242
|
-
if (!childrenText.length) {
|
243
|
-
return null;
|
244
|
-
}
|
245
|
-
|
246
|
-
return ' {' + newLine + indent + oneIndent + childrenText.join(',' + newLine + indent + oneIndent) + newLine + indent + '}';
|
247
|
-
}
|
248
|
-
|
249
|
-
function printDirectives(node, filter) {
|
250
|
-
var directiveStrings;
|
251
|
-
node.getDirectives().forEach(function (directive) {
|
252
|
-
if (filter && !filter(directive)) {
|
253
|
-
return;
|
254
|
-
}
|
255
|
-
|
256
|
-
var dirString = '@' + directive.name;
|
257
|
-
|
258
|
-
if (directive.args.length) {
|
259
|
-
dirString += '(' + directive.args.map(printDirectiveArg).join(',') + ')';
|
260
|
-
}
|
261
|
-
|
262
|
-
directiveStrings = directiveStrings || [];
|
263
|
-
directiveStrings.push(dirString);
|
264
|
-
});
|
265
|
-
|
266
|
-
if (!directiveStrings) {
|
267
|
-
return '';
|
268
|
-
}
|
269
|
-
|
270
|
-
return ' ' + directiveStrings.join(' ');
|
271
|
-
}
|
272
|
-
|
273
|
-
function printDirectiveArg(_ref4) {
|
274
|
-
var name = _ref4.name,
|
275
|
-
value = _ref4.value;
|
276
|
-
!(typeof value === 'boolean' || typeof value === 'number' || typeof value === 'string') ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'printRelayOSSQuery(): Relay only supports directives with scalar values ' + '(boolean, number, or string), got `%s: %s`.', name, value) : require("fbjs/lib/invariant")(false) : void 0;
|
277
|
-
return name + ':' + JSON.stringify(value);
|
278
|
-
}
|
279
|
-
|
280
|
-
function printDirectivesAndChildren(node, printerState) {
|
281
|
-
var conditionDirectives = printDirectives(node, isConditionDirective);
|
282
|
-
var otherDirectives = printDirectives(node, isNonConditionDirective);
|
283
|
-
return otherDirectives + (conditionDirectives ? ' {' + newLine + oneIndent + '...' + conditionDirectives + require("nullthrows")(printChildren(node, printerState, oneIndent)) + newLine + '}' : require("nullthrows")(printChildren(node, printerState, '')));
|
284
|
-
}
|
285
|
-
|
286
|
-
function printArgument(name, value, type, printerState) {
|
287
|
-
if (value == null) {
|
288
|
-
return value;
|
289
|
-
}
|
290
|
-
|
291
|
-
var stringValue;
|
292
|
-
|
293
|
-
if (type != null) {
|
294
|
-
var variableID = createVariable(name, value, type, printerState);
|
295
|
-
stringValue = '$' + variableID;
|
296
|
-
} else {
|
297
|
-
stringValue = JSON.stringify(value);
|
298
|
-
}
|
299
|
-
|
300
|
-
return name + ':' + stringValue;
|
301
|
-
}
|
302
|
-
|
303
|
-
function createVariable(name, value, type, printerState) {
|
304
|
-
!(value != null) ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'printRelayOSSQuery: Expected a non-null value for variable `%s`.', name) : require("fbjs/lib/invariant")(false) : void 0;
|
305
|
-
var valueKey = JSON.stringify(value);
|
306
|
-
var nonNullType = printNonNullType(type);
|
307
|
-
var variablesForType = printerState.variableMap.get(nonNullType);
|
308
|
-
|
309
|
-
if (!variablesForType) {
|
310
|
-
variablesForType = new Map();
|
311
|
-
printerState.variableMap.set(nonNullType, variablesForType);
|
312
|
-
}
|
313
|
-
|
314
|
-
var existingVariable = variablesForType.get(valueKey);
|
315
|
-
|
316
|
-
if (existingVariable) {
|
317
|
-
return existingVariable.variableID;
|
318
|
-
} else {
|
319
|
-
var variableID = name + '_' + require("fbjs/lib/base62")(printerState.variableCount++);
|
320
|
-
|
321
|
-
variablesForType.set(valueKey, {
|
322
|
-
value: value,
|
323
|
-
variableID: variableID
|
324
|
-
});
|
325
|
-
return variableID;
|
326
|
-
}
|
327
|
-
}
|
328
|
-
|
329
|
-
module.exports = require("relay-runtime").RelayProfiler.instrument('printRelayQuery', printRelayOSSQuery);
|
package/lib/printRelayQuery.js
DELETED
@@ -1,26 +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
|
-
/**
|
13
|
-
* To support legacy behavior, allow the classic relay printer to be injectable.
|
14
|
-
* Requiring printRelayOSSQuery directly guarantees printing with modern GraphQL
|
15
|
-
* (circa 2015+) syntax, while using this module may use an injected
|
16
|
-
* implementation which can introduce printing legacy GraphQL syntax.
|
17
|
-
*/
|
18
|
-
var printRelayQueryImpl = require("./printRelayOSSQuery");
|
19
|
-
|
20
|
-
module.exports = function printRelayQuery(node) {
|
21
|
-
return printRelayQueryImpl(node);
|
22
|
-
};
|
23
|
-
|
24
|
-
module.exports.injectImpl = function injectImpl(impl) {
|
25
|
-
printRelayQueryImpl = impl;
|
26
|
-
};
|
@@ -1,25 +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
|
-
/**
|
13
|
-
* @internal
|
14
|
-
*
|
15
|
-
* A map from developer-friendly operation names ("append", "prepend", "remove")
|
16
|
-
* to internal book-keeping keys used to store metadata on records
|
17
|
-
* ("__rangeOperationAppend__" etc).
|
18
|
-
*/
|
19
|
-
var rangeOperationToMetadataKey = {};
|
20
|
-
rangeOperationToMetadataKey[require("relay-runtime").RangeOperations.APPEND] = '__rangeOperationAppend__';
|
21
|
-
rangeOperationToMetadataKey[require("relay-runtime").RangeOperations.IGNORE] = '__rangeOperationIgnore__';
|
22
|
-
rangeOperationToMetadataKey[require("relay-runtime").RangeOperations.PREPEND] = '__rangeOperationPrepend__';
|
23
|
-
rangeOperationToMetadataKey[require("relay-runtime").RangeOperations.REFETCH] = '__rangeOperationRefetch__';
|
24
|
-
rangeOperationToMetadataKey[require("relay-runtime").RangeOperations.REMOVE] = '__rangeOperationRemove__';
|
25
|
-
module.exports = Object.freeze(rangeOperationToMetadataKey);
|