relay-compiler 0.0.0-main-8ff54d69 → 0.0.0-main-38f1c96e
Sign up to get free protection for your applications and to get access to all the features.
- package/cli.js +23 -0
- package/index.js +19 -3
- package/linux-x64/relay +0 -0
- package/macos-x64/relay +0 -0
- package/package.json +2 -24
- package/win-x64/relay.exe +0 -0
- package/bin/RelayCompilerBin.js.flow +0 -168
- package/bin/RelayCompilerMain.js.flow +0 -515
- package/bin/__fixtures__/plugin-module.js.flow +0 -17
- package/bin/relay-compiler +0 -19068
- package/codegen/CodegenDirectory.js.flow +0 -372
- package/codegen/CodegenRunner.js.flow +0 -424
- package/codegen/CodegenTypes.js.flow +0 -28
- package/codegen/CodegenWatcher.js.flow +0 -250
- package/codegen/NormalizationCodeGenerator.js.flow +0 -566
- package/codegen/ReaderCodeGenerator.js.flow +0 -510
- package/codegen/RelayCodeGenerator.js.flow +0 -85
- package/codegen/RelayFileWriter.js.flow +0 -365
- package/codegen/SourceControl.js.flow +0 -58
- package/codegen/compileRelayArtifacts.js.flow +0 -181
- package/codegen/createPrintRequireModuleDependency.js.flow +0 -19
- package/codegen/sortObjectByKey.js.flow +0 -25
- package/codegen/writeRelayGeneratedFile.js.flow +0 -235
- package/core/ASTCache.js.flow +0 -73
- package/core/ASTConvert.js.flow +0 -230
- package/core/CompilerContext.js.flow +0 -189
- package/core/CompilerError.js.flow +0 -255
- package/core/DotGraphQLParser.js.flow +0 -37
- package/core/GraphQLCompilerProfiler.js.flow +0 -341
- package/core/GraphQLDerivedFromMetadata.js.flow +0 -36
- package/core/GraphQLWatchmanClient.js.flow +0 -109
- package/core/IR.js.flow +0 -326
- package/core/IRPrinter.js.flow +0 -472
- package/core/IRTransformer.js.flow +0 -376
- package/core/IRValidator.js.flow +0 -259
- package/core/IRVisitor.js.flow +0 -150
- package/core/JSModuleParser.js.flow +0 -24
- package/core/RelayCompilerScope.js.flow +0 -199
- package/core/RelayFindGraphQLTags.js.flow +0 -118
- package/core/RelayGraphQLEnumsGenerator.js.flow +0 -55
- package/core/RelayIRTransforms.js.flow +0 -138
- package/core/RelayParser.js.flow +0 -1741
- package/core/RelaySourceModuleParser.js.flow +0 -133
- package/core/Schema.js.flow +0 -2035
- package/core/SchemaUtils.js.flow +0 -120
- package/core/filterContextForNode.js.flow +0 -49
- package/core/getFieldDefinition.js.flow +0 -156
- package/core/getIdentifierForArgumentValue.js.flow +0 -49
- package/core/getIdentifierForSelection.js.flow +0 -68
- package/core/getLiteralArgumentValues.js.flow +0 -32
- package/core/getNormalizationOperationName.js.flow +0 -19
- package/core/inferRootArgumentDefinitions.js.flow +0 -322
- package/index.js.flow +0 -198
- package/language/RelayLanguagePluginInterface.js.flow +0 -283
- package/language/javascript/FindGraphQLTags.js.flow +0 -136
- package/language/javascript/RelayFlowBabelFactories.js.flow +0 -176
- package/language/javascript/RelayFlowGenerator.js.flow +0 -1096
- package/language/javascript/RelayFlowTypeTransformers.js.flow +0 -181
- package/language/javascript/RelayLanguagePluginJavaScript.js.flow +0 -33
- package/language/javascript/formatGeneratedModule.js.flow +0 -65
- package/lib/bin/RelayCompilerBin.js +0 -143
- package/lib/bin/RelayCompilerMain.js +0 -488
- package/lib/bin/__fixtures__/plugin-module.js +0 -16
- package/lib/codegen/CodegenDirectory.js +0 -335
- package/lib/codegen/CodegenRunner.js +0 -433
- package/lib/codegen/CodegenTypes.js +0 -11
- package/lib/codegen/CodegenWatcher.js +0 -271
- package/lib/codegen/NormalizationCodeGenerator.js +0 -487
- package/lib/codegen/ReaderCodeGenerator.js +0 -473
- package/lib/codegen/RelayCodeGenerator.js +0 -75
- package/lib/codegen/RelayFileWriter.js +0 -270
- package/lib/codegen/SourceControl.js +0 -60
- package/lib/codegen/compileRelayArtifacts.js +0 -157
- package/lib/codegen/createPrintRequireModuleDependency.js +0 -19
- package/lib/codegen/sortObjectByKey.js +0 -41
- package/lib/codegen/writeRelayGeneratedFile.js +0 -206
- package/lib/core/ASTCache.js +0 -70
- package/lib/core/ASTConvert.js +0 -198
- package/lib/core/CompilerContext.js +0 -165
- package/lib/core/CompilerError.js +0 -252
- package/lib/core/DotGraphQLParser.js +0 -40
- package/lib/core/GraphQLCompilerProfiler.js +0 -299
- package/lib/core/GraphQLDerivedFromMetadata.js +0 -31
- package/lib/core/GraphQLWatchmanClient.js +0 -150
- package/lib/core/IR.js +0 -11
- package/lib/core/IRPrinter.js +0 -388
- package/lib/core/IRTransformer.js +0 -345
- package/lib/core/IRValidator.js +0 -226
- package/lib/core/IRVisitor.js +0 -45
- package/lib/core/JSModuleParser.js +0 -18
- package/lib/core/RelayCompilerScope.js +0 -183
- package/lib/core/RelayFindGraphQLTags.js +0 -79
- package/lib/core/RelayGraphQLEnumsGenerator.js +0 -50
- package/lib/core/RelayIRTransforms.js +0 -109
- package/lib/core/RelayParser.js +0 -1381
- package/lib/core/RelaySourceModuleParser.js +0 -104
- package/lib/core/Schema.js +0 -1877
- package/lib/core/SchemaUtils.js +0 -98
- package/lib/core/filterContextForNode.js +0 -50
- package/lib/core/getFieldDefinition.js +0 -145
- package/lib/core/getIdentifierForArgumentValue.js +0 -54
- package/lib/core/getIdentifierForSelection.js +0 -49
- package/lib/core/getLiteralArgumentValues.js +0 -26
- package/lib/core/getNormalizationOperationName.js +0 -17
- package/lib/core/inferRootArgumentDefinitions.js +0 -351
- package/lib/index.js +0 -178
- package/lib/language/RelayLanguagePluginInterface.js +0 -26
- package/lib/language/javascript/FindGraphQLTags.js +0 -126
- package/lib/language/javascript/RelayFlowBabelFactories.js +0 -160
- package/lib/language/javascript/RelayFlowGenerator.js +0 -856
- package/lib/language/javascript/RelayFlowTypeTransformers.js +0 -119
- package/lib/language/javascript/RelayLanguagePluginJavaScript.js +0 -30
- package/lib/language/javascript/formatGeneratedModule.js +0 -36
- package/lib/reporters/ConsoleReporter.js +0 -61
- package/lib/reporters/MultiReporter.js +0 -45
- package/lib/reporters/Reporter.js +0 -11
- package/lib/runner/Artifacts.js +0 -323
- package/lib/runner/BufferedFilesystem.js +0 -262
- package/lib/runner/GraphQLASTNodeGroup.js +0 -256
- package/lib/runner/GraphQLASTUtils.js +0 -23
- package/lib/runner/GraphQLNodeMap.js +0 -81
- package/lib/runner/Sources.js +0 -271
- package/lib/runner/StrictMap.js +0 -134
- package/lib/runner/compileArtifacts.js +0 -39
- package/lib/runner/extractAST.js +0 -77
- package/lib/runner/getChangedNodeNames.js +0 -82
- package/lib/runner/getSchemaInstance.js +0 -30
- package/lib/runner/types.js +0 -12
- package/lib/test-utils/TestSchema.js +0 -27
- package/lib/test-utils/parseGraphQLText.js +0 -30
- package/lib/transforms/ApplyFragmentArgumentTransform.js +0 -393
- package/lib/transforms/ClientExtensionsTransform.js +0 -221
- package/lib/transforms/ConnectionTransform.js +0 -639
- package/lib/transforms/DeclarativeConnectionMutationTransform.js +0 -218
- package/lib/transforms/DeferStreamTransform.js +0 -246
- package/lib/transforms/DisallowIdAsAlias.js +0 -40
- package/lib/transforms/DisallowTypenameOnRoot.js +0 -53
- package/lib/transforms/FieldHandleTransform.js +0 -79
- package/lib/transforms/FilterCompilerDirectivesTransform.js +0 -29
- package/lib/transforms/FilterDirectivesTransform.js +0 -42
- package/lib/transforms/FlattenTransform.js +0 -306
- package/lib/transforms/GenerateIDFieldTransform.js +0 -135
- package/lib/transforms/GenerateTypeNameTransform.js +0 -149
- package/lib/transforms/InlineDataFragmentTransform.js +0 -100
- package/lib/transforms/InlineFragmentsTransform.js +0 -61
- package/lib/transforms/MaskTransform.js +0 -117
- package/lib/transforms/MatchTransform.js +0 -434
- package/lib/transforms/ReactFlightComponentTransform.js +0 -158
- package/lib/transforms/RefetchableFragmentTransform.js +0 -249
- package/lib/transforms/RelayDirectiveTransform.js +0 -83
- package/lib/transforms/RequiredFieldTransform.js +0 -369
- package/lib/transforms/SkipClientExtensionsTransform.js +0 -46
- package/lib/transforms/SkipHandleFieldTransform.js +0 -45
- package/lib/transforms/SkipRedundantNodesTransform.js +0 -261
- package/lib/transforms/SkipSplitOperationTransform.js +0 -32
- package/lib/transforms/SkipUnreachableNodeTransform.js +0 -158
- package/lib/transforms/SkipUnusedVariablesTransform.js +0 -75
- package/lib/transforms/SplitModuleImportTransform.js +0 -82
- package/lib/transforms/TestOperationTransform.js +0 -144
- package/lib/transforms/TransformUtils.js +0 -21
- package/lib/transforms/ValidateGlobalVariablesTransform.js +0 -92
- package/lib/transforms/ValidateRequiredArgumentsTransform.js +0 -114
- package/lib/transforms/ValidateServerOnlyDirectivesTransform.js +0 -108
- package/lib/transforms/ValidateUnusedVariablesTransform.js +0 -96
- package/lib/transforms/query-generators/FetchableQueryGenerator.js +0 -157
- package/lib/transforms/query-generators/NodeQueryGenerator.js +0 -166
- package/lib/transforms/query-generators/QueryQueryGenerator.js +0 -48
- package/lib/transforms/query-generators/ViewerQueryGenerator.js +0 -77
- package/lib/transforms/query-generators/index.js +0 -60
- package/lib/transforms/query-generators/utils.js +0 -92
- package/lib/util/CodeMarker.js +0 -80
- package/lib/util/DefaultHandleKey.js +0 -15
- package/lib/util/RelayCompilerCache.js +0 -97
- package/lib/util/Rollout.js +0 -40
- package/lib/util/TimeReporter.js +0 -83
- package/lib/util/areEqualArgValues.js +0 -135
- package/lib/util/argumentContainsVariables.js +0 -37
- package/lib/util/dedupeJSONStringify.js +0 -160
- package/lib/util/generateAbstractTypeRefinementKey.js +0 -24
- package/lib/util/getDefinitionNodeHash.js +0 -22
- package/lib/util/getModuleName.js +0 -32
- package/lib/util/joinArgumentDefinitions.js +0 -67
- package/lib/util/md5.js +0 -17
- package/lib/util/murmurHash.js +0 -86
- package/lib/util/nullthrowsOSS.js +0 -23
- package/lib/util/orList.js +0 -36
- package/lib/util/partitionArray.js +0 -35
- package/relay-compiler.js +0 -17
- package/relay-compiler.min.js +0 -22
- package/reporters/ConsoleReporter.js.flow +0 -81
- package/reporters/MultiReporter.js.flow +0 -43
- package/reporters/Reporter.js.flow +0 -19
- package/runner/Artifacts.js.flow +0 -215
- package/runner/BufferedFilesystem.js.flow +0 -194
- package/runner/GraphQLASTNodeGroup.js.flow +0 -174
- package/runner/GraphQLASTUtils.js.flow +0 -26
- package/runner/GraphQLNodeMap.js.flow +0 -55
- package/runner/Sources.js.flow +0 -227
- package/runner/StrictMap.js.flow +0 -96
- package/runner/compileArtifacts.js.flow +0 -75
- package/runner/extractAST.js.flow +0 -98
- package/runner/getChangedNodeNames.js.flow +0 -48
- package/runner/getSchemaInstance.js.flow +0 -36
- package/runner/types.js.flow +0 -37
- package/test-utils/TestSchema.js.flow +0 -30
- package/test-utils/parseGraphQLText.js.flow +0 -41
- package/transforms/ApplyFragmentArgumentTransform.js.flow +0 -524
- package/transforms/ClientExtensionsTransform.js.flow +0 -224
- package/transforms/ConnectionTransform.js.flow +0 -850
- package/transforms/DeclarativeConnectionMutationTransform.js.flow +0 -245
- package/transforms/DeferStreamTransform.js.flow +0 -263
- package/transforms/DisallowIdAsAlias.js.flow +0 -46
- package/transforms/DisallowTypenameOnRoot.js.flow +0 -44
- package/transforms/FieldHandleTransform.js.flow +0 -77
- package/transforms/FilterCompilerDirectivesTransform.js.flow +0 -33
- package/transforms/FilterDirectivesTransform.js.flow +0 -45
- package/transforms/FlattenTransform.js.flow +0 -458
- package/transforms/GenerateIDFieldTransform.js.flow +0 -151
- package/transforms/GenerateTypeNameTransform.js.flow +0 -159
- package/transforms/InlineDataFragmentTransform.js.flow +0 -123
- package/transforms/InlineFragmentsTransform.js.flow +0 -70
- package/transforms/MaskTransform.js.flow +0 -124
- package/transforms/MatchTransform.js.flow +0 -587
- package/transforms/ReactFlightComponentTransform.js.flow +0 -207
- package/transforms/RefetchableFragmentTransform.js.flow +0 -266
- package/transforms/RelayDirectiveTransform.js.flow +0 -96
- package/transforms/RequiredFieldTransform.js.flow +0 -413
- package/transforms/SkipClientExtensionsTransform.js.flow +0 -54
- package/transforms/SkipHandleFieldTransform.js.flow +0 -44
- package/transforms/SkipRedundantNodesTransform.js.flow +0 -277
- package/transforms/SkipSplitOperationTransform.js.flow +0 -37
- package/transforms/SkipUnreachableNodeTransform.js.flow +0 -148
- package/transforms/SkipUnusedVariablesTransform.js.flow +0 -59
- package/transforms/SplitModuleImportTransform.js.flow +0 -97
- package/transforms/TestOperationTransform.js.flow +0 -142
- package/transforms/TransformUtils.js.flow +0 -26
- package/transforms/ValidateGlobalVariablesTransform.js.flow +0 -80
- package/transforms/ValidateRequiredArgumentsTransform.js.flow +0 -130
- package/transforms/ValidateServerOnlyDirectivesTransform.js.flow +0 -128
- package/transforms/ValidateUnusedVariablesTransform.js.flow +0 -88
- package/transforms/query-generators/FetchableQueryGenerator.js.flow +0 -188
- package/transforms/query-generators/NodeQueryGenerator.js.flow +0 -217
- package/transforms/query-generators/QueryQueryGenerator.js.flow +0 -57
- package/transforms/query-generators/ViewerQueryGenerator.js.flow +0 -97
- package/transforms/query-generators/index.js.flow +0 -89
- package/transforms/query-generators/utils.js.flow +0 -76
- package/util/CodeMarker.js.flow +0 -79
- package/util/DefaultHandleKey.js.flow +0 -17
- package/util/RelayCompilerCache.js.flow +0 -86
- package/util/Rollout.js.flow +0 -39
- package/util/TimeReporter.js.flow +0 -79
- package/util/areEqualArgValues.js.flow +0 -126
- package/util/argumentContainsVariables.js.flow +0 -38
- package/util/dedupeJSONStringify.js.flow +0 -156
- package/util/generateAbstractTypeRefinementKey.js.flow +0 -29
- package/util/getDefinitionNodeHash.js.flow +0 -24
- package/util/getModuleName.js.flow +0 -39
- package/util/joinArgumentDefinitions.js.flow +0 -105
- package/util/md5.js.flow +0 -19
- package/util/murmurHash.js.flow +0 -94
- package/util/nullthrowsOSS.js.flow +0 -25
- package/util/orList.js.flow +0 -37
- package/util/partitionArray.js.flow +0 -37
package/lib/runner/Sources.js
DELETED
@@ -1,271 +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
|
-
* @format
|
8
|
-
*
|
9
|
-
* @emails oncall+relay
|
10
|
-
*/
|
11
|
-
// flowlint ambiguous-object-type:error
|
12
|
-
'use strict';
|
13
|
-
|
14
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
15
|
-
|
16
|
-
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
17
|
-
|
18
|
-
var _createForOfIteratorHelper2 = _interopRequireDefault(require("@babel/runtime/helpers/createForOfIteratorHelper"));
|
19
|
-
|
20
|
-
var md5 = require('../util/md5');
|
21
|
-
|
22
|
-
var _require = require('./extractAST'),
|
23
|
-
toASTRecord = _require.toASTRecord;
|
24
|
-
|
25
|
-
var _require2 = require('graphql'),
|
26
|
-
Source = _require2.Source,
|
27
|
-
parse = _require2.parse;
|
28
|
-
|
29
|
-
var invariant = require('invariant');
|
30
|
-
|
31
|
-
var Sources = /*#__PURE__*/function () {
|
32
|
-
Sources.fromSavedState = function fromSavedState(_ref) {
|
33
|
-
var extractFromFile = _ref.extractFromFile,
|
34
|
-
savedState = _ref.savedState;
|
35
|
-
var state = {};
|
36
|
-
|
37
|
-
var _iterator = (0, _createForOfIteratorHelper2["default"])(savedState),
|
38
|
-
_step;
|
39
|
-
|
40
|
-
try {
|
41
|
-
var _loop = function _loop() {
|
42
|
-
var _step$value = _step.value,
|
43
|
-
file = _step$value.file,
|
44
|
-
savedStateSources = _step$value.sources;
|
45
|
-
var nodes = {};
|
46
|
-
var sources = [];
|
47
|
-
|
48
|
-
var _iterator2 = (0, _createForOfIteratorHelper2["default"])(savedStateSources),
|
49
|
-
_step2;
|
50
|
-
|
51
|
-
try {
|
52
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
53
|
-
var text = _step2.value;
|
54
|
-
var doc = parse(new Source(text, file));
|
55
|
-
!doc.definitions.length ? process.env.NODE_ENV !== "production" ? invariant(false, 'expected not empty list of definitions') : invariant(false) : void 0;
|
56
|
-
var entities = doc.definitions.map(function (node) {
|
57
|
-
return toASTRecord(node);
|
58
|
-
});
|
59
|
-
entities.forEach(function (astRecord) {
|
60
|
-
nodes[md5(astRecord.text)] = astRecord.ast;
|
61
|
-
});
|
62
|
-
sources.push(text);
|
63
|
-
}
|
64
|
-
} catch (err) {
|
65
|
-
_iterator2.e(err);
|
66
|
-
} finally {
|
67
|
-
_iterator2.f();
|
68
|
-
}
|
69
|
-
|
70
|
-
state[file] = {
|
71
|
-
nodes: nodes,
|
72
|
-
sources: sources
|
73
|
-
};
|
74
|
-
};
|
75
|
-
|
76
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
77
|
-
_loop();
|
78
|
-
}
|
79
|
-
} catch (err) {
|
80
|
-
_iterator.e(err);
|
81
|
-
} finally {
|
82
|
-
_iterator.f();
|
83
|
-
}
|
84
|
-
|
85
|
-
return new Sources({
|
86
|
-
extractFromFile: extractFromFile,
|
87
|
-
state: state
|
88
|
-
});
|
89
|
-
};
|
90
|
-
|
91
|
-
function Sources(_ref2) {
|
92
|
-
var extractFromFile = _ref2.extractFromFile,
|
93
|
-
state = _ref2.state;
|
94
|
-
this._extractFromFile = extractFromFile;
|
95
|
-
this._state = (0, _objectSpread2["default"])({}, state);
|
96
|
-
}
|
97
|
-
|
98
|
-
var _proto = Sources.prototype;
|
99
|
-
|
100
|
-
_proto.processChanges = function processChanges(baseDir, files) {
|
101
|
-
var _ast$name$value, _ast$name;
|
102
|
-
|
103
|
-
var added = [];
|
104
|
-
var removed = [];
|
105
|
-
var state = (0, _objectSpread2["default"])({}, this._state);
|
106
|
-
|
107
|
-
var _iterator3 = (0, _createForOfIteratorHelper2["default"])(files),
|
108
|
-
_step3;
|
109
|
-
|
110
|
-
try {
|
111
|
-
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
112
|
-
var _state$file$name$node, _state$file$name;
|
113
|
-
|
114
|
-
var _file = _step3.value;
|
115
|
-
var newDefs = void 0;
|
116
|
-
var newSources = void 0;
|
117
|
-
|
118
|
-
try {
|
119
|
-
var extracted = this._extractFromFile(baseDir, _file);
|
120
|
-
|
121
|
-
if (extracted != null) {
|
122
|
-
newDefs = extracted.nodes;
|
123
|
-
newSources = extracted.sources;
|
124
|
-
}
|
125
|
-
} catch (error) {
|
126
|
-
throw new Error("RelayCompiler: Sources module failed to parse ".concat(_file.name, ":\n").concat(error.message));
|
127
|
-
}
|
128
|
-
|
129
|
-
var hasEntry = state.hasOwnProperty(_file.name);
|
130
|
-
var oldEntry = (_state$file$name$node = (_state$file$name = state[_file.name]) === null || _state$file$name === void 0 ? void 0 : _state$file$name.nodes) !== null && _state$file$name$node !== void 0 ? _state$file$name$node : {}; // First case, we have new changes in the file
|
131
|
-
// for example changed Query or Fragment
|
132
|
-
|
133
|
-
if (newDefs != null && newDefs.length > 0) {
|
134
|
-
// We need to add all entities from the changed file to added arrays
|
135
|
-
var newEntry = {};
|
136
|
-
var newTexts = new Set();
|
137
|
-
|
138
|
-
var _iterator4 = (0, _createForOfIteratorHelper2["default"])(newDefs),
|
139
|
-
_step4;
|
140
|
-
|
141
|
-
try {
|
142
|
-
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
143
|
-
var _step4$value = _step4.value,
|
144
|
-
_ast = _step4$value.ast,
|
145
|
-
text = _step4$value.text;
|
146
|
-
var hashedText = md5(text);
|
147
|
-
|
148
|
-
if (newTexts.has(hashedText)) {
|
149
|
-
var name = 'unknown';
|
150
|
-
|
151
|
-
switch (_ast.kind) {
|
152
|
-
case 'FragmentDefinition':
|
153
|
-
name = _ast.name.value;
|
154
|
-
break;
|
155
|
-
|
156
|
-
case 'OperationDefinition':
|
157
|
-
name = (_ast$name$value = (_ast$name = _ast.name) === null || _ast$name === void 0 ? void 0 : _ast$name.value) !== null && _ast$name$value !== void 0 ? _ast$name$value : 'unnamed operation';
|
158
|
-
break;
|
159
|
-
}
|
160
|
-
|
161
|
-
throw new Error("Duplicate definition of `".concat(name, "` in `").concat(_file.name, "`"));
|
162
|
-
}
|
163
|
-
|
164
|
-
newTexts.add(hashedText);
|
165
|
-
|
166
|
-
if (hasEntry && oldEntry[hashedText] != null) {
|
167
|
-
// Entity text did not change, so we
|
168
|
-
// don't need to change it in the state
|
169
|
-
newEntry[hashedText] = oldEntry[hashedText];
|
170
|
-
} else {
|
171
|
-
// Here we have completely new text.
|
172
|
-
// We need add it to the `added` changes
|
173
|
-
newEntry[hashedText] = _ast;
|
174
|
-
added.push({
|
175
|
-
file: _file.name,
|
176
|
-
ast: _ast
|
177
|
-
});
|
178
|
-
}
|
179
|
-
} // Also, we need to delete all old entities
|
180
|
-
// that are not included in the new changes
|
181
|
-
|
182
|
-
} catch (err) {
|
183
|
-
_iterator4.e(err);
|
184
|
-
} finally {
|
185
|
-
_iterator4.f();
|
186
|
-
}
|
187
|
-
|
188
|
-
if (hasEntry) {
|
189
|
-
for (var _i = 0, _Object$keys = Object.keys(oldEntry); _i < _Object$keys.length; _i++) {
|
190
|
-
var oldHashedText = _Object$keys[_i];
|
191
|
-
var ast = oldEntry[oldHashedText];
|
192
|
-
|
193
|
-
if (!newTexts.has(oldHashedText)) {
|
194
|
-
removed.push({
|
195
|
-
file: _file.name,
|
196
|
-
ast: ast
|
197
|
-
});
|
198
|
-
}
|
199
|
-
}
|
200
|
-
} // Finally, update the state with the changes
|
201
|
-
|
202
|
-
|
203
|
-
state[_file.name] = {
|
204
|
-
nodes: newEntry,
|
205
|
-
// $FlowFixMe[incompatible-type]
|
206
|
-
sources: newSources
|
207
|
-
};
|
208
|
-
} else {
|
209
|
-
// Otherwise, file has been removed or there are no entities in the file
|
210
|
-
if (hasEntry) {
|
211
|
-
// We will put all ASTNodes from current state to removed collection
|
212
|
-
for (var _i2 = 0, _Object$keys2 = Object.keys(oldEntry); _i2 < _Object$keys2.length; _i2++) {
|
213
|
-
var _oldHashedText = _Object$keys2[_i2];
|
214
|
-
var _ast2 = oldEntry[_oldHashedText];
|
215
|
-
removed.push({
|
216
|
-
file: _file.name,
|
217
|
-
ast: _ast2
|
218
|
-
});
|
219
|
-
}
|
220
|
-
|
221
|
-
delete state[_file.name];
|
222
|
-
}
|
223
|
-
}
|
224
|
-
}
|
225
|
-
} catch (err) {
|
226
|
-
_iterator3.e(err);
|
227
|
-
} finally {
|
228
|
-
_iterator3.f();
|
229
|
-
}
|
230
|
-
|
231
|
-
return {
|
232
|
-
// $FlowFixMe[incompatible-return]
|
233
|
-
changes: {
|
234
|
-
added: added,
|
235
|
-
removed: removed
|
236
|
-
},
|
237
|
-
sources: new Sources({
|
238
|
-
extractFromFile: this._extractFromFile,
|
239
|
-
state: state
|
240
|
-
})
|
241
|
-
};
|
242
|
-
};
|
243
|
-
|
244
|
-
_proto.nodes = function* nodes() {
|
245
|
-
for (var _file2 in this._state) {
|
246
|
-
var entry = this._state[_file2];
|
247
|
-
|
248
|
-
for (var _i3 = 0, _Object$values = Object.values(entry.nodes); _i3 < _Object$values.length; _i3++) {
|
249
|
-
var node = _Object$values[_i3];
|
250
|
-
yield node;
|
251
|
-
}
|
252
|
-
}
|
253
|
-
};
|
254
|
-
|
255
|
-
_proto.serializeState = function serializeState() {
|
256
|
-
var serializedState = [];
|
257
|
-
|
258
|
-
for (var _file3 in this._state) {
|
259
|
-
serializedState.push({
|
260
|
-
file: _file3,
|
261
|
-
sources: this._state[_file3].sources
|
262
|
-
});
|
263
|
-
}
|
264
|
-
|
265
|
-
return serializedState;
|
266
|
-
};
|
267
|
-
|
268
|
-
return Sources;
|
269
|
-
}();
|
270
|
-
|
271
|
-
module.exports = Sources;
|
package/lib/runner/StrictMap.js
DELETED
@@ -1,134 +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
|
-
* @emails oncall+relay
|
10
|
-
*/
|
11
|
-
// flowlint ambiguous-object-type:error
|
12
|
-
'use strict';
|
13
|
-
|
14
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
15
|
-
|
16
|
-
var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator");
|
17
|
-
|
18
|
-
var _createForOfIteratorHelper2 = _interopRequireDefault(require("@babel/runtime/helpers/createForOfIteratorHelper"));
|
19
|
-
|
20
|
-
var invariant = require('invariant');
|
21
|
-
|
22
|
-
var StrictMap = /*#__PURE__*/function () {
|
23
|
-
function StrictMap(iterable) {
|
24
|
-
this._map = new Map(iterable);
|
25
|
-
return this;
|
26
|
-
}
|
27
|
-
|
28
|
-
var _proto = StrictMap.prototype;
|
29
|
-
|
30
|
-
_proto.clear = function clear() {
|
31
|
-
this._map.clear();
|
32
|
-
};
|
33
|
-
|
34
|
-
_proto["delete"] = function _delete(key) {
|
35
|
-
return this._map["delete"](key);
|
36
|
-
};
|
37
|
-
|
38
|
-
_proto.entries = function entries() {
|
39
|
-
return this._map.entries();
|
40
|
-
};
|
41
|
-
|
42
|
-
_proto.forEach = function forEach(callbackfn, thisArg) {
|
43
|
-
this._map.forEach(callbackfn, thisArg);
|
44
|
-
};
|
45
|
-
|
46
|
-
_proto.map = function map(f) {
|
47
|
-
var result = new StrictMap();
|
48
|
-
|
49
|
-
var _iterator = (0, _createForOfIteratorHelper2["default"])(this._map),
|
50
|
-
_step;
|
51
|
-
|
52
|
-
try {
|
53
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
54
|
-
var _step$value = _step.value,
|
55
|
-
key = _step$value[0],
|
56
|
-
val = _step$value[1];
|
57
|
-
result.set(key, f(val, key, this));
|
58
|
-
}
|
59
|
-
} catch (err) {
|
60
|
-
_iterator.e(err);
|
61
|
-
} finally {
|
62
|
-
_iterator.f();
|
63
|
-
}
|
64
|
-
|
65
|
-
return result;
|
66
|
-
};
|
67
|
-
|
68
|
-
_proto.asyncMap = /*#__PURE__*/function () {
|
69
|
-
var _asyncMap = _asyncToGenerator(function* (f) {
|
70
|
-
var _this = this;
|
71
|
-
|
72
|
-
var entryPromises = [];
|
73
|
-
|
74
|
-
var _iterator2 = (0, _createForOfIteratorHelper2["default"])(this._map),
|
75
|
-
_step2;
|
76
|
-
|
77
|
-
try {
|
78
|
-
var _loop = function _loop() {
|
79
|
-
var _step2$value = _step2.value,
|
80
|
-
key = _step2$value[0],
|
81
|
-
val = _step2$value[1];
|
82
|
-
entryPromises.push(f(val, key, _this).then(function (resultVal) {
|
83
|
-
return [key, resultVal];
|
84
|
-
}));
|
85
|
-
};
|
86
|
-
|
87
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
88
|
-
_loop();
|
89
|
-
}
|
90
|
-
} catch (err) {
|
91
|
-
_iterator2.e(err);
|
92
|
-
} finally {
|
93
|
-
_iterator2.f();
|
94
|
-
}
|
95
|
-
|
96
|
-
var entries = yield Promise.all(entryPromises);
|
97
|
-
return new StrictMap(entries);
|
98
|
-
});
|
99
|
-
|
100
|
-
function asyncMap(_x) {
|
101
|
-
return _asyncMap.apply(this, arguments);
|
102
|
-
}
|
103
|
-
|
104
|
-
return asyncMap;
|
105
|
-
}();
|
106
|
-
|
107
|
-
_proto.get = function get(key) {
|
108
|
-
!this.has(key) ? process.env.NODE_ENV !== "production" ? invariant(false, 'StrictMap: trying to read non-existent key `%s`.', String(key)) : invariant(false) : void 0; // $FlowFixMe[incompatible-return] - we checked the key exists
|
109
|
-
|
110
|
-
return this._map.get(key);
|
111
|
-
};
|
112
|
-
|
113
|
-
_proto.has = function has(key) {
|
114
|
-
return this._map.has(key);
|
115
|
-
};
|
116
|
-
|
117
|
-
_proto.keys = function keys() {
|
118
|
-
return this._map.keys();
|
119
|
-
};
|
120
|
-
|
121
|
-
_proto.set = function set(key, value) {
|
122
|
-
this._map.set(key, value);
|
123
|
-
|
124
|
-
return this;
|
125
|
-
};
|
126
|
-
|
127
|
-
_proto.values = function values() {
|
128
|
-
return this._map.values();
|
129
|
-
};
|
130
|
-
|
131
|
-
return StrictMap;
|
132
|
-
}();
|
133
|
-
|
134
|
-
module.exports = StrictMap;
|
@@ -1,39 +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
|
-
// flowlint ambiguous-object-type:error
|
11
|
-
'use strict';
|
12
|
-
|
13
|
-
var compileRelayArtifacts = require('../codegen/compileRelayArtifacts');
|
14
|
-
|
15
|
-
var ASTConvert = require('../core/ASTConvert');
|
16
|
-
|
17
|
-
var CompilerContext = require('../core/CompilerContext');
|
18
|
-
|
19
|
-
var RelayParser = require('../core/RelayParser');
|
20
|
-
|
21
|
-
function compileArtifacts(_ref) {
|
22
|
-
var schema = _ref.schema,
|
23
|
-
compilerTransforms = _ref.compilerTransforms,
|
24
|
-
inputDefinitions = _ref.definitions,
|
25
|
-
reporter = _ref.reporter,
|
26
|
-
typeGenerator = _ref.typeGenerator;
|
27
|
-
var definitions = ASTConvert.convertASTDocuments(schema, [{
|
28
|
-
kind: 'Document',
|
29
|
-
definitions: inputDefinitions
|
30
|
-
}], RelayParser.transform);
|
31
|
-
var compilerContext = new CompilerContext(schema).addAll(definitions);
|
32
|
-
var transformedTypeContext = compilerContext.applyTransforms(typeGenerator.transforms, reporter);
|
33
|
-
return {
|
34
|
-
transformedTypeContext: transformedTypeContext,
|
35
|
-
artifacts: compileRelayArtifacts(compilerContext, compilerTransforms, reporter)
|
36
|
-
};
|
37
|
-
}
|
38
|
-
|
39
|
-
module.exports = compileArtifacts;
|
package/lib/runner/extractAST.js
DELETED
@@ -1,77 +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
|
-
* @format
|
8
|
-
*
|
9
|
-
*/
|
10
|
-
// flowlint ambiguous-object-type:error
|
11
|
-
'use strict';
|
12
|
-
|
13
|
-
var JSModuleParser = require('../core/JSModuleParser');
|
14
|
-
|
15
|
-
var _require = require('graphql'),
|
16
|
-
parse = _require.parse,
|
17
|
-
print = _require.print;
|
18
|
-
|
19
|
-
var invariant = require('invariant');
|
20
|
-
|
21
|
-
function extractFromJS(baseDir, file) {
|
22
|
-
if (!file.exists) {
|
23
|
-
return null;
|
24
|
-
}
|
25
|
-
|
26
|
-
var f = {
|
27
|
-
relPath: file.name,
|
28
|
-
exists: true,
|
29
|
-
hash: file['content.sha1hex']
|
30
|
-
};
|
31
|
-
var fileFilter = JSModuleParser.getFileFilter(baseDir);
|
32
|
-
|
33
|
-
if (!fileFilter(f)) {
|
34
|
-
return null;
|
35
|
-
}
|
36
|
-
|
37
|
-
var result = JSModuleParser.parseFileWithSources(baseDir, f);
|
38
|
-
|
39
|
-
if (result == null || result.document.definitions.length === 0) {
|
40
|
-
return null;
|
41
|
-
}
|
42
|
-
|
43
|
-
var doc = result.document,
|
44
|
-
sources = result.sources;
|
45
|
-
var nodes = doc.definitions.map(function (def) {
|
46
|
-
if (def.kind === 'FragmentDefinition' || def.kind === 'OperationDefinition') {
|
47
|
-
return toASTRecord(def);
|
48
|
-
}
|
49
|
-
|
50
|
-
throw new Error("Unexpected definition kind: ".concat(def.kind));
|
51
|
-
});
|
52
|
-
return {
|
53
|
-
nodes: nodes,
|
54
|
-
sources: sources
|
55
|
-
};
|
56
|
-
}
|
57
|
-
|
58
|
-
function toASTRecord(node) {
|
59
|
-
return {
|
60
|
-
ast: node,
|
61
|
-
text: print(node)
|
62
|
-
};
|
63
|
-
}
|
64
|
-
|
65
|
-
function parseExecutableNode(text) {
|
66
|
-
var nodes = parse(text).definitions;
|
67
|
-
!(nodes.length === 1) ? process.env.NODE_ENV !== "production" ? invariant(false, 'expected exactly 1 definition') : invariant(false) : void 0;
|
68
|
-
var node = nodes[0];
|
69
|
-
!(node.kind === 'OperationDefinition' || node.kind === 'FragmentDefinition') ? process.env.NODE_ENV !== "production" ? invariant(false, 'expected an ExecutableDefinitionNode') : invariant(false) : void 0;
|
70
|
-
return node;
|
71
|
-
}
|
72
|
-
|
73
|
-
module.exports = {
|
74
|
-
parseExecutableNode: parseExecutableNode,
|
75
|
-
toASTRecord: toASTRecord,
|
76
|
-
extractFromJS: extractFromJS
|
77
|
-
};
|
@@ -1,82 +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
|
-
* @format
|
8
|
-
*
|
9
|
-
*/
|
10
|
-
// flowlint ambiguous-object-type:error
|
11
|
-
'use strict';
|
12
|
-
|
13
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
14
|
-
|
15
|
-
var _createForOfIteratorHelper2 = _interopRequireDefault(require("@babel/runtime/helpers/createForOfIteratorHelper"));
|
16
|
-
|
17
|
-
var _require = require('./GraphQLASTUtils'),
|
18
|
-
getName = _require.getName;
|
19
|
-
|
20
|
-
function getChangedNodeNames(projectStates, projects) {
|
21
|
-
var changedNames = new Set();
|
22
|
-
|
23
|
-
var _iterator = (0, _createForOfIteratorHelper2["default"])(projects),
|
24
|
-
_step;
|
25
|
-
|
26
|
-
try {
|
27
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
28
|
-
var projectType = _step.value;
|
29
|
-
var subConfig = projectStates.get(projectType);
|
30
|
-
|
31
|
-
var _iterator2 = (0, _createForOfIteratorHelper2["default"])(subConfig.initialDirty),
|
32
|
-
_step2;
|
33
|
-
|
34
|
-
try {
|
35
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
36
|
-
var name = _step2.value;
|
37
|
-
changedNames.add(name);
|
38
|
-
}
|
39
|
-
} catch (err) {
|
40
|
-
_iterator2.e(err);
|
41
|
-
} finally {
|
42
|
-
_iterator2.f();
|
43
|
-
}
|
44
|
-
|
45
|
-
var _iterator3 = (0, _createForOfIteratorHelper2["default"])(subConfig.changes.added),
|
46
|
-
_step3;
|
47
|
-
|
48
|
-
try {
|
49
|
-
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
50
|
-
var ast = _step3.value.ast;
|
51
|
-
changedNames.add(getName(ast));
|
52
|
-
}
|
53
|
-
} catch (err) {
|
54
|
-
_iterator3.e(err);
|
55
|
-
} finally {
|
56
|
-
_iterator3.f();
|
57
|
-
}
|
58
|
-
|
59
|
-
var _iterator4 = (0, _createForOfIteratorHelper2["default"])(subConfig.changes.removed),
|
60
|
-
_step4;
|
61
|
-
|
62
|
-
try {
|
63
|
-
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
64
|
-
var _ast = _step4.value.ast;
|
65
|
-
changedNames.add(getName(_ast));
|
66
|
-
}
|
67
|
-
} catch (err) {
|
68
|
-
_iterator4.e(err);
|
69
|
-
} finally {
|
70
|
-
_iterator4.f();
|
71
|
-
}
|
72
|
-
}
|
73
|
-
} catch (err) {
|
74
|
-
_iterator.e(err);
|
75
|
-
} finally {
|
76
|
-
_iterator.f();
|
77
|
-
}
|
78
|
-
|
79
|
-
return changedNames;
|
80
|
-
}
|
81
|
-
|
82
|
-
module.exports = getChangedNodeNames;
|
@@ -1,30 +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
|
-
// flowlint ambiguous-object-type:error
|
11
|
-
'use strict';
|
12
|
-
|
13
|
-
var _require = require('../core/Schema'),
|
14
|
-
create = _require.create;
|
15
|
-
|
16
|
-
var schemaCache = new Map();
|
17
|
-
|
18
|
-
function getSchemaInstance(getSchemaSource, getSchemaExtensions, schemaExtensions) {
|
19
|
-
var source = getSchemaSource();
|
20
|
-
var schema = schemaCache.get(source);
|
21
|
-
|
22
|
-
if (schema == null) {
|
23
|
-
schema = create(source, getSchemaExtensions(), schemaExtensions);
|
24
|
-
schemaCache.set(source, schema);
|
25
|
-
}
|
26
|
-
|
27
|
-
return schema;
|
28
|
-
}
|
29
|
-
|
30
|
-
module.exports = getSchemaInstance;
|
package/lib/runner/types.js
DELETED
@@ -1,12 +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
|
-
* @emails oncall+relay
|
10
|
-
*/
|
11
|
-
// flowlint ambiguous-object-type:error
|
12
|
-
'use strict';
|
@@ -1,27 +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
|
-
// flowlint ambiguous-object-type:error
|
11
|
-
'use strict';
|
12
|
-
|
13
|
-
var _require = require('../core/Schema'),
|
14
|
-
create = _require.create;
|
15
|
-
|
16
|
-
var fs = require('fs');
|
17
|
-
|
18
|
-
var _require2 = require('graphql'),
|
19
|
-
Source = _require2.Source;
|
20
|
-
|
21
|
-
var path = require('path');
|
22
|
-
|
23
|
-
var testSchemaPath = path.join(__dirname, 'testschema.graphql');
|
24
|
-
module.exports = {
|
25
|
-
TestSchema: create(new Source(fs.readFileSync(testSchemaPath, 'utf8'))),
|
26
|
-
testSchemaPath: testSchemaPath
|
27
|
-
};
|
@@ -1,30 +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
|
-
// flowlint ambiguous-object-type:error
|
11
|
-
'use strict';
|
12
|
-
|
13
|
-
var _require = require('../'),
|
14
|
-
Parser = _require.Parser,
|
15
|
-
convertASTDocuments = _require.convertASTDocuments;
|
16
|
-
|
17
|
-
var _require2 = require('graphql'),
|
18
|
-
parse = _require2.parse;
|
19
|
-
|
20
|
-
function parseGraphQLText(schema, text) {
|
21
|
-
var ast = parse(text);
|
22
|
-
var extendedSchema = schema.extend(ast);
|
23
|
-
var definitions = convertASTDocuments(extendedSchema, [ast], Parser.transform.bind(Parser));
|
24
|
-
return {
|
25
|
-
definitions: definitions,
|
26
|
-
schema: extendedSchema
|
27
|
-
};
|
28
|
-
}
|
29
|
-
|
30
|
-
module.exports = parseGraphQLText;
|