relay-compiler 1.3.0 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE +16 -26
- package/bin/relay-compiler +7348 -5939
- package/index.js +3 -6
- package/lib/{FileParser.js → ASTCache.js} +17 -14
- package/lib/ASTConvert.js +84 -70
- package/lib/CodegenDirectory.js +122 -28
- package/lib/{RelayCodegenRunner.js → CodegenRunner.js} +110 -186
- package/lib/CodegenTypes.js +12 -0
- package/lib/{RelayCodegenWatcher.js → CodegenWatcher.js} +53 -43
- package/lib/DefaultHandleKey.js +2 -4
- package/lib/DotGraphQLParser.js +27 -0
- package/lib/FilterDirectivesTransform.js +11 -11
- package/lib/FindGraphQLTags.js +33 -52
- package/lib/FlattenTransform.js +197 -0
- package/lib/GraphQLCompilerContext.js +158 -0
- package/lib/GraphQLCompilerProfiler.js +271 -0
- package/lib/GraphQLCompilerPublic.js +27 -22
- package/lib/GraphQLCompilerUserError.js +26 -0
- package/lib/GraphQLConsoleReporter.js +58 -0
- package/lib/GraphQLIR.js +12 -0
- package/lib/{RelayPrinter.js → GraphQLIRPrinter.js} +42 -38
- package/lib/{RelayIRTransformer.js → GraphQLIRTransformer.js} +47 -38
- package/lib/GraphQLIRTransforms.js +6 -15
- package/lib/{RelayIRVisitor.js → GraphQLIRVisitor.js} +7 -6
- package/lib/GraphQLMultiReporter.js +50 -0
- package/lib/GraphQLParser.js +743 -0
- package/lib/GraphQLReporter.js +12 -0
- package/lib/GraphQLSchemaUtils.js +10 -36
- package/lib/GraphQLValidator.js +13 -15
- package/lib/{RelayWatchmanClient.js → GraphQLWatchmanClient.js} +15 -17
- package/lib/InlineFragmentsTransform.js +48 -0
- package/lib/PatchedBabelGenerator.js +58 -0
- package/lib/RelayApplyFragmentArgumentTransform.js +37 -18
- package/lib/RelayCodeGenerator.js +130 -60
- package/lib/RelayCompilerBin.js +80 -35
- package/lib/RelayCompilerCache.js +18 -11
- package/lib/RelayCompilerPublic.js +24 -10
- package/lib/RelayCompilerScope.js +2 -4
- package/lib/RelayConcreteNode.js +31 -14
- package/lib/RelayConnectionConstants.js +2 -4
- package/lib/RelayConnectionTransform.js +34 -38
- package/lib/RelayDefaultHandleKey.js +2 -4
- package/lib/RelayDeferrableFragmentTransform.js +464 -0
- package/lib/RelayError.js +2 -6
- package/lib/RelayFieldHandleTransform.js +15 -11
- package/lib/RelayFileWriter.js +119 -98
- package/lib/RelayFlowBabelFactories.js +113 -0
- package/lib/RelayFlowGenerator.js +180 -200
- package/lib/RelayFlowTypeTransformers.js +109 -0
- package/lib/RelayGenerateIDFieldTransform.js +131 -0
- package/lib/RelayGenerateTypeNameTransform.js +75 -0
- package/lib/RelayGraphQLEnumsGenerator.js +65 -0
- package/lib/RelayIRTransforms.js +19 -23
- package/lib/RelayInternalTypes.js +2 -5
- package/lib/RelayInternals.js +2 -5
- package/lib/RelayJSModuleParser.js +64 -0
- package/lib/RelayMaskTransform.js +129 -0
- package/lib/RelayMetricsRecorder.js +9 -9
- package/lib/RelayMockRenderer.js +3 -8
- package/lib/RelayNetworkDebug.js +4 -7
- package/lib/RelayParser.js +28 -645
- package/lib/RelayProfiler.js +7 -7
- package/lib/RelayQueryCaching.js +2 -5
- package/lib/RelayRelayDirectiveTransform.js +47 -33
- package/lib/RelayRuntimeTypes.js +22 -0
- package/lib/RelayShallowMock.js +4 -7
- package/lib/RelaySkipHandleFieldTransform.js +13 -11
- package/lib/RelayTaskQueue.js +2 -5
- package/lib/RelayTransformUtils.js +20 -0
- package/lib/RelayTypes.js +2 -5
- package/lib/RelayValidator.js +9 -8
- package/lib/RelayViewerHandleTransform.js +22 -18
- package/lib/SkipClientFieldTransform.js +36 -53
- package/lib/SkipRedundantNodesTransform.js +22 -29
- package/lib/SkipUnreachableNodeTransform.js +57 -36
- package/lib/SourceControl.js +61 -0
- package/lib/StripUnusedVariablesTransform.js +86 -41
- package/lib/areEqualOSS.js +2 -4
- package/lib/compileRelayArtifacts.js +72 -0
- package/lib/dedent.js +2 -5
- package/lib/dedupeJSONStringify.js +132 -0
- package/lib/deepFreeze.js +3 -5
- package/lib/deepMergeAssignments.js +68 -0
- package/lib/filterContextForNode.js +5 -7
- package/lib/formatGeneratedModule.js +5 -9
- package/lib/{getIdentifierForRelayArgumentValue.js → getIdentifierForArgumentValue.js} +8 -10
- package/lib/getIdentifierForSelection.js +37 -0
- package/lib/getLiteralArgumentValues.js +26 -0
- package/lib/getModuleName.js +2 -4
- package/lib/getRelayHandleKey.js +2 -4
- package/lib/isCompatibleRelayFragmentType.js +2 -5
- package/lib/isEquivalentType.js +55 -0
- package/lib/isPromise.js +2 -5
- package/lib/isScalarAndEqual.js +3 -5
- package/lib/murmurHash.js +2 -4
- package/lib/nullthrowsOSS.js +7 -5
- package/lib/recycleNodesInto.js +2 -4
- package/lib/relayUnstableBatchedUpdates.js +2 -5
- package/lib/relayUnstableBatchedUpdates.native.js +2 -5
- package/lib/requestsForOperation.js +75 -0
- package/lib/simpleClone.js +2 -4
- package/lib/stableCopy.js +35 -0
- package/lib/testEditDistance.js +2 -5
- package/lib/throwFailedPromise.js +2 -5
- package/lib/writeRelayGeneratedFile.js +84 -50
- package/package.json +16 -15
- package/relay-compiler.js +7208 -5872
- package/relay-compiler.min.js +7200 -5867
- package/ARCHITECTURE.md +0 -94
- package/PATENTS +0 -33
- package/lib/AutoAliasTransform.js +0 -80
- package/lib/GraphQLFileParser.js +0 -27
- package/lib/GraphQLTextParser.js +0 -46
- package/lib/RelayCodegenTypes.js +0 -14
- package/lib/RelayCompiledTypes.js +0 -13
- package/lib/RelayCompiler.js +0 -144
- package/lib/RelayCompilerContext.js +0 -133
- package/lib/RelayCompilerUserError.js +0 -30
- package/lib/RelayConsoleReporter.js +0 -40
- package/lib/RelayFileIRParser.js +0 -66
- package/lib/RelayFlattenTransform.js +0 -278
- package/lib/RelayFlowParser.js +0 -188
- package/lib/RelayGenerateRequisiteFieldsTransform.js +0 -189
- package/lib/RelayIR.js +0 -14
- package/lib/RelayMultiReporter.js +0 -40
- package/lib/RelayReporter.js +0 -14
- package/lib/RelayTestSchema.js +0 -21
- package/lib/formatStorageKey.js +0 -37
- package/lib/getIdentifierForRelaySelection.js +0 -54
- package/lib/getRelayLiteralArgumentValues.js +0 -28
- package/lib/parseGraphQLText.js +0 -33
- package/lib/prettyStringify.js +0 -35
- package/lib/printFlowTypes.js +0 -282
- package/lib/stableJSONStringify.js +0 -45
- package/lib/stableJSONStringifyOSS.js +0 -44
- package/lib/transformInputObjectToIR.js +0 -85
- package/lib/writeLegacyFlowFile.js +0 -24
@@ -1,13 +1,11 @@
|
|
1
1
|
/**
|
2
2
|
* Copyright (c) 2013-present, Facebook, Inc.
|
3
|
-
* All rights reserved.
|
4
3
|
*
|
5
|
-
* This source code is licensed under the
|
6
|
-
* LICENSE file in the root directory of this source tree.
|
7
|
-
* of patent rights can be found in the PATENTS file in the same directory.
|
4
|
+
* This source code is licensed under the MIT license found in the
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
8
6
|
*
|
9
7
|
*
|
10
|
-
* @providesModule
|
8
|
+
* @providesModule GraphQLIRPrinter
|
11
9
|
* @format
|
12
10
|
*/
|
13
11
|
|
@@ -25,7 +23,7 @@ var _require2 = require('graphql'),
|
|
25
23
|
var INDENT = ' ';
|
26
24
|
|
27
25
|
/**
|
28
|
-
* Converts a
|
26
|
+
* Converts a GraphQLIR node into a GraphQL string. Custom Relay
|
29
27
|
* extensions (directives) are not supported; to print fragments with
|
30
28
|
* variables or fragment spreads with arguments, transform the node
|
31
29
|
* prior to printing.
|
@@ -36,7 +34,7 @@ function print(node) {
|
|
36
34
|
} else if (node.kind === 'Root') {
|
37
35
|
return node.operation + ' ' + node.name + printArgumentDefinitions(node.argumentDefinitions) + printDirectives(node.directives) + printSelections(node, '') + '\n';
|
38
36
|
} else {
|
39
|
-
require('fbjs/lib/invariant')(false, '
|
37
|
+
require('fbjs/lib/invariant')(false, 'GraphQLIRPrinter: Unsupported IR node `%s`.', node.kind);
|
40
38
|
}
|
41
39
|
}
|
42
40
|
|
@@ -51,42 +49,39 @@ function printSelections(node, indent, parentCondition) {
|
|
51
49
|
return printed.length ? ' {\n' + (indent + INDENT) + printed.join('\n' + indent + INDENT) + '\n' + indent + '}' : '';
|
52
50
|
}
|
53
51
|
|
52
|
+
/**
|
53
|
+
* Prints a field without subselections.
|
54
|
+
*/
|
55
|
+
function printField(field) {
|
56
|
+
var parentCondition = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
57
|
+
|
58
|
+
return (field.alias != null ? field.alias + ': ' + field.name : field.name) + printArguments(field.args) + parentCondition + printDirectives(field.directives) + printHandles(field);
|
59
|
+
}
|
60
|
+
|
54
61
|
function printSelection(selection, indent, parentCondition) {
|
55
62
|
parentCondition = parentCondition || '';
|
56
|
-
var str =
|
63
|
+
var str = void 0;
|
57
64
|
if (selection.kind === 'LinkedField') {
|
58
|
-
|
59
|
-
str += selection.alias + ': ';
|
60
|
-
}
|
61
|
-
str += selection.name;
|
62
|
-
str += printArguments(selection.args);
|
63
|
-
str += parentCondition;
|
64
|
-
str += printDirectives(selection.directives);
|
65
|
-
str += printHandles(selection);
|
65
|
+
str = printField(selection, parentCondition);
|
66
66
|
str += printSelections(selection, indent + INDENT);
|
67
67
|
} else if (selection.kind === 'ScalarField') {
|
68
|
-
|
69
|
-
str += selection.alias + ': ';
|
70
|
-
}
|
71
|
-
str += selection.name;
|
72
|
-
str += printArguments(selection.args);
|
73
|
-
str += parentCondition;
|
74
|
-
str += printDirectives(selection.directives);
|
75
|
-
str += printHandles(selection);
|
68
|
+
str = printField(selection, parentCondition);
|
76
69
|
} else if (selection.kind === 'InlineFragment') {
|
77
|
-
str
|
70
|
+
str = '... on ' + selection.typeCondition.toString();
|
78
71
|
str += parentCondition;
|
79
72
|
str += printDirectives(selection.directives);
|
80
73
|
str += printSelections(selection, indent + INDENT);
|
81
74
|
} else if (selection.kind === 'FragmentSpread') {
|
82
|
-
str
|
75
|
+
str = '...' + selection.name;
|
83
76
|
str += parentCondition;
|
84
77
|
str += printFragmentArguments(selection.args);
|
85
78
|
str += printDirectives(selection.directives);
|
79
|
+
} else if (selection.kind === 'DeferrableFragmentSpread') {
|
80
|
+
str = selection.alias + ': ' + selection.storageKey;
|
86
81
|
} else if (selection.kind === 'Condition') {
|
87
82
|
var value = printValue(selection.condition);
|
88
83
|
// For Flow
|
89
|
-
require('fbjs/lib/invariant')(value != null, '
|
84
|
+
require('fbjs/lib/invariant')(value != null, 'GraphQLIRPrinter: Expected a variable for condition, got a literal `null`.');
|
90
85
|
var condStr = selection.passingValue ? ' @include' : ' @skip';
|
91
86
|
condStr += '(if: ' + value + ')';
|
92
87
|
condStr += parentCondition;
|
@@ -94,9 +89,9 @@ function printSelection(selection, indent, parentCondition) {
|
|
94
89
|
var subSelections = selection.selections.map(function (sel) {
|
95
90
|
return printSelection(sel, indent, condStr);
|
96
91
|
});
|
97
|
-
str
|
92
|
+
str = subSelections.join('\n' + INDENT);
|
98
93
|
} else {
|
99
|
-
require('fbjs/lib/invariant')(false, '
|
94
|
+
require('fbjs/lib/invariant')(false, 'GraphQLIRPrinter: Unknown selection kind `%s`.', selection.kind);
|
100
95
|
}
|
101
96
|
return str;
|
102
97
|
}
|
@@ -169,10 +164,13 @@ function printArguments(args) {
|
|
169
164
|
}
|
170
165
|
|
171
166
|
function printValue(value, type) {
|
167
|
+
if (type instanceof GraphQLNonNull) {
|
168
|
+
type = type.ofType;
|
169
|
+
}
|
172
170
|
if (value.kind === 'Variable') {
|
173
171
|
return '$' + value.variableName;
|
174
172
|
} else if (value.kind === 'ObjectValue') {
|
175
|
-
require('fbjs/lib/invariant')(type instanceof GraphQLInputObjectType, '
|
173
|
+
require('fbjs/lib/invariant')(type instanceof GraphQLInputObjectType, 'GraphQLIRPrinter: Need an InputObject type to print objects.');
|
176
174
|
|
177
175
|
var typeFields = type.getFields();
|
178
176
|
var pairs = value.fields.map(function (field) {
|
@@ -182,7 +180,7 @@ function printValue(value, type) {
|
|
182
180
|
|
183
181
|
return '{' + pairs.join(', ') + '}';
|
184
182
|
} else if (value.kind === 'ListValue') {
|
185
|
-
require('fbjs/lib/invariant')(type instanceof GraphQLList, '
|
183
|
+
require('fbjs/lib/invariant')(type instanceof GraphQLList, 'GraphQLIRPrinter: Need a type in order to print arrays.');
|
186
184
|
var innerType = type.ofType;
|
187
185
|
return '[' + value.items.map(function (i) {
|
188
186
|
return printValue(i, innerType);
|
@@ -199,26 +197,32 @@ function printLiteral(value, type) {
|
|
199
197
|
type = type.ofType;
|
200
198
|
}
|
201
199
|
if (type instanceof GraphQLEnumType) {
|
202
|
-
require('fbjs/lib/invariant')(typeof value === 'string', '
|
200
|
+
require('fbjs/lib/invariant')(typeof value === 'string', 'GraphQLIRPrinter: Expected value of type %s to be a string, got `%s`.', type.name, value);
|
203
201
|
return value;
|
204
202
|
}
|
205
203
|
if (Array.isArray(value)) {
|
206
|
-
require('fbjs/lib/invariant')(type instanceof GraphQLList, '
|
204
|
+
require('fbjs/lib/invariant')(type instanceof GraphQLList, 'GraphQLIRPrinter: Need a type in order to print arrays.');
|
207
205
|
var itemType = type.ofType;
|
208
206
|
return '[' + value.map(function (item) {
|
209
207
|
return printLiteral(item, itemType);
|
210
208
|
}).join(', ') + ']';
|
211
209
|
} else if (typeof value === 'object' && value) {
|
212
210
|
var fields = [];
|
213
|
-
require('fbjs/lib/invariant')(type instanceof GraphQLInputObjectType, '
|
211
|
+
require('fbjs/lib/invariant')(type instanceof GraphQLInputObjectType, 'GraphQLIRPrinter: Need an InputObject type to print objects.');
|
214
212
|
var typeFields = type.getFields();
|
215
|
-
|
216
|
-
|
217
|
-
|
213
|
+
for (var key in value) {
|
214
|
+
if (value.hasOwnProperty(key)) {
|
215
|
+
fields.push(key + ': ' + printLiteral(value[key], typeFields[key].type));
|
216
|
+
}
|
217
|
+
}
|
218
218
|
return '{' + fields.join(', ') + '}';
|
219
|
+
} else if (type instanceof GraphQLList && value != null) {
|
220
|
+
// Not an array, but still a list. Treat as list-of-one as per spec 3.1.7:
|
221
|
+
// http://facebook.github.io/graphql/October2016/#sec-Lists
|
222
|
+
return printLiteral(value, type.ofType);
|
219
223
|
} else {
|
220
224
|
return JSON.stringify(value);
|
221
225
|
}
|
222
226
|
}
|
223
227
|
|
224
|
-
module.exports = { print: print };
|
228
|
+
module.exports = { print: print, printField: printField, printArguments: printArguments, printDirectives: printDirectives };
|
@@ -1,12 +1,10 @@
|
|
1
1
|
/**
|
2
2
|
* Copyright (c) 2013-present, Facebook, Inc.
|
3
|
-
* All rights reserved.
|
4
3
|
*
|
5
|
-
* This source code is licensed under the
|
6
|
-
* LICENSE file in the root directory of this source tree.
|
7
|
-
* of patent rights can be found in the PATENTS file in the same directory.
|
4
|
+
* This source code is licensed under the MIT license found in the
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
8
6
|
*
|
9
|
-
* @providesModule
|
7
|
+
* @providesModule GraphQLIRTransformer
|
10
8
|
*
|
11
9
|
* @format
|
12
10
|
*/
|
@@ -36,21 +34,17 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'd
|
|
36
34
|
* If a visitor function is *not* defined for a kind, a default traversal is
|
37
35
|
* used to evaluate its children.
|
38
36
|
*
|
39
|
-
* The `stateInitializer` argument accepts
|
40
|
-
* each document (fragment or root) in the context. Any documents for
|
41
|
-
* initializer returns null/undefined is deleted from the context
|
42
|
-
* traversed.
|
37
|
+
* The `stateInitializer` argument accepts an optional function to construct the
|
38
|
+
* state for each document (fragment or root) in the context. Any documents for
|
39
|
+
* which the initializer returns null/undefined is deleted from the context
|
40
|
+
* without being traversed.
|
43
41
|
*
|
44
42
|
* Example: Alias all scalar fields with the reverse of their name:
|
45
43
|
*
|
46
44
|
* ```
|
47
|
-
* transform(
|
48
|
-
*
|
49
|
-
*
|
50
|
-
* ScalarField: visitScalarField,
|
51
|
-
* },
|
52
|
-
* () => ({}) // dummy non-null state
|
53
|
-
* );
|
45
|
+
* transform(context, {
|
46
|
+
* ScalarField: visitScalarField,
|
47
|
+
* });
|
54
48
|
*
|
55
49
|
* function visitScalarField(field: ScalarField, state: State): ?ScalarField {
|
56
50
|
* // Traverse child nodes - for a scalar field these are the arguments &
|
@@ -66,21 +60,25 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'd
|
|
66
60
|
*/
|
67
61
|
function transform(context, visitor, stateInitializer) {
|
68
62
|
var transformer = new Transformer(context, visitor);
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
63
|
+
return context.withMutations(function (nextContext) {
|
64
|
+
context.forEachDocument(function (prevNode) {
|
65
|
+
var nextNode = void 0;
|
66
|
+
if (stateInitializer === undefined) {
|
67
|
+
nextNode = transformer.visit(prevNode, undefined);
|
68
|
+
} else {
|
69
|
+
var _state = stateInitializer(prevNode);
|
70
|
+
if (_state != null) {
|
71
|
+
nextNode = transformer.visit(prevNode, _state);
|
72
|
+
}
|
73
|
+
}
|
74
|
+
if (!nextNode) {
|
75
|
+
nextContext = nextContext.remove(prevNode.name);
|
76
|
+
} else if (nextNode !== prevNode) {
|
77
|
+
nextContext = nextContext.replace(nextNode);
|
78
|
+
}
|
79
|
+
});
|
80
|
+
return nextContext;
|
82
81
|
});
|
83
|
-
return nextContext;
|
84
82
|
}
|
85
83
|
|
86
84
|
/**
|
@@ -150,8 +148,8 @@ var Transformer = function () {
|
|
150
148
|
if (nodeVisitor) {
|
151
149
|
// If a handler for the kind is defined, it is responsible for calling
|
152
150
|
// `traverse` to transform children as necessary.
|
153
|
-
var
|
154
|
-
var nextNode = nodeVisitor.call(this, node,
|
151
|
+
var _state2 = this._getState();
|
152
|
+
var nextNode = nodeVisitor.call(this, node, _state2);
|
155
153
|
return nextNode;
|
156
154
|
}
|
157
155
|
// Otherwise traverse is called automatically.
|
@@ -164,6 +162,9 @@ var Transformer = function () {
|
|
164
162
|
case 'Argument':
|
165
163
|
nextNode = this._traverseChildren(prevNode, null, ['value']);
|
166
164
|
break;
|
165
|
+
case 'Batch':
|
166
|
+
nextNode = this._traverseChildren(prevNode, ['requests'], ['fragment']);
|
167
|
+
break;
|
167
168
|
case 'Literal':
|
168
169
|
case 'LocalArgumentDefinition':
|
169
170
|
case 'RootArgumentDefinition':
|
@@ -193,21 +194,29 @@ var Transformer = function () {
|
|
193
194
|
nextNode = this._traverseChildren(prevNode, ['fields']);
|
194
195
|
break;
|
195
196
|
case 'Condition':
|
197
|
+
nextNode = this._traverseChildren(prevNode, ['directives', 'selections'], ['condition']);
|
198
|
+
if (!nextNode.selections.length) {
|
199
|
+
nextNode = null;
|
200
|
+
}
|
201
|
+
break;
|
196
202
|
case 'InlineFragment':
|
197
203
|
nextNode = this._traverseChildren(prevNode, ['directives', 'selections']);
|
198
204
|
if (!nextNode.selections.length) {
|
199
205
|
nextNode = null;
|
200
206
|
}
|
201
207
|
break;
|
208
|
+
case 'DeferrableFragmentSpread':
|
209
|
+
nextNode = this._traverseChildren(prevNode, ['args', 'fragmentArgs', 'directives']);
|
210
|
+
break;
|
202
211
|
case 'Fragment':
|
203
212
|
case 'Root':
|
204
213
|
nextNode = this._traverseChildren(prevNode, ['argumentDefinitions', 'directives', 'selections']);
|
205
|
-
|
206
|
-
|
207
|
-
|
214
|
+
break;
|
215
|
+
case 'Request':
|
216
|
+
nextNode = this._traverseChildren(prevNode, null, ['root']);
|
208
217
|
break;
|
209
218
|
default:
|
210
|
-
require('fbjs/lib/invariant')(false, '
|
219
|
+
require('fbjs/lib/invariant')(false, 'GraphQLIRTransformer: Unknown kind `%s`.', prevNode.kind);
|
211
220
|
}
|
212
221
|
return nextNode;
|
213
222
|
};
|
@@ -221,7 +230,7 @@ var Transformer = function () {
|
|
221
230
|
if (!prevItems) {
|
222
231
|
return;
|
223
232
|
}
|
224
|
-
require('fbjs/lib/invariant')(Array.isArray(prevItems), '
|
233
|
+
require('fbjs/lib/invariant')(Array.isArray(prevItems), 'GraphQLIRTransformer: Expected data for `%s` to be an array, got `%s`.', key, prevItems);
|
225
234
|
var nextItems = _this._map(prevItems);
|
226
235
|
if (nextNode || nextItems !== prevItems) {
|
227
236
|
nextNode = nextNode || (0, _extends3['default'])({}, prevNode);
|
@@ -259,7 +268,7 @@ var Transformer = function () {
|
|
259
268
|
};
|
260
269
|
|
261
270
|
Transformer.prototype._getState = function _getState() {
|
262
|
-
require('fbjs/lib/invariant')(this._states.length, '
|
271
|
+
require('fbjs/lib/invariant')(this._states.length, 'GraphQLIRTransformer: Expected a current state to be set but found none. ' + 'This is usually the result of mismatched number of pushState()/popState() ' + 'calls.');
|
263
272
|
return this._states[this._states.length - 1];
|
264
273
|
};
|
265
274
|
|
@@ -1,10 +1,8 @@
|
|
1
1
|
/**
|
2
2
|
* Copyright (c) 2013-present, Facebook, Inc.
|
3
|
-
* All rights reserved.
|
4
3
|
*
|
5
|
-
* This source code is licensed under the
|
6
|
-
* LICENSE file in the root directory of this source tree.
|
7
|
-
* of patent rights can be found in the PATENTS file in the same directory.
|
4
|
+
* This source code is licensed under the MIT license found in the
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
8
6
|
*
|
9
7
|
* @providesModule GraphQLIRTransforms
|
10
8
|
*
|
@@ -14,23 +12,16 @@
|
|
14
12
|
'use strict';
|
15
13
|
|
16
14
|
// Transforms applied to fragments used for reading data from a store
|
17
|
-
var FRAGMENT_TRANSFORMS = [
|
18
|
-
return require('./RelayFlattenTransform').transform(ctx, {
|
19
|
-
flattenAbstractTypes: true
|
20
|
-
});
|
21
|
-
}, require('./SkipRedundantNodesTransform').transform];
|
15
|
+
var FRAGMENT_TRANSFORMS = [require('./FlattenTransform').transformWithOptions({ flattenAbstractTypes: true }), require('./SkipRedundantNodesTransform').transform];
|
22
16
|
|
23
17
|
// Transforms applied to queries/mutations/subscriptions that are used for
|
24
18
|
// fetching data from the server and parsing those responses.
|
25
19
|
var QUERY_TRANSFORMS = [require('./SkipClientFieldTransform').transform, require('./SkipUnreachableNodeTransform').transform];
|
26
20
|
|
27
21
|
// Transforms applied to the code used to process a query response.
|
28
|
-
var CODEGEN_TRANSFORMS = [
|
29
|
-
|
30
|
-
|
31
|
-
flattenFragmentSpreads: true
|
32
|
-
});
|
33
|
-
}, require('./SkipRedundantNodesTransform').transform, require('./FilterDirectivesTransform').transform];
|
22
|
+
var CODEGEN_TRANSFORMS = [require('./InlineFragmentsTransform').transform, require('./FlattenTransform').transformWithOptions({
|
23
|
+
flattenAbstractTypes: true
|
24
|
+
}), require('./SkipRedundantNodesTransform').transform, require('./FilterDirectivesTransform').transform];
|
34
25
|
|
35
26
|
module.exports = {
|
36
27
|
codegenTransforms: CODEGEN_TRANSFORMS,
|
@@ -1,12 +1,10 @@
|
|
1
1
|
/**
|
2
2
|
* Copyright (c) 2013-present, Facebook, Inc.
|
3
|
-
* All rights reserved.
|
4
3
|
*
|
5
|
-
* This source code is licensed under the
|
6
|
-
* LICENSE file in the root directory of this source tree.
|
7
|
-
* of patent rights can be found in the PATENTS file in the same directory.
|
4
|
+
* This source code is licensed under the MIT license found in the
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
8
6
|
*
|
9
|
-
* @providesModule
|
7
|
+
* @providesModule GraphQLIRVisitor
|
10
8
|
*
|
11
9
|
* @format
|
12
10
|
*/
|
@@ -16,6 +14,7 @@ var visit = require('graphql').visit;
|
|
16
14
|
|
17
15
|
var NodeKeys = {
|
18
16
|
Argument: ['value'],
|
17
|
+
Batch: ['requests', 'fragment'],
|
19
18
|
Condition: ['condition', 'selections'],
|
20
19
|
Directive: ['args'],
|
21
20
|
Fragment: ['argumentDefinitions', 'directives', 'selections'],
|
@@ -24,10 +23,12 @@ var NodeKeys = {
|
|
24
23
|
LinkedField: ['args', 'directives', 'selections'],
|
25
24
|
Literal: [],
|
26
25
|
LocalArgumentDefinition: [],
|
26
|
+
Request: ['root'],
|
27
27
|
Root: ['argumentDefinitions', 'directives', 'selections'],
|
28
28
|
RootArgumentDefinition: [],
|
29
29
|
ScalarField: ['args', 'directives'],
|
30
|
-
Variable: []
|
30
|
+
Variable: [],
|
31
|
+
DeferrableFragmentSpread: ['args', 'directives', 'fragmentArgs']
|
31
32
|
};
|
32
33
|
|
33
34
|
function visitIR(root, visitor) {
|
@@ -0,0 +1,50 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
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
|
+
* @providesModule GraphQLMultiReporter
|
8
|
+
*
|
9
|
+
* @format
|
10
|
+
*/
|
11
|
+
|
12
|
+
'use strict';
|
13
|
+
|
14
|
+
var _classCallCheck3 = _interopRequireDefault(require('babel-runtime/helpers/classCallCheck'));
|
15
|
+
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
17
|
+
|
18
|
+
var GraphQLMultiReporter = function () {
|
19
|
+
function GraphQLMultiReporter() {
|
20
|
+
(0, _classCallCheck3['default'])(this, GraphQLMultiReporter);
|
21
|
+
|
22
|
+
for (var _len = arguments.length, reporters = Array(_len), _key = 0; _key < _len; _key++) {
|
23
|
+
reporters[_key] = arguments[_key];
|
24
|
+
}
|
25
|
+
|
26
|
+
this._reporters = reporters;
|
27
|
+
}
|
28
|
+
|
29
|
+
GraphQLMultiReporter.prototype.reportMessage = function reportMessage(message) {
|
30
|
+
this._reporters.forEach(function (reporter) {
|
31
|
+
reporter.reportMessage(message);
|
32
|
+
});
|
33
|
+
};
|
34
|
+
|
35
|
+
GraphQLMultiReporter.prototype.reportTime = function reportTime(name, ms) {
|
36
|
+
this._reporters.forEach(function (reporter) {
|
37
|
+
reporter.reportTime(name, ms);
|
38
|
+
});
|
39
|
+
};
|
40
|
+
|
41
|
+
GraphQLMultiReporter.prototype.reportError = function reportError(caughtLocation, error) {
|
42
|
+
this._reporters.forEach(function (reporter) {
|
43
|
+
reporter.reportError(caughtLocation, error);
|
44
|
+
});
|
45
|
+
};
|
46
|
+
|
47
|
+
return GraphQLMultiReporter;
|
48
|
+
}();
|
49
|
+
|
50
|
+
module.exports = GraphQLMultiReporter;
|