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,189 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Copyright (c) 2013-present, Facebook, Inc.
|
3
|
-
* All rights reserved.
|
4
|
-
*
|
5
|
-
* This source code is licensed under the BSD-style license found in the
|
6
|
-
* LICENSE file in the root directory of this source tree. An additional grant
|
7
|
-
* of patent rights can be found in the PATENTS file in the same directory.
|
8
|
-
*
|
9
|
-
*
|
10
|
-
* @providesModule RelayGenerateRequisiteFieldsTransform
|
11
|
-
* @format
|
12
|
-
*/
|
13
|
-
|
14
|
-
'use strict';
|
15
|
-
|
16
|
-
var _extends3 = _interopRequireDefault(require('babel-runtime/helpers/extends'));
|
17
|
-
|
18
|
-
var _toConsumableArray3 = _interopRequireDefault(require('babel-runtime/helpers/toConsumableArray'));
|
19
|
-
|
20
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
21
|
-
|
22
|
-
var _require = require('graphql'),
|
23
|
-
assertAbstractType = _require.assertAbstractType,
|
24
|
-
assertCompositeType = _require.assertCompositeType,
|
25
|
-
assertLeafType = _require.assertLeafType;
|
26
|
-
|
27
|
-
var canHaveSelections = require('./GraphQLSchemaUtils').canHaveSelections,
|
28
|
-
getRawType = require('./GraphQLSchemaUtils').getRawType,
|
29
|
-
hasID = require('./GraphQLSchemaUtils').hasID,
|
30
|
-
implementsInterface = require('./GraphQLSchemaUtils').implementsInterface,
|
31
|
-
isAbstractType = require('./GraphQLSchemaUtils').isAbstractType,
|
32
|
-
mayImplement = require('./GraphQLSchemaUtils').mayImplement;
|
33
|
-
|
34
|
-
var TYPENAME_KEY = '__typename';
|
35
|
-
var ID = 'id';
|
36
|
-
var ID_TYPE = 'ID';
|
37
|
-
var NODE_TYPE = 'Node';
|
38
|
-
var STRING_TYPE = 'String';
|
39
|
-
|
40
|
-
/**
|
41
|
-
* A transform that adds "requisite" fields to all nodes:
|
42
|
-
* - Adds an `id` selection on any `LinkedField` of type that implements `Node`
|
43
|
-
* or has an id field but where there is no unaliased `id` selection.
|
44
|
-
* - Adds `__typename` on any `LinkedField` of a union/interface type where
|
45
|
-
* there is no unaliased `__typename` selection.
|
46
|
-
*/
|
47
|
-
function transform(context) {
|
48
|
-
var documents = context.documents();
|
49
|
-
return documents.reduce(function (ctx, node) {
|
50
|
-
var transformedNode = transformNode(context, node);
|
51
|
-
return ctx.add(transformedNode);
|
52
|
-
}, new (require('./RelayCompilerContext'))(context.schema));
|
53
|
-
}
|
54
|
-
|
55
|
-
function transformNode(context, node) {
|
56
|
-
var selections = node.selections.map(function (selection) {
|
57
|
-
if (selection.kind === 'LinkedField') {
|
58
|
-
return transformField(context, selection);
|
59
|
-
} else if (selection.kind === 'InlineFragment' || selection.kind === 'Condition') {
|
60
|
-
return transformNode(context, selection);
|
61
|
-
} else {
|
62
|
-
return selection;
|
63
|
-
}
|
64
|
-
});
|
65
|
-
return (0, _extends3['default'])({}, node, {
|
66
|
-
selections: selections
|
67
|
-
});
|
68
|
-
}
|
69
|
-
|
70
|
-
function transformField(context, field) {
|
71
|
-
var transformedNode = transformNode(context, field);
|
72
|
-
var type = field.type;
|
73
|
-
|
74
|
-
var generatedSelections = [].concat((0, _toConsumableArray3['default'])(transformedNode.selections));
|
75
|
-
var idSelections = generateIDSelections(context, field, field.type);
|
76
|
-
if (idSelections) {
|
77
|
-
generatedSelections.push.apply(generatedSelections, (0, _toConsumableArray3['default'])(idSelections));
|
78
|
-
}
|
79
|
-
if (isAbstractType(type) && !hasUnaliasedSelection(field, TYPENAME_KEY)) {
|
80
|
-
var stringType = assertLeafType(context.schema.getType(STRING_TYPE));
|
81
|
-
generatedSelections.push({
|
82
|
-
kind: 'ScalarField',
|
83
|
-
alias: null,
|
84
|
-
args: [],
|
85
|
-
directives: [],
|
86
|
-
handles: null,
|
87
|
-
metadata: null,
|
88
|
-
name: TYPENAME_KEY,
|
89
|
-
type: stringType
|
90
|
-
});
|
91
|
-
}
|
92
|
-
var selections = sortSelections(generatedSelections);
|
93
|
-
return (0, _extends3['default'])({}, transformedNode, {
|
94
|
-
selections: selections
|
95
|
-
});
|
96
|
-
}
|
97
|
-
|
98
|
-
/**
|
99
|
-
* @internal
|
100
|
-
*
|
101
|
-
* Returns an array of zero or more selections to fetch `id` depending on the
|
102
|
-
* type of the given field:
|
103
|
-
* - If the field already has an unaliased `id` field, do nothing
|
104
|
-
* - If the field type has an `id` subfield, return an `id` selection
|
105
|
-
* - If the field type is abstract, then generate a `... on Node { id }`
|
106
|
-
* fragment if *any* concrete type implements Node. Then generate a
|
107
|
-
* `... on PossibleType { id }` for every concrete type that does *not*
|
108
|
-
* implement `Node`
|
109
|
-
*/
|
110
|
-
function generateIDSelections(context, field, type) {
|
111
|
-
if (hasUnaliasedSelection(field, ID)) {
|
112
|
-
return null;
|
113
|
-
}
|
114
|
-
var unmodifiedType = assertCompositeType(getRawType(type));
|
115
|
-
var generatedSelections = [];
|
116
|
-
// Object or Interface type that has `id` field
|
117
|
-
if (canHaveSelections(unmodifiedType) && hasID(context.schema, unmodifiedType)) {
|
118
|
-
var idType = assertLeafType(context.schema.getType(ID_TYPE));
|
119
|
-
generatedSelections.push({
|
120
|
-
kind: 'ScalarField',
|
121
|
-
alias: null,
|
122
|
-
args: [],
|
123
|
-
directives: [],
|
124
|
-
handles: null,
|
125
|
-
metadata: null,
|
126
|
-
name: ID,
|
127
|
-
type: idType
|
128
|
-
});
|
129
|
-
} else if (isAbstractType(unmodifiedType)) {
|
130
|
-
// Union or interface: concrete types may implement `Node` or have an `id`
|
131
|
-
// field
|
132
|
-
var _idType = assertLeafType(context.schema.getType(ID_TYPE));
|
133
|
-
if (mayImplement(context.schema, unmodifiedType, NODE_TYPE)) {
|
134
|
-
var nodeType = assertCompositeType(context.schema.getType(NODE_TYPE));
|
135
|
-
generatedSelections.push(buildIdFragment(nodeType, _idType));
|
136
|
-
}
|
137
|
-
var abstractType = assertAbstractType(unmodifiedType);
|
138
|
-
context.schema.getPossibleTypes(abstractType).forEach(function (possibleType) {
|
139
|
-
if (!implementsInterface(possibleType, NODE_TYPE) && hasID(context.schema, possibleType)) {
|
140
|
-
generatedSelections.push(buildIdFragment(possibleType, _idType));
|
141
|
-
}
|
142
|
-
});
|
143
|
-
}
|
144
|
-
return generatedSelections;
|
145
|
-
}
|
146
|
-
|
147
|
-
/**
|
148
|
-
* @internal
|
149
|
-
*/
|
150
|
-
function buildIdFragment(fragmentType, idType) {
|
151
|
-
return {
|
152
|
-
kind: 'InlineFragment',
|
153
|
-
directives: [],
|
154
|
-
metadata: null,
|
155
|
-
typeCondition: fragmentType,
|
156
|
-
selections: [{
|
157
|
-
kind: 'ScalarField',
|
158
|
-
alias: null,
|
159
|
-
args: [],
|
160
|
-
directives: [],
|
161
|
-
handles: null,
|
162
|
-
metadata: null,
|
163
|
-
name: ID,
|
164
|
-
type: idType
|
165
|
-
}]
|
166
|
-
};
|
167
|
-
}
|
168
|
-
|
169
|
-
/**
|
170
|
-
* @internal
|
171
|
-
*/
|
172
|
-
function hasUnaliasedSelection(field, fieldName) {
|
173
|
-
return field.selections.some(function (selection) {
|
174
|
-
return selection.kind === 'ScalarField' && selection.alias == null && selection.name === fieldName;
|
175
|
-
});
|
176
|
-
}
|
177
|
-
|
178
|
-
/**
|
179
|
-
* @internal
|
180
|
-
*
|
181
|
-
* For interoperability with classic systems, sort `__typename` first.
|
182
|
-
*/
|
183
|
-
function sortSelections(selections) {
|
184
|
-
return [].concat((0, _toConsumableArray3['default'])(selections)).sort(function (a, b) {
|
185
|
-
return a.kind === 'ScalarField' && a.name === TYPENAME_KEY ? -1 : b.kind === 'ScalarField' && b.name === TYPENAME_KEY ? 1 : 0;
|
186
|
-
});
|
187
|
-
}
|
188
|
-
|
189
|
-
module.exports = { transform: transform };
|
package/lib/RelayIR.js
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Copyright (c) 2013-present, Facebook, Inc.
|
3
|
-
* All rights reserved.
|
4
|
-
*
|
5
|
-
* This source code is licensed under the BSD-style license found in the
|
6
|
-
* LICENSE file in the root directory of this source tree. An additional grant
|
7
|
-
* of patent rights can be found in the PATENTS file in the same directory.
|
8
|
-
*
|
9
|
-
* @providesModule RelayIR
|
10
|
-
*
|
11
|
-
* @format
|
12
|
-
*/
|
13
|
-
|
14
|
-
'use strict';
|
@@ -1,40 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Copyright (c) 2013-present, Facebook, Inc.
|
3
|
-
* All rights reserved.
|
4
|
-
*
|
5
|
-
* This source code is licensed under the BSD-style license found in the
|
6
|
-
* LICENSE file in the root directory of this source tree. An additional grant
|
7
|
-
* of patent rights can be found in the PATENTS file in the same directory.
|
8
|
-
*
|
9
|
-
* @providesModule RelayMultiReporter
|
10
|
-
*
|
11
|
-
* @format
|
12
|
-
*/
|
13
|
-
|
14
|
-
'use strict';
|
15
|
-
|
16
|
-
var _classCallCheck3 = _interopRequireDefault(require('babel-runtime/helpers/classCallCheck'));
|
17
|
-
|
18
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
19
|
-
|
20
|
-
var RelayMultiReporter = function () {
|
21
|
-
function RelayMultiReporter() {
|
22
|
-
(0, _classCallCheck3['default'])(this, RelayMultiReporter);
|
23
|
-
|
24
|
-
for (var _len = arguments.length, reporters = Array(_len), _key = 0; _key < _len; _key++) {
|
25
|
-
reporters[_key] = arguments[_key];
|
26
|
-
}
|
27
|
-
|
28
|
-
this._reporters = reporters;
|
29
|
-
}
|
30
|
-
|
31
|
-
RelayMultiReporter.prototype.reportError = function reportError(caughtLocation, error) {
|
32
|
-
this._reporters.forEach(function (reporter) {
|
33
|
-
reporter.reportError(caughtLocation, error);
|
34
|
-
});
|
35
|
-
};
|
36
|
-
|
37
|
-
return RelayMultiReporter;
|
38
|
-
}();
|
39
|
-
|
40
|
-
module.exports = RelayMultiReporter;
|
package/lib/RelayReporter.js
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Copyright (c) 2013-present, Facebook, Inc.
|
3
|
-
* All rights reserved.
|
4
|
-
*
|
5
|
-
* This source code is licensed under the BSD-style license found in the
|
6
|
-
* LICENSE file in the root directory of this source tree. An additional grant
|
7
|
-
* of patent rights can be found in the PATENTS file in the same directory.
|
8
|
-
*
|
9
|
-
* @providesModule RelayReporter
|
10
|
-
*
|
11
|
-
* @format
|
12
|
-
*/
|
13
|
-
|
14
|
-
'use strict';
|
package/lib/RelayTestSchema.js
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Copyright (c) 2013-present, Facebook, Inc.
|
3
|
-
* All rights reserved.
|
4
|
-
*
|
5
|
-
* This source code is licensed under the BSD-style license found in the
|
6
|
-
* LICENSE file in the root directory of this source tree. An additional grant
|
7
|
-
* of patent rights can be found in the PATENTS file in the same directory.
|
8
|
-
*
|
9
|
-
* @providesModule RelayTestSchema
|
10
|
-
*
|
11
|
-
* @format
|
12
|
-
*/
|
13
|
-
|
14
|
-
'use strict';
|
15
|
-
|
16
|
-
var _require = require('graphql'),
|
17
|
-
buildASTSchema = _require.buildASTSchema,
|
18
|
-
parse = _require.parse;
|
19
|
-
|
20
|
-
var schemaPath = require('path').join(__dirname, 'testschema.graphql');
|
21
|
-
module.exports = buildASTSchema(parse(require('fs').readFileSync(schemaPath, 'utf8')));
|
package/lib/formatStorageKey.js
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Copyright (c) 2013-present, Facebook, Inc.
|
3
|
-
* All rights reserved.
|
4
|
-
*
|
5
|
-
* This source code is licensed under the BSD-style license found in the
|
6
|
-
* LICENSE file in the root directory of this source tree. An additional grant
|
7
|
-
* of patent rights can be found in the PATENTS file in the same directory.
|
8
|
-
*
|
9
|
-
* @providesModule formatStorageKey
|
10
|
-
*
|
11
|
-
* @format
|
12
|
-
*/
|
13
|
-
|
14
|
-
'use strict';
|
15
|
-
|
16
|
-
/**
|
17
|
-
* Given a `fieldName` (eg. "foo") and an object representing arguments and
|
18
|
-
* values (eg. `{first: 10, orberBy: "name"}`) returns a unique storage key
|
19
|
-
* (ie. `foo{"first":10,"orderBy":"name"}`).
|
20
|
-
*/
|
21
|
-
function formatStorageKey(fieldName, argsWithValues) {
|
22
|
-
if (!argsWithValues) {
|
23
|
-
return fieldName;
|
24
|
-
}
|
25
|
-
var filtered = null;
|
26
|
-
require('fbjs/lib/forEachObject')(argsWithValues, function (value, argName) {
|
27
|
-
if (value != null) {
|
28
|
-
if (!filtered) {
|
29
|
-
filtered = {};
|
30
|
-
}
|
31
|
-
filtered[argName] = value;
|
32
|
-
}
|
33
|
-
});
|
34
|
-
return fieldName + (filtered ? require('./stableJSONStringify')(filtered) : '');
|
35
|
-
}
|
36
|
-
|
37
|
-
module.exports = formatStorageKey;
|
@@ -1,54 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Copyright (c) 2013-present, Facebook, Inc.
|
3
|
-
* All rights reserved.
|
4
|
-
*
|
5
|
-
* This source code is licensed under the BSD-style license found in the
|
6
|
-
* LICENSE file in the root directory of this source tree. An additional grant
|
7
|
-
* of patent rights can be found in the PATENTS file in the same directory.
|
8
|
-
*
|
9
|
-
*
|
10
|
-
* @providesModule getIdentifierForRelaySelection
|
11
|
-
* @format
|
12
|
-
*/
|
13
|
-
|
14
|
-
'use strict';
|
15
|
-
|
16
|
-
/**
|
17
|
-
* Generates an identifier that is unique to a given selection: the alias for
|
18
|
-
* fields, the type for inline fragments, and a summary of the condition
|
19
|
-
* variable and passing value for conditions.
|
20
|
-
*/
|
21
|
-
function getIdentifierForRelaySelection(node) {
|
22
|
-
var obj = void 0;
|
23
|
-
switch (node.kind) {
|
24
|
-
case 'LinkedField':
|
25
|
-
case 'ScalarField':
|
26
|
-
obj = {
|
27
|
-
directives: node.directives,
|
28
|
-
field: node.alias || node.name
|
29
|
-
};
|
30
|
-
break;
|
31
|
-
case 'InlineFragment':
|
32
|
-
obj = {
|
33
|
-
inlineFragment: node.typeCondition.toString()
|
34
|
-
};
|
35
|
-
break;
|
36
|
-
case 'Condition':
|
37
|
-
obj = {
|
38
|
-
condition: node.condition,
|
39
|
-
passingValue: node.passingValue
|
40
|
-
};
|
41
|
-
break;
|
42
|
-
case 'FragmentSpread':
|
43
|
-
obj = {
|
44
|
-
fragmentSpread: node.name,
|
45
|
-
args: node.args
|
46
|
-
};
|
47
|
-
break;
|
48
|
-
default:
|
49
|
-
require('fbjs/lib/invariant')(false, 'RelayFlattenTransform: Unexpected kind `%s`.', node.kind);
|
50
|
-
}
|
51
|
-
return require('./stableJSONStringifyOSS')(obj);
|
52
|
-
}
|
53
|
-
|
54
|
-
module.exports = getIdentifierForRelaySelection;
|
@@ -1,28 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Copyright (c) 2013-present, Facebook, Inc.
|
3
|
-
* All rights reserved.
|
4
|
-
*
|
5
|
-
* This source code is licensed under the BSD-style license found in the
|
6
|
-
* LICENSE file in the root directory of this source tree. An additional grant
|
7
|
-
* of patent rights can be found in the PATENTS file in the same directory.
|
8
|
-
*
|
9
|
-
* @providesModule getRelayLiteralArgumentValues
|
10
|
-
*
|
11
|
-
* @format
|
12
|
-
*/
|
13
|
-
|
14
|
-
'use strict';
|
15
|
-
|
16
|
-
// Copy of Variables type from '../../../react-relay/classic/tools/RelayTypes'
|
17
|
-
// Duplicating here rather than importing it since we can't take on a dependency
|
18
|
-
// outside of graphql-compiler.
|
19
|
-
function getRelayLiteralArgumentValues(args) {
|
20
|
-
var values = {};
|
21
|
-
args.forEach(function (arg) {
|
22
|
-
require('fbjs/lib/invariant')(arg.value.kind === 'Literal', 'getRelayLiteralArgumentValues(): Expected all args to be literals.');
|
23
|
-
values[arg.name] = arg.value.value;
|
24
|
-
});
|
25
|
-
return values;
|
26
|
-
}
|
27
|
-
|
28
|
-
module.exports = getRelayLiteralArgumentValues;
|
package/lib/parseGraphQLText.js
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Copyright (c) 2013-present, Facebook, Inc.
|
3
|
-
* All rights reserved.
|
4
|
-
*
|
5
|
-
* This source code is licensed under the BSD-style license found in the
|
6
|
-
* LICENSE file in the root directory of this source tree. An additional grant
|
7
|
-
* of patent rights can be found in the PATENTS file in the same directory.
|
8
|
-
*
|
9
|
-
* @providesModule parseGraphQLText
|
10
|
-
*
|
11
|
-
* @format
|
12
|
-
*/
|
13
|
-
|
14
|
-
'use strict';
|
15
|
-
|
16
|
-
var _require = require('./ASTConvert'),
|
17
|
-
convertASTDocuments = _require.convertASTDocuments;
|
18
|
-
|
19
|
-
var _require2 = require('graphql'),
|
20
|
-
extendSchema = _require2.extendSchema,
|
21
|
-
parse = _require2.parse;
|
22
|
-
|
23
|
-
function parseGraphQLText(schema, text) {
|
24
|
-
var ast = parse(text);
|
25
|
-
var extendedSchema = extendSchema(schema, ast);
|
26
|
-
var definitions = convertASTDocuments(extendedSchema, [ast], []);
|
27
|
-
return {
|
28
|
-
definitions: definitions,
|
29
|
-
schema: extendedSchema !== schema ? extendedSchema : null
|
30
|
-
};
|
31
|
-
}
|
32
|
-
|
33
|
-
module.exports = parseGraphQLText;
|
package/lib/prettyStringify.js
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Copyright (c) 2013-present, Facebook, Inc.
|
3
|
-
* All rights reserved.
|
4
|
-
*
|
5
|
-
* This source code is licensed under the BSD-style license found in the
|
6
|
-
* LICENSE file in the root directory of this source tree. An additional grant
|
7
|
-
* of patent rights can be found in the PATENTS file in the same directory.
|
8
|
-
*
|
9
|
-
*
|
10
|
-
* @providesModule prettyStringify
|
11
|
-
* @format
|
12
|
-
*/
|
13
|
-
|
14
|
-
'use strict';
|
15
|
-
|
16
|
-
/**
|
17
|
-
* Simple wrapper for `JSON.stringify` that adds whitespace to aid readability:
|
18
|
-
*
|
19
|
-
* ```
|
20
|
-
* const object = {a: 1, b 2};
|
21
|
-
*
|
22
|
-
* JSON.stringify(object); // {"a":1,"b":2}
|
23
|
-
*
|
24
|
-
* prettyStringify(object); // {
|
25
|
-
* // "a": 1,
|
26
|
-
* // "b": 2
|
27
|
-
* // }
|
28
|
-
* ```
|
29
|
-
*/
|
30
|
-
|
31
|
-
function prettyStringify(stringifiable) {
|
32
|
-
return JSON.stringify(stringifiable, null, 2);
|
33
|
-
}
|
34
|
-
|
35
|
-
module.exports = prettyStringify;
|