relay-compiler 0.0.0-main-bfcb5c59 → 0.0.0-main-4467ae84
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 -26
- package/win-x64/relay.exe +0 -0
- package/bin/RelayCompilerBin.js.flow +0 -168
- package/bin/RelayCompilerMain.js.flow +0 -513
- package/bin/__fixtures__/plugin-module.js.flow +0 -17
- package/bin/relay-compiler +0 -19066
- 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 -565
- 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 -1731
- 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 -486
- 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/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/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 -194
- 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 -255
- 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 -126
- package/transforms/ValidateServerOnlyDirectivesTransform.js.flow +0 -111
- 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 -152
- 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
@@ -1,434 +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 _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
14
|
-
|
15
|
-
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
16
|
-
|
17
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
18
|
-
|
19
|
-
var _require = require('../core/CompilerError'),
|
20
|
-
createCompilerError = _require.createCompilerError,
|
21
|
-
createUserError = _require.createUserError;
|
22
|
-
|
23
|
-
var getLiteralArgumentValues = require('../core/getLiteralArgumentValues');
|
24
|
-
|
25
|
-
var getNormalizationOperationName = require('../core/getNormalizationOperationName');
|
26
|
-
|
27
|
-
var IRTransformer = require('../core/IRTransformer');
|
28
|
-
|
29
|
-
var _require2 = require('relay-runtime'),
|
30
|
-
getModuleComponentKey = _require2.getModuleComponentKey,
|
31
|
-
getModuleOperationKey = _require2.getModuleOperationKey;
|
32
|
-
|
33
|
-
var SUPPORTED_ARGUMENT_NAME = 'supported';
|
34
|
-
var JS_FIELD_TYPE = 'JSDependency';
|
35
|
-
var JS_FIELD_MODULE_ARG = 'module';
|
36
|
-
var JS_FIELD_ID_ARG = 'id';
|
37
|
-
var JS_FIELD_NAME = 'js';
|
38
|
-
var SCHEMA_EXTENSION = "\n directive @match(key: String) on FIELD\n\n directive @module(\n name: String!\n ) on FRAGMENT_SPREAD\n";
|
39
|
-
|
40
|
-
/**
|
41
|
-
* This transform rewrites LinkedField nodes with @match and rewrites them
|
42
|
-
* into `LinkedField` nodes with a `supported` argument.
|
43
|
-
*/
|
44
|
-
function matchTransform(context) {
|
45
|
-
return IRTransformer.transform(context, {
|
46
|
-
// TODO: type IRTransformer to allow changing result type
|
47
|
-
FragmentSpread: visitFragmentSpread,
|
48
|
-
LinkedField: visitLinkedField,
|
49
|
-
InlineFragment: visitInlineFragment,
|
50
|
-
ScalarField: visitScalarField
|
51
|
-
}, function (node) {
|
52
|
-
return {
|
53
|
-
documentName: node.name,
|
54
|
-
matchesForPath: new Map(),
|
55
|
-
moduleKey: null,
|
56
|
-
parentType: node.type,
|
57
|
-
path: []
|
58
|
-
};
|
59
|
-
});
|
60
|
-
}
|
61
|
-
|
62
|
-
function visitInlineFragment(node, state) {
|
63
|
-
return this.traverse(node, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, state), {}, {
|
64
|
-
parentType: node.typeCondition
|
65
|
-
}));
|
66
|
-
}
|
67
|
-
|
68
|
-
function visitScalarField(field) {
|
69
|
-
var context = this.getContext();
|
70
|
-
var schema = context.getSchema();
|
71
|
-
|
72
|
-
if (field.name === JS_FIELD_NAME) {
|
73
|
-
var jsModuleType = schema.getTypeFromString(JS_FIELD_TYPE);
|
74
|
-
|
75
|
-
if (jsModuleType == null || !schema.isServerType(jsModuleType)) {
|
76
|
-
throw new createUserError("'".concat(JS_FIELD_NAME, "' should be defined on the server schema."), [field.loc]);
|
77
|
-
}
|
78
|
-
|
79
|
-
if (schema.isScalar(jsModuleType) && schema.areEqualTypes(schema.getRawType(field.type), jsModuleType)) {
|
80
|
-
throw new createUserError("Direct use of the '".concat(JS_FIELD_NAME, "' field is not allowed, use ") + '@match/@module instead.', [field.loc]);
|
81
|
-
}
|
82
|
-
}
|
83
|
-
|
84
|
-
return field;
|
85
|
-
}
|
86
|
-
|
87
|
-
function visitLinkedField(node, state) {
|
88
|
-
var context = this.getContext();
|
89
|
-
var schema = context.getSchema();
|
90
|
-
var matchDirective = node.directives.find(function (directive) {
|
91
|
-
return directive.name === 'match';
|
92
|
-
});
|
93
|
-
var moduleKey = null;
|
94
|
-
|
95
|
-
if (matchDirective != null) {
|
96
|
-
var _getLiteralArgumentVa = getLiteralArgumentValues(matchDirective.args);
|
97
|
-
|
98
|
-
moduleKey = _getLiteralArgumentVa.key;
|
99
|
-
|
100
|
-
if (moduleKey != null && (typeof moduleKey !== 'string' || !moduleKey.startsWith(state.documentName))) {
|
101
|
-
var _matchDirective$args$;
|
102
|
-
|
103
|
-
throw createUserError("Expected the 'key' argument of @match to be a literal string starting " + "with the document name, e.g. '".concat(state.documentName, "_<localName>'."), [((_matchDirective$args$ = matchDirective.args.find(function (arg) {
|
104
|
-
return arg.name === 'key';
|
105
|
-
})) !== null && _matchDirective$args$ !== void 0 ? _matchDirective$args$ : matchDirective).loc]);
|
106
|
-
}
|
107
|
-
}
|
108
|
-
|
109
|
-
state.path.push(node);
|
110
|
-
var transformedNode = this.traverse(node, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, state), {}, {
|
111
|
-
moduleKey: moduleKey,
|
112
|
-
parentType: node.type
|
113
|
-
}));
|
114
|
-
state.path.pop();
|
115
|
-
|
116
|
-
if (matchDirective == null) {
|
117
|
-
return transformedNode;
|
118
|
-
}
|
119
|
-
|
120
|
-
var parentType = state.parentType;
|
121
|
-
var rawType = schema.getRawType(parentType);
|
122
|
-
|
123
|
-
if (!(schema.isInterface(rawType) || schema.isObject(rawType))) {
|
124
|
-
throw createUserError("@match used on incompatible field '".concat(transformedNode.name, "'.") + '@match may only be used with fields whose parent type is an ' + "interface or object, got invalid type '".concat(schema.getTypeString(parentType), "'."), [node.loc]);
|
125
|
-
}
|
126
|
-
|
127
|
-
var currentField = schema.getFieldConfig(schema.expectField(schema.assertCompositeType(rawType), transformedNode.name));
|
128
|
-
var supportedArgumentDefinition = currentField.args.find(function (_ref) {
|
129
|
-
var name = _ref.name;
|
130
|
-
return name === SUPPORTED_ARGUMENT_NAME;
|
131
|
-
});
|
132
|
-
|
133
|
-
if (supportedArgumentDefinition == null) {
|
134
|
-
if (moduleKey == null) {
|
135
|
-
throw createUserError('@match on a field without the `supported` argument is a no-op, please remove the `@match`.', [node.loc]);
|
136
|
-
}
|
137
|
-
|
138
|
-
return transformedNode;
|
139
|
-
}
|
140
|
-
|
141
|
-
var supportedArgType = schema.getNullableType(supportedArgumentDefinition.type);
|
142
|
-
var supportedArgOfType = supportedArgType != null && schema.isList(supportedArgType) ? schema.getListItemType(supportedArgType) : null;
|
143
|
-
|
144
|
-
if (supportedArgType == null || supportedArgOfType == null || !schema.isString(schema.getNullableType(supportedArgOfType))) {
|
145
|
-
throw createUserError("@match used on incompatible field '".concat(transformedNode.name, "'. ") + '@match may only be used with fields that accept a ' + "'supported: [String!]!' argument.", [node.loc]);
|
146
|
-
}
|
147
|
-
|
148
|
-
var rawFieldType = schema.getRawType(transformedNode.type);
|
149
|
-
|
150
|
-
if (!schema.isAbstractType(rawFieldType)) {
|
151
|
-
throw createUserError("@match used on incompatible field '".concat(transformedNode.name, "'.") + '@match may only be used with fields that return a union or interface.', [node.loc]);
|
152
|
-
}
|
153
|
-
|
154
|
-
var seenTypes = new Map();
|
155
|
-
var selections = [];
|
156
|
-
transformedNode.selections.forEach(function (matchSelection) {
|
157
|
-
if (matchSelection.kind === 'ScalarField' && matchSelection.name === '__typename') {
|
158
|
-
selections.push(matchSelection);
|
159
|
-
return;
|
160
|
-
}
|
161
|
-
|
162
|
-
var moduleImport = matchSelection.kind === 'InlineFragment' ? matchSelection.selections[0] : null;
|
163
|
-
|
164
|
-
if (matchSelection.kind !== 'InlineFragment' || moduleImport == null || moduleImport.kind !== 'ModuleImport') {
|
165
|
-
throw createUserError('Invalid @match selection: all selections should be ' + 'fragment spreads with @module.', [matchSelection.loc]);
|
166
|
-
}
|
167
|
-
|
168
|
-
var matchedType = matchSelection.typeCondition;
|
169
|
-
seenTypes.set(matchedType, matchSelection);
|
170
|
-
selections.push(matchSelection);
|
171
|
-
});
|
172
|
-
|
173
|
-
if (seenTypes.size === 0) {
|
174
|
-
throw createUserError('Invalid @match selection: expected at least one @module selection. ' + "Remove @match or add a '...Fragment @module()' selection.", [matchDirective.loc]);
|
175
|
-
}
|
176
|
-
|
177
|
-
var supportedArg = transformedNode.args.find(function (arg) {
|
178
|
-
return arg.name === SUPPORTED_ARGUMENT_NAME;
|
179
|
-
});
|
180
|
-
|
181
|
-
if (supportedArg != null) {
|
182
|
-
throw createUserError("Invalid @match selection: the '".concat(SUPPORTED_ARGUMENT_NAME, "' argument ") + 'is automatically added and cannot be supplied explicitly.', [supportedArg.loc]);
|
183
|
-
}
|
184
|
-
|
185
|
-
return {
|
186
|
-
kind: 'LinkedField',
|
187
|
-
alias: transformedNode.alias,
|
188
|
-
args: [].concat((0, _toConsumableArray2["default"])(transformedNode.args), [{
|
189
|
-
kind: 'Argument',
|
190
|
-
name: SUPPORTED_ARGUMENT_NAME,
|
191
|
-
type: supportedArgumentDefinition.type,
|
192
|
-
value: {
|
193
|
-
kind: 'Literal',
|
194
|
-
loc: node.loc,
|
195
|
-
value: Array.from(seenTypes.keys()).map(function (type) {
|
196
|
-
return schema.getTypeString(type);
|
197
|
-
})
|
198
|
-
},
|
199
|
-
loc: node.loc
|
200
|
-
}]),
|
201
|
-
connection: false,
|
202
|
-
directives: [],
|
203
|
-
handles: null,
|
204
|
-
loc: node.loc,
|
205
|
-
metadata: null,
|
206
|
-
name: transformedNode.name,
|
207
|
-
type: transformedNode.type,
|
208
|
-
selections: selections
|
209
|
-
};
|
210
|
-
} // Transform @module
|
211
|
-
|
212
|
-
|
213
|
-
function visitFragmentSpread(spread, _ref2) {
|
214
|
-
var _moduleDirective$args2, _moduleDirective$args3, _moduleDirective$args4, _moduleDirective$args5, _moduleDirective$args6, _moduleDirective$args7;
|
215
|
-
|
216
|
-
var documentName = _ref2.documentName,
|
217
|
-
path = _ref2.path,
|
218
|
-
matchesForPath = _ref2.matchesForPath,
|
219
|
-
moduleKeyFromParent = _ref2.moduleKey;
|
220
|
-
var transformedNode = this.traverse(spread);
|
221
|
-
var moduleDirective = transformedNode.directives.find(function (directive) {
|
222
|
-
return directive.name === 'module';
|
223
|
-
});
|
224
|
-
|
225
|
-
if (moduleDirective == null) {
|
226
|
-
return transformedNode;
|
227
|
-
}
|
228
|
-
|
229
|
-
if (spread.args.length !== 0) {
|
230
|
-
var _spread$args$;
|
231
|
-
|
232
|
-
throw createUserError('@module does not support @arguments.', [(_spread$args$ = spread.args[0]) === null || _spread$args$ === void 0 ? void 0 : _spread$args$.loc].filter(Boolean));
|
233
|
-
}
|
234
|
-
|
235
|
-
var context = this.getContext();
|
236
|
-
var schema = context.getSchema();
|
237
|
-
var jsModuleType = schema.asScalarFieldType(schema.getTypeFromString(JS_FIELD_TYPE));
|
238
|
-
|
239
|
-
if (jsModuleType == null || !schema.isServerType(jsModuleType)) {
|
240
|
-
throw new createUserError("'".concat(JS_FIELD_NAME, "' should be defined on the server schema."), [spread.loc]);
|
241
|
-
}
|
242
|
-
|
243
|
-
if (!schema.isScalar(jsModuleType)) {
|
244
|
-
throw createUserError('Using @module requires the schema to define a scalar ' + "'".concat(JS_FIELD_TYPE, "' type."));
|
245
|
-
}
|
246
|
-
|
247
|
-
var fragment = context.getFragment(spread.name, spread.loc);
|
248
|
-
|
249
|
-
if (!schema.isObject(fragment.type)) {
|
250
|
-
throw createUserError("@module used on invalid fragment spread '...".concat(spread.name, "'. @module ") + 'may only be used with fragments on a concrete (object) type, ' + "but the fragment has abstract type '".concat(schema.getTypeString(fragment.type), "'."), [spread.loc, fragment.loc]);
|
251
|
-
}
|
252
|
-
|
253
|
-
var field = schema.getFieldByName(fragment.type, JS_FIELD_NAME);
|
254
|
-
|
255
|
-
if (!field) {
|
256
|
-
throw createUserError("@module used on invalid fragment spread '...".concat(spread.name, "'. @module ") + "requires the fragment type '".concat(schema.getTypeString(fragment.type), "' to have a ") + "'".concat(JS_FIELD_NAME, "(").concat(JS_FIELD_MODULE_ARG, ": String! ") + "[".concat(JS_FIELD_ID_ARG, ": String]): ").concat(JS_FIELD_TYPE, "' field (your ") + "schema may choose to omit the 'id' argument but if present it " + "must accept a 'String').", [moduleDirective.loc]);
|
257
|
-
}
|
258
|
-
|
259
|
-
var jsField = schema.getFieldConfig(field);
|
260
|
-
var jsFieldModuleArg = jsField ? jsField.args.find(function (arg) {
|
261
|
-
return arg.name === JS_FIELD_MODULE_ARG;
|
262
|
-
}) : null;
|
263
|
-
var jsFieldIdArg = jsField ? jsField.args.find(function (arg) {
|
264
|
-
return arg.name === JS_FIELD_ID_ARG;
|
265
|
-
}) : null;
|
266
|
-
|
267
|
-
if (jsFieldModuleArg == null || !schema.isString(schema.getNullableType(jsFieldModuleArg.type)) || jsFieldIdArg != null && !schema.isString(jsFieldIdArg.type) || jsField.type !== jsModuleType) {
|
268
|
-
throw createUserError("@module used on invalid fragment spread '...".concat(spread.name, "'. @module ") + "requires the fragment type '".concat(schema.getTypeString(fragment.type), "' to have a ") + "'".concat(JS_FIELD_NAME, "(").concat(JS_FIELD_MODULE_ARG, ": String! ") + "[".concat(JS_FIELD_ID_ARG, ": String]): ").concat(JS_FIELD_TYPE, "' field (your ") + "schema may choose to omit the 'id' argument but if present it " + "must accept a 'String').", [moduleDirective.loc]);
|
269
|
-
}
|
270
|
-
|
271
|
-
if (spread.directives.length !== 1) {
|
272
|
-
throw createUserError("@module used on invalid fragment spread '...".concat(spread.name, "'. @module ") + 'may not have additional directives.', [spread.loc]);
|
273
|
-
}
|
274
|
-
|
275
|
-
var _getLiteralArgumentVa2 = getLiteralArgumentValues(moduleDirective.args),
|
276
|
-
moduleName = _getLiteralArgumentVa2.name;
|
277
|
-
|
278
|
-
if (typeof moduleName !== 'string') {
|
279
|
-
var _moduleDirective$args;
|
280
|
-
|
281
|
-
throw createUserError("Expected the 'name' argument of @module to be a literal string", [((_moduleDirective$args = moduleDirective.args.find(function (arg) {
|
282
|
-
return arg.name === 'name';
|
283
|
-
})) !== null && _moduleDirective$args !== void 0 ? _moduleDirective$args : spread).loc]);
|
284
|
-
}
|
285
|
-
|
286
|
-
var parentField = path[path.length - 1];
|
287
|
-
var moduleKey = moduleKeyFromParent !== null && moduleKeyFromParent !== void 0 ? moduleKeyFromParent : documentName;
|
288
|
-
var aliasPath = path.map(function (x) {
|
289
|
-
return x.alias;
|
290
|
-
}).join('.');
|
291
|
-
var moduleId = aliasPath === '' ? documentName : "".concat(documentName, ".").concat(aliasPath);
|
292
|
-
var typeName = schema.getTypeString(fragment.type);
|
293
|
-
var matches = matchesForPath.get(aliasPath);
|
294
|
-
|
295
|
-
if (matches == null) {
|
296
|
-
var _parentField$loc;
|
297
|
-
|
298
|
-
if (matchesForPath.size !== 0) {
|
299
|
-
var existingMatchWithKey = Array.from(matchesForPath.values()).find(function (entry) {
|
300
|
-
return entry.key === moduleKey;
|
301
|
-
});
|
302
|
-
|
303
|
-
if (existingMatchWithKey != null) {
|
304
|
-
if (parentField == null) {
|
305
|
-
throw createCompilerError('Cannot have @module selections at multiple paths unless the selections are within fields.', [spread.loc]);
|
306
|
-
}
|
307
|
-
|
308
|
-
throw createUserError('Invalid @module selection: documents with multiple fields ' + "containing 3D selections must specify a unique 'key' value " + "for each field: use '".concat(parentField.alias, " @match(key: \"").concat(documentName, "_<localName>\")'."), [parentField.loc]);
|
309
|
-
}
|
310
|
-
}
|
311
|
-
|
312
|
-
matches = {
|
313
|
-
key: moduleKey,
|
314
|
-
location: (_parentField$loc = parentField === null || parentField === void 0 ? void 0 : parentField.loc) !== null && _parentField$loc !== void 0 ? _parentField$loc : spread.loc,
|
315
|
-
types: new Map()
|
316
|
-
};
|
317
|
-
matchesForPath.set(aliasPath, matches);
|
318
|
-
}
|
319
|
-
|
320
|
-
if (moduleKey !== matches.key) {
|
321
|
-
var _parentField$loc2;
|
322
|
-
|
323
|
-
// The user can't override the key locally (per @module),
|
324
|
-
// so this is just an internal sanity check
|
325
|
-
throw createCompilerError('Invalid @module selection: expected all selections at path ' + "'".concat(aliasPath, " to have the same 'key', got '").concat(moduleKey, "' and '").concat(matches.key, "'."), [(_parentField$loc2 = parentField === null || parentField === void 0 ? void 0 : parentField.loc) !== null && _parentField$loc2 !== void 0 ? _parentField$loc2 : spread.loc]);
|
326
|
-
}
|
327
|
-
|
328
|
-
var previousMatchForType = matches.types.get(typeName);
|
329
|
-
|
330
|
-
if (previousMatchForType != null && (previousMatchForType.fragment !== spread.name || previousMatchForType.module !== moduleName)) {
|
331
|
-
throw createUserError('Invalid @module selection: concrete type ' + "'".concat(typeName, "' was matched multiple times at path ") + "'".concat(aliasPath, "' but with a different fragment or module name."), [spread.loc, previousMatchForType.location]);
|
332
|
-
}
|
333
|
-
|
334
|
-
matches.types.set(typeName, {
|
335
|
-
location: spread.loc,
|
336
|
-
fragment: spread.name,
|
337
|
-
module: moduleName
|
338
|
-
});
|
339
|
-
var normalizationName = getNormalizationOperationName(spread.name) + '.graphql';
|
340
|
-
var componentKey = getModuleComponentKey(moduleKey);
|
341
|
-
var componentField = {
|
342
|
-
alias: componentKey,
|
343
|
-
args: [{
|
344
|
-
kind: 'Argument',
|
345
|
-
name: JS_FIELD_MODULE_ARG,
|
346
|
-
type: jsFieldModuleArg.type,
|
347
|
-
value: {
|
348
|
-
kind: 'Literal',
|
349
|
-
loc: (_moduleDirective$args2 = (_moduleDirective$args3 = moduleDirective.args[0]) === null || _moduleDirective$args3 === void 0 ? void 0 : _moduleDirective$args3.loc) !== null && _moduleDirective$args2 !== void 0 ? _moduleDirective$args2 : moduleDirective.loc,
|
350
|
-
value: moduleName
|
351
|
-
},
|
352
|
-
loc: moduleDirective.loc
|
353
|
-
}, jsFieldIdArg != null ? {
|
354
|
-
kind: 'Argument',
|
355
|
-
name: JS_FIELD_ID_ARG,
|
356
|
-
type: jsFieldIdArg.type,
|
357
|
-
value: {
|
358
|
-
kind: 'Literal',
|
359
|
-
loc: (_moduleDirective$args4 = (_moduleDirective$args5 = moduleDirective.args[0]) === null || _moduleDirective$args5 === void 0 ? void 0 : _moduleDirective$args5.loc) !== null && _moduleDirective$args4 !== void 0 ? _moduleDirective$args4 : moduleDirective.loc,
|
360
|
-
value: moduleId
|
361
|
-
},
|
362
|
-
loc: moduleDirective.loc
|
363
|
-
} : null].filter(Boolean),
|
364
|
-
directives: [],
|
365
|
-
handles: null,
|
366
|
-
kind: 'ScalarField',
|
367
|
-
loc: moduleDirective.loc,
|
368
|
-
metadata: {
|
369
|
-
skipNormalizationNode: true
|
370
|
-
},
|
371
|
-
name: JS_FIELD_NAME,
|
372
|
-
type: jsModuleType
|
373
|
-
};
|
374
|
-
var operationKey = getModuleOperationKey(moduleKey);
|
375
|
-
var operationField = {
|
376
|
-
alias: operationKey,
|
377
|
-
args: [{
|
378
|
-
kind: 'Argument',
|
379
|
-
name: JS_FIELD_MODULE_ARG,
|
380
|
-
type: jsFieldModuleArg.type,
|
381
|
-
value: {
|
382
|
-
kind: 'Literal',
|
383
|
-
loc: moduleDirective.loc,
|
384
|
-
value: normalizationName
|
385
|
-
},
|
386
|
-
loc: moduleDirective.loc
|
387
|
-
}, jsFieldIdArg != null ? {
|
388
|
-
kind: 'Argument',
|
389
|
-
name: JS_FIELD_ID_ARG,
|
390
|
-
type: jsFieldIdArg.type,
|
391
|
-
value: {
|
392
|
-
kind: 'Literal',
|
393
|
-
loc: (_moduleDirective$args6 = (_moduleDirective$args7 = moduleDirective.args[0]) === null || _moduleDirective$args7 === void 0 ? void 0 : _moduleDirective$args7.loc) !== null && _moduleDirective$args6 !== void 0 ? _moduleDirective$args6 : moduleDirective.loc,
|
394
|
-
value: moduleId
|
395
|
-
},
|
396
|
-
loc: moduleDirective.loc
|
397
|
-
} : null].filter(Boolean),
|
398
|
-
directives: [],
|
399
|
-
handles: null,
|
400
|
-
kind: 'ScalarField',
|
401
|
-
loc: moduleDirective.loc,
|
402
|
-
metadata: {
|
403
|
-
skipNormalizationNode: true
|
404
|
-
},
|
405
|
-
name: JS_FIELD_NAME,
|
406
|
-
type: jsModuleType
|
407
|
-
};
|
408
|
-
return {
|
409
|
-
kind: 'InlineFragment',
|
410
|
-
directives: [],
|
411
|
-
loc: moduleDirective.loc,
|
412
|
-
metadata: null,
|
413
|
-
selections: [{
|
414
|
-
kind: 'ModuleImport',
|
415
|
-
loc: moduleDirective.loc,
|
416
|
-
key: moduleKey,
|
417
|
-
id: moduleId,
|
418
|
-
module: moduleName,
|
419
|
-
sourceDocument: documentName,
|
420
|
-
name: spread.name,
|
421
|
-
selections: [(0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, spread), {}, {
|
422
|
-
directives: spread.directives.filter(function (directive) {
|
423
|
-
return directive !== moduleDirective;
|
424
|
-
})
|
425
|
-
}), operationField, componentField]
|
426
|
-
}],
|
427
|
-
typeCondition: fragment.type
|
428
|
-
};
|
429
|
-
}
|
430
|
-
|
431
|
-
module.exports = {
|
432
|
-
SCHEMA_EXTENSION: SCHEMA_EXTENSION,
|
433
|
-
transform: matchTransform
|
434
|
-
};
|
@@ -1,158 +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
|
-
'use strict';
|
12
|
-
|
13
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
14
|
-
|
15
|
-
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
16
|
-
|
17
|
-
var _require = require('../core/CompilerError'),
|
18
|
-
createCompilerError = _require.createCompilerError,
|
19
|
-
createUserError = _require.createUserError;
|
20
|
-
|
21
|
-
var IRTransformer = require('../core/IRTransformer');
|
22
|
-
|
23
|
-
var _require2 = require('relay-runtime'),
|
24
|
-
RelayFeatureFlags = _require2.RelayFeatureFlags;
|
25
|
-
|
26
|
-
var FLIGHT_FIELD_COMPONENT_ARGUMENT_TYPE = 'String';
|
27
|
-
var FLIGHT_FIELD_COMPONENT_ARGUMENT_NAME = 'component';
|
28
|
-
var FLIGHT_FIELD_PROPS_ARGUMENT_NAME = 'props';
|
29
|
-
var FLIGHT_FIELD_PROPS_TYPE = 'ReactFlightProps';
|
30
|
-
var FLIGHT_FIELD_RETURN_TYPE = 'ReactFlightComponent';
|
31
|
-
|
32
|
-
/**
|
33
|
-
* Experimental transform for React Flight.
|
34
|
-
*/
|
35
|
-
function reactFlightComponentTransform(context) {
|
36
|
-
var schema = context.getSchema();
|
37
|
-
var propsType = schema.getTypeFromString(FLIGHT_FIELD_PROPS_TYPE);
|
38
|
-
propsType = propsType ? schema.asInputType(propsType) : null;
|
39
|
-
var componentType = schema.getTypeFromString(FLIGHT_FIELD_RETURN_TYPE);
|
40
|
-
componentType = componentType ? schema.asScalarFieldType(componentType) : null;
|
41
|
-
|
42
|
-
if (!RelayFeatureFlags.ENABLE_REACT_FLIGHT_COMPONENT_FIELD || propsType == null || componentType == null) {
|
43
|
-
return context;
|
44
|
-
}
|
45
|
-
|
46
|
-
var types = {
|
47
|
-
propsType: propsType,
|
48
|
-
componentType: componentType
|
49
|
-
};
|
50
|
-
return IRTransformer.transform(context, {
|
51
|
-
ScalarField: visitScalarField,
|
52
|
-
LinkedField: visitLinkedField,
|
53
|
-
InlineFragment: visitInlineFragment
|
54
|
-
}, function (node) {
|
55
|
-
return {
|
56
|
-
parentType: node.type,
|
57
|
-
types: types
|
58
|
-
};
|
59
|
-
});
|
60
|
-
}
|
61
|
-
|
62
|
-
function visitInlineFragment(fragment, state) {
|
63
|
-
var _fragment$typeConditi;
|
64
|
-
|
65
|
-
return this.traverse(fragment, {
|
66
|
-
parentType: (_fragment$typeConditi = fragment.typeCondition) !== null && _fragment$typeConditi !== void 0 ? _fragment$typeConditi : state.parentType,
|
67
|
-
types: state.types
|
68
|
-
});
|
69
|
-
}
|
70
|
-
|
71
|
-
function visitLinkedField(field, state) {
|
72
|
-
return this.traverse(field, {
|
73
|
-
parentType: field.type,
|
74
|
-
types: state.types
|
75
|
-
});
|
76
|
-
}
|
77
|
-
|
78
|
-
function visitScalarField(field, state) {
|
79
|
-
// use the return type to quickly determine if this is a flight field
|
80
|
-
var schema = this.getContext().getSchema();
|
81
|
-
|
82
|
-
if (schema.getRawType(field.type) !== state.types.componentType) {
|
83
|
-
return field;
|
84
|
-
} // get the name of the component that provides this field
|
85
|
-
|
86
|
-
|
87
|
-
var clientField = schema.getFieldByName(state.parentType, field.name);
|
88
|
-
|
89
|
-
if (clientField == null) {
|
90
|
-
throw createCompilerError("Definition not found for field '".concat(schema.getTypeString(state.parentType), ".").concat(field.name, "'"), [field.loc]);
|
91
|
-
}
|
92
|
-
|
93
|
-
var componentDirective = clientField.directives.find(function (directive) {
|
94
|
-
return directive.name === 'react_flight_component';
|
95
|
-
});
|
96
|
-
var componentNameArg = componentDirective === null || componentDirective === void 0 ? void 0 : componentDirective.args.find(function (arg) {
|
97
|
-
return arg.name === 'name';
|
98
|
-
});
|
99
|
-
|
100
|
-
if (componentNameArg == null || componentNameArg.value.kind !== 'StringValue' || typeof componentNameArg.value.value !== 'string') {
|
101
|
-
throw createUserError('Invalid Flight field, expected the schema extension to specify ' + "the component's module name with the '@react_flight_component' directive", [field.loc]);
|
102
|
-
}
|
103
|
-
|
104
|
-
var componentName = componentNameArg.value.value; // validate that the parent type has a `flight(component, props)` field
|
105
|
-
|
106
|
-
var flightField = schema.getFieldByName(state.parentType, 'flight');
|
107
|
-
|
108
|
-
if (flightField == null) {
|
109
|
-
throw createUserError("Invalid Flight field, expected the parent type '".concat(schema.getTypeString(state.parentType), "' ") + "to define a 'flight(component: String, props: ReactFlightProps): ReactFlightComponent' field", [field.loc]);
|
110
|
-
}
|
111
|
-
|
112
|
-
var componentArg = flightField.args.get(FLIGHT_FIELD_COMPONENT_ARGUMENT_NAME);
|
113
|
-
var propsArg = flightField.args.get(FLIGHT_FIELD_PROPS_ARGUMENT_NAME);
|
114
|
-
|
115
|
-
if (componentArg == null || propsArg == null || schema.getRawType(componentArg.type) !== schema.getTypeFromString(FLIGHT_FIELD_COMPONENT_ARGUMENT_TYPE) || schema.getRawType(propsArg.type) !== state.types.propsType || schema.getRawType(flightField.type) !== state.types.componentType) {
|
116
|
-
throw createUserError("Invalid Flight field, expected the parent type '".concat(schema.getTypeString(state.parentType), "' ") + "to define a 'flight(component: String, props: ReactFlightProps): ReactFlightComponent' field", [field.loc]);
|
117
|
-
}
|
118
|
-
|
119
|
-
return (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, field), {}, {
|
120
|
-
name: 'flight',
|
121
|
-
args: [{
|
122
|
-
kind: 'Argument',
|
123
|
-
loc: field.loc,
|
124
|
-
name: FLIGHT_FIELD_COMPONENT_ARGUMENT_NAME,
|
125
|
-
type: schema.getTypeFromString(FLIGHT_FIELD_COMPONENT_ARGUMENT_TYPE),
|
126
|
-
value: {
|
127
|
-
kind: 'Literal',
|
128
|
-
value: componentName,
|
129
|
-
loc: field.loc
|
130
|
-
}
|
131
|
-
}, {
|
132
|
-
kind: 'Argument',
|
133
|
-
loc: field.loc,
|
134
|
-
name: FLIGHT_FIELD_PROPS_ARGUMENT_NAME,
|
135
|
-
type: state.types.propsType,
|
136
|
-
value: {
|
137
|
-
kind: 'ObjectValue',
|
138
|
-
fields: field.args.map(function (arg) {
|
139
|
-
return {
|
140
|
-
kind: 'ObjectFieldValue',
|
141
|
-
loc: arg.loc,
|
142
|
-
name: arg.name,
|
143
|
-
value: arg.value
|
144
|
-
};
|
145
|
-
}),
|
146
|
-
loc: field.loc
|
147
|
-
}
|
148
|
-
}],
|
149
|
-
metadata: (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, field.metadata || {}), {}, {
|
150
|
-
flight: true
|
151
|
-
}),
|
152
|
-
type: state.types.componentType
|
153
|
-
});
|
154
|
-
}
|
155
|
-
|
156
|
-
module.exports = {
|
157
|
-
transform: reactFlightComponentTransform
|
158
|
-
};
|