relay-compiler 7.0.0 → 9.1.0
Sign up to get free protection for your applications and to get access to all the features.
- package/bin/RelayCompilerBin.js.flow +169 -0
- package/bin/RelayCompilerMain.js.flow +508 -0
- package/bin/__fixtures__/plugin-module.js.flow +17 -0
- package/bin/relay-compiler +8554 -8142
- package/codegen/CodegenDirectory.js.flow +375 -0
- package/codegen/CodegenRunner.js.flow +431 -0
- package/codegen/CodegenTypes.js.flow +28 -0
- package/codegen/CodegenWatcher.js.flow +254 -0
- package/codegen/NormalizationCodeGenerator.js.flow +499 -0
- package/codegen/ReaderCodeGenerator.js.flow +453 -0
- package/codegen/RelayCodeGenerator.js.flow +76 -0
- package/codegen/RelayFileWriter.js.flow +366 -0
- package/codegen/SourceControl.js.flow +58 -0
- package/codegen/compileRelayArtifacts.js.flow +182 -0
- package/codegen/createPrintRequireModuleDependency.js.flow +21 -0
- package/codegen/writeRelayGeneratedFile.js.flow +194 -0
- package/core/ASTCache.js.flow +73 -0
- package/core/ASTConvert.js.flow +233 -0
- package/core/CompilerContext.js.flow +190 -0
- package/core/CompilerError.js.flow +250 -0
- package/core/DotGraphQLParser.js.flow +39 -0
- package/core/GraphQLCompilerProfiler.js.flow +341 -0
- package/core/GraphQLDerivedFromMetadata.js.flow +48 -0
- package/core/GraphQLWatchmanClient.js.flow +111 -0
- package/core/IR.js.flow +329 -0
- package/core/IRPrinter.js.flow +488 -0
- package/core/IRTransformer.js.flow +377 -0
- package/core/IRValidator.js.flow +260 -0
- package/core/IRVisitor.js.flow +150 -0
- package/core/JSModuleParser.js.flow +24 -0
- package/core/RelayCompilerScope.js.flow +199 -0
- package/core/RelayFindGraphQLTags.js.flow +119 -0
- package/core/RelayGraphQLEnumsGenerator.js.flow +55 -0
- package/core/RelayIRTransforms.js.flow +130 -0
- package/core/RelayParser.js.flow +1759 -0
- package/core/RelaySourceModuleParser.js.flow +135 -0
- package/core/Schema.js.flow +1985 -0
- package/core/SchemaUtils.js.flow +109 -0
- package/core/filterContextForNode.js.flow +50 -0
- package/core/getFieldDefinition.js.flow +156 -0
- package/core/getIdentifierForArgumentValue.js.flow +49 -0
- package/core/getIdentifierForSelection.js.flow +69 -0
- package/core/getLiteralArgumentValues.js.flow +32 -0
- package/core/getNormalizationOperationName.js.flow +19 -0
- package/core/inferRootArgumentDefinitions.js.flow +323 -0
- package/index.js +1 -1
- package/index.js.flow +202 -0
- package/language/RelayLanguagePluginInterface.js.flow +283 -0
- package/language/javascript/FindGraphQLTags.js.flow +233 -0
- package/language/javascript/RelayFlowBabelFactories.js.flow +180 -0
- package/language/javascript/RelayFlowGenerator.js.flow +1040 -0
- package/language/javascript/RelayFlowTypeTransformers.js.flow +184 -0
- package/language/javascript/RelayLanguagePluginJavaScript.js.flow +34 -0
- package/language/javascript/formatGeneratedModule.js.flow +65 -0
- package/lib/bin/RelayCompilerBin.js +25 -7
- package/lib/bin/RelayCompilerMain.js +134 -125
- package/lib/bin/__fixtures__/plugin-module.js +1 -0
- package/lib/codegen/CodegenDirectory.js +14 -8
- package/lib/codegen/CodegenRunner.js +35 -75
- package/lib/codegen/CodegenTypes.js +1 -0
- package/lib/codegen/CodegenWatcher.js +14 -21
- package/lib/codegen/NormalizationCodeGenerator.js +80 -127
- package/lib/codegen/ReaderCodeGenerator.js +85 -111
- package/lib/codegen/RelayCodeGenerator.js +9 -6
- package/lib/codegen/RelayFileWriter.js +22 -41
- package/lib/codegen/SourceControl.js +1 -0
- package/lib/codegen/compileRelayArtifacts.js +18 -31
- package/lib/codegen/createPrintRequireModuleDependency.js +1 -0
- package/lib/codegen/writeRelayGeneratedFile.js +62 -90
- package/lib/core/ASTCache.js +4 -4
- package/lib/core/ASTConvert.js +1 -0
- package/lib/core/{GraphQLCompilerContext.js → CompilerContext.js} +10 -11
- package/lib/core/{RelayCompilerError.js → CompilerError.js} +29 -55
- package/lib/core/DotGraphQLParser.js +1 -0
- package/lib/core/GraphQLCompilerProfiler.js +9 -12
- package/lib/core/GraphQLDerivedFromMetadata.js +1 -0
- package/lib/core/GraphQLWatchmanClient.js +5 -12
- package/lib/core/{GraphQLIR.js → IR.js} +1 -0
- package/lib/core/{GraphQLIRPrinter.js → IRPrinter.js} +39 -17
- package/lib/core/{GraphQLIRTransformer.js → IRTransformer.js} +21 -16
- package/lib/core/{GraphQLIRValidator.js → IRValidator.js} +18 -10
- package/lib/core/{GraphQLIRVisitor.js → IRVisitor.js} +1 -2
- package/lib/core/JSModuleParser.js +18 -0
- package/lib/core/RelayCompilerScope.js +6 -5
- package/lib/core/RelayFindGraphQLTags.js +1 -0
- package/lib/core/RelayGraphQLEnumsGenerator.js +26 -12
- package/lib/core/RelayIRTransforms.js +12 -9
- package/lib/core/RelayParser.js +113 -75
- package/lib/core/RelaySourceModuleParser.js +4 -3
- package/lib/core/Schema.js +808 -317
- package/lib/core/SchemaUtils.js +1 -0
- package/lib/core/filterContextForNode.js +5 -4
- package/lib/core/getFieldDefinition.js +14 -16
- package/lib/core/getIdentifierForArgumentValue.js +18 -0
- package/lib/core/getIdentifierForSelection.js +4 -5
- package/lib/core/getLiteralArgumentValues.js +1 -0
- package/lib/core/getNormalizationOperationName.js +1 -0
- package/lib/core/inferRootArgumentDefinitions.js +79 -99
- package/lib/index.js +69 -19
- package/lib/language/RelayLanguagePluginInterface.js +1 -0
- package/lib/language/javascript/FindGraphQLTags.js +1 -0
- package/lib/language/javascript/RelayFlowBabelFactories.js +15 -0
- package/lib/language/javascript/RelayFlowGenerator.js +94 -173
- package/lib/language/javascript/RelayFlowTypeTransformers.js +2 -3
- package/lib/language/javascript/RelayLanguagePluginJavaScript.js +7 -4
- package/lib/language/javascript/formatGeneratedModule.js +14 -4
- package/lib/reporters/ConsoleReporter.js +2 -3
- package/lib/reporters/MultiReporter.js +2 -3
- package/lib/reporters/Reporter.js +1 -0
- package/lib/runner/Artifacts.js +327 -0
- package/lib/runner/BufferedFilesystem.js +265 -0
- package/lib/runner/GraphQLASTNodeGroup.js +260 -0
- package/lib/runner/GraphQLASTUtils.js +23 -0
- package/lib/runner/GraphQLNodeMap.js +85 -0
- package/lib/runner/Sources.js +266 -0
- package/lib/runner/StrictMap.js +136 -0
- package/lib/runner/compileArtifacts.js +39 -0
- package/lib/runner/extractAST.js +77 -0
- package/lib/runner/getChangedNodeNames.js +84 -0
- package/lib/runner/getSchemaInstance.js +30 -0
- package/lib/runner/types.js +12 -0
- package/lib/transforms/ApplyFragmentArgumentTransform.js +49 -55
- package/lib/transforms/ClientExtensionsTransform.js +11 -17
- package/lib/transforms/ConnectionTransform.js +35 -28
- package/lib/transforms/DeferStreamTransform.js +26 -74
- package/lib/transforms/DisallowIdAsAlias.js +5 -4
- package/lib/transforms/DisallowTypenameOnRoot.js +55 -0
- package/lib/transforms/FieldHandleTransform.js +8 -3
- package/lib/transforms/FilterDirectivesTransform.js +4 -3
- package/lib/transforms/FlattenTransform.js +23 -47
- package/lib/transforms/GenerateIDFieldTransform.js +9 -4
- package/lib/transforms/GenerateTypeNameTransform.js +8 -3
- package/lib/transforms/InlineDataFragmentTransform.js +11 -6
- package/lib/transforms/InlineFragmentsTransform.js +3 -2
- package/lib/transforms/MaskTransform.js +20 -19
- package/lib/transforms/MatchTransform.js +113 -34
- package/lib/transforms/RefetchableFragmentTransform.js +25 -41
- package/lib/transforms/RelayDirectiveTransform.js +13 -4
- package/lib/transforms/SkipClientExtensionsTransform.js +11 -2
- package/lib/transforms/SkipHandleFieldTransform.js +8 -3
- package/lib/transforms/SkipRedundantNodesTransform.js +9 -6
- package/lib/transforms/SkipSplitOperationTransform.js +32 -0
- package/lib/transforms/SkipUnreachableNodeTransform.js +12 -12
- package/lib/transforms/SkipUnusedVariablesTransform.js +19 -17
- package/lib/transforms/SplitModuleImportTransform.js +4 -3
- package/lib/transforms/TestOperationTransform.js +9 -6
- package/lib/transforms/TransformUtils.js +1 -0
- package/lib/transforms/ValidateGlobalVariablesTransform.js +20 -31
- package/lib/transforms/ValidateRequiredArgumentsTransform.js +17 -20
- package/lib/transforms/ValidateServerOnlyDirectivesTransform.js +20 -33
- package/lib/transforms/ValidateUnusedVariablesTransform.js +20 -31
- package/lib/transforms/query-generators/FetchableQueryGenerator.js +161 -0
- package/lib/transforms/query-generators/NodeQueryGenerator.js +9 -3
- package/lib/transforms/query-generators/QueryQueryGenerator.js +2 -0
- package/lib/transforms/query-generators/ViewerQueryGenerator.js +6 -3
- package/lib/transforms/query-generators/index.js +25 -7
- package/lib/transforms/query-generators/utils.js +13 -15
- package/lib/util/CodeMarker.js +1 -0
- package/lib/util/DefaultHandleKey.js +1 -0
- package/lib/util/RelayCompilerCache.js +2 -3
- package/lib/util/Rollout.js +1 -0
- package/lib/util/TimeReporter.js +83 -0
- package/lib/util/areEqualOSS.js +1 -0
- package/lib/util/dedupeJSONStringify.js +16 -12
- package/lib/util/getDefinitionNodeHash.js +22 -0
- package/lib/util/getModuleName.js +4 -5
- package/lib/util/joinArgumentDefinitions.js +2 -1
- package/lib/util/md5.js +17 -0
- package/lib/util/murmurHash.js +1 -0
- package/lib/util/nullthrowsOSS.js +1 -0
- package/lib/util/orList.js +2 -1
- package/lib/util/partitionArray.js +1 -0
- package/package.json +4 -4
- package/relay-compiler.js +4 -4
- package/relay-compiler.min.js +4 -4
- package/reporters/ConsoleReporter.js.flow +81 -0
- package/reporters/MultiReporter.js.flow +43 -0
- package/reporters/Reporter.js.flow +19 -0
- package/runner/Artifacts.js.flow +219 -0
- package/runner/BufferedFilesystem.js.flow +194 -0
- package/runner/GraphQLASTNodeGroup.js.flow +176 -0
- package/runner/GraphQLASTUtils.js.flow +26 -0
- package/runner/GraphQLNodeMap.js.flow +55 -0
- package/runner/Sources.js.flow +218 -0
- package/runner/StrictMap.js.flow +96 -0
- package/runner/compileArtifacts.js.flow +76 -0
- package/runner/extractAST.js.flow +100 -0
- package/runner/getChangedNodeNames.js.flow +48 -0
- package/runner/getSchemaInstance.js.flow +36 -0
- package/runner/types.js.flow +37 -0
- package/transforms/ApplyFragmentArgumentTransform.js.flow +474 -0
- package/transforms/ClientExtensionsTransform.js.flow +220 -0
- package/transforms/ConnectionTransform.js.flow +869 -0
- package/transforms/DeferStreamTransform.js.flow +258 -0
- package/transforms/DisallowIdAsAlias.js.flow +47 -0
- package/transforms/DisallowTypenameOnRoot.js.flow +45 -0
- package/transforms/FieldHandleTransform.js.flow +80 -0
- package/transforms/FilterDirectivesTransform.js.flow +45 -0
- package/transforms/FlattenTransform.js.flow +456 -0
- package/transforms/GenerateIDFieldTransform.js.flow +134 -0
- package/transforms/GenerateTypeNameTransform.js.flow +81 -0
- package/transforms/InlineDataFragmentTransform.js.flow +124 -0
- package/transforms/InlineFragmentsTransform.js.flow +71 -0
- package/transforms/MaskTransform.js.flow +126 -0
- package/transforms/MatchTransform.js.flow +583 -0
- package/transforms/RefetchableFragmentTransform.js.flow +272 -0
- package/transforms/RelayDirectiveTransform.js.flow +99 -0
- package/transforms/SkipClientExtensionsTransform.js.flow +54 -0
- package/transforms/SkipHandleFieldTransform.js.flow +44 -0
- package/transforms/SkipRedundantNodesTransform.js.flow +253 -0
- package/transforms/SkipSplitOperationTransform.js.flow +37 -0
- package/transforms/SkipUnreachableNodeTransform.js.flow +149 -0
- package/transforms/SkipUnusedVariablesTransform.js.flow +59 -0
- package/transforms/SplitModuleImportTransform.js.flow +98 -0
- package/transforms/TestOperationTransform.js.flow +138 -0
- package/transforms/TransformUtils.js.flow +26 -0
- package/transforms/ValidateGlobalVariablesTransform.js.flow +81 -0
- package/transforms/ValidateRequiredArgumentsTransform.js.flow +127 -0
- package/transforms/ValidateServerOnlyDirectivesTransform.js.flow +112 -0
- package/transforms/ValidateUnusedVariablesTransform.js.flow +89 -0
- package/transforms/query-generators/FetchableQueryGenerator.js.flow +190 -0
- package/transforms/query-generators/NodeQueryGenerator.js.flow +206 -0
- package/transforms/query-generators/QueryQueryGenerator.js.flow +57 -0
- package/transforms/query-generators/ViewerQueryGenerator.js.flow +97 -0
- package/transforms/query-generators/index.js.flow +90 -0
- package/transforms/query-generators/utils.js.flow +72 -0
- package/util/CodeMarker.js.flow +79 -0
- package/util/DefaultHandleKey.js.flow +17 -0
- package/util/RelayCompilerCache.js.flow +88 -0
- package/util/Rollout.js.flow +39 -0
- package/util/TimeReporter.js.flow +79 -0
- package/util/areEqualOSS.js.flow +123 -0
- package/util/dedupeJSONStringify.js.flow +152 -0
- package/util/getDefinitionNodeHash.js.flow +25 -0
- package/util/getModuleName.js.flow +39 -0
- package/util/joinArgumentDefinitions.js.flow +99 -0
- package/util/md5.js.flow +22 -0
- package/util/murmurHash.js.flow +94 -0
- package/util/nullthrowsOSS.js.flow +25 -0
- package/util/orList.js.flow +37 -0
- package/util/partitionArray.js.flow +37 -0
- package/lib/transforms/ConnectionFieldTransform.js +0 -275
package/lib/core/Schema.js
CHANGED
@@ -8,41 +8,51 @@
|
|
8
8
|
* @format
|
9
9
|
* @emails oncall+relay
|
10
10
|
*/
|
11
|
+
// flowlint ambiguous-object-type:error
|
11
12
|
'use strict';
|
12
13
|
|
13
14
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
14
15
|
|
16
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
17
|
+
|
18
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
19
|
+
|
15
20
|
var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
|
16
21
|
|
17
|
-
var
|
22
|
+
function _createForOfIteratorHelper(o) { if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (o = _unsupportedIterableToArray(o))) { var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var it, normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
23
|
+
|
24
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
18
25
|
|
19
|
-
var
|
26
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
20
27
|
|
21
|
-
var
|
28
|
+
function _createSuper(Derived) { return function () { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
29
|
+
|
30
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
31
|
+
|
32
|
+
var _require = require('./CompilerError'),
|
22
33
|
createCompilerError = _require.createCompilerError;
|
23
34
|
|
24
|
-
var _require2 = require('
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
35
|
+
var _require2 = require('./SchemaUtils'),
|
36
|
+
isSchemaDefinitionAST = _require2.isSchemaDefinitionAST;
|
37
|
+
|
38
|
+
var _require3 = require('graphql'),
|
39
|
+
GraphQLFloat = _require3.GraphQLFloat,
|
40
|
+
GraphQLInt = _require3.GraphQLInt,
|
41
|
+
GraphQLBoolean = _require3.GraphQLBoolean,
|
42
|
+
GraphQLString = _require3.GraphQLString,
|
43
|
+
GraphQLID = _require3.GraphQLID,
|
44
|
+
parse = _require3.parse,
|
45
|
+
parseType = _require3.parseType,
|
46
|
+
print = _require3.print,
|
47
|
+
valueFromASTUntyped = _require3.valueFromASTUntyped;
|
37
48
|
|
38
49
|
/**
|
39
50
|
* @private
|
40
51
|
*/
|
41
|
-
var Type =
|
42
|
-
|
43
|
-
function () {
|
44
|
-
function Type(name) {
|
52
|
+
var Type = /*#__PURE__*/function () {
|
53
|
+
function Type(name, isClient) {
|
45
54
|
this.name = name;
|
55
|
+
this.isClient = isClient;
|
46
56
|
}
|
47
57
|
|
48
58
|
var _proto = Type.prototype;
|
@@ -62,11 +72,11 @@ function () {
|
|
62
72
|
*/
|
63
73
|
|
64
74
|
|
65
|
-
var ScalarType =
|
66
|
-
/*#__PURE__*/
|
67
|
-
function (_Type) {
|
75
|
+
var ScalarType = /*#__PURE__*/function (_Type) {
|
68
76
|
(0, _inheritsLoose2["default"])(ScalarType, _Type);
|
69
77
|
|
78
|
+
var _super = _createSuper(ScalarType);
|
79
|
+
|
70
80
|
function ScalarType() {
|
71
81
|
return _Type.apply(this, arguments) || this;
|
72
82
|
}
|
@@ -78,13 +88,17 @@ function (_Type) {
|
|
78
88
|
*/
|
79
89
|
|
80
90
|
|
81
|
-
var EnumType =
|
82
|
-
/*#__PURE__*/
|
83
|
-
function (_Type2) {
|
91
|
+
var EnumType = /*#__PURE__*/function (_Type2) {
|
84
92
|
(0, _inheritsLoose2["default"])(EnumType, _Type2);
|
85
93
|
|
86
|
-
|
87
|
-
|
94
|
+
var _super2 = _createSuper(EnumType);
|
95
|
+
|
96
|
+
function EnumType(name, values, isClient) {
|
97
|
+
var _this;
|
98
|
+
|
99
|
+
_this = _Type2.call(this, name, isClient) || this;
|
100
|
+
_this.values = values;
|
101
|
+
return _this;
|
88
102
|
}
|
89
103
|
|
90
104
|
return EnumType;
|
@@ -94,11 +108,11 @@ function (_Type2) {
|
|
94
108
|
*/
|
95
109
|
|
96
110
|
|
97
|
-
var UnionType =
|
98
|
-
/*#__PURE__*/
|
99
|
-
function (_Type3) {
|
111
|
+
var UnionType = /*#__PURE__*/function (_Type3) {
|
100
112
|
(0, _inheritsLoose2["default"])(UnionType, _Type3);
|
101
113
|
|
114
|
+
var _super3 = _createSuper(UnionType);
|
115
|
+
|
102
116
|
function UnionType() {
|
103
117
|
return _Type3.apply(this, arguments) || this;
|
104
118
|
}
|
@@ -110,11 +124,11 @@ function (_Type3) {
|
|
110
124
|
*/
|
111
125
|
|
112
126
|
|
113
|
-
var ObjectType =
|
114
|
-
/*#__PURE__*/
|
115
|
-
function (_Type4) {
|
127
|
+
var ObjectType = /*#__PURE__*/function (_Type4) {
|
116
128
|
(0, _inheritsLoose2["default"])(ObjectType, _Type4);
|
117
129
|
|
130
|
+
var _super4 = _createSuper(ObjectType);
|
131
|
+
|
118
132
|
function ObjectType() {
|
119
133
|
return _Type4.apply(this, arguments) || this;
|
120
134
|
}
|
@@ -126,11 +140,11 @@ function (_Type4) {
|
|
126
140
|
*/
|
127
141
|
|
128
142
|
|
129
|
-
var InputObjectType =
|
130
|
-
/*#__PURE__*/
|
131
|
-
function (_Type5) {
|
143
|
+
var InputObjectType = /*#__PURE__*/function (_Type5) {
|
132
144
|
(0, _inheritsLoose2["default"])(InputObjectType, _Type5);
|
133
145
|
|
146
|
+
var _super5 = _createSuper(InputObjectType);
|
147
|
+
|
134
148
|
function InputObjectType() {
|
135
149
|
return _Type5.apply(this, arguments) || this;
|
136
150
|
}
|
@@ -142,11 +156,11 @@ function (_Type5) {
|
|
142
156
|
*/
|
143
157
|
|
144
158
|
|
145
|
-
var InterfaceType =
|
146
|
-
/*#__PURE__*/
|
147
|
-
function (_Type6) {
|
159
|
+
var InterfaceType = /*#__PURE__*/function (_Type6) {
|
148
160
|
(0, _inheritsLoose2["default"])(InterfaceType, _Type6);
|
149
161
|
|
162
|
+
var _super6 = _createSuper(InterfaceType);
|
163
|
+
|
150
164
|
function InterfaceType() {
|
151
165
|
return _Type6.apply(this, arguments) || this;
|
152
166
|
}
|
@@ -158,9 +172,7 @@ function (_Type6) {
|
|
158
172
|
*/
|
159
173
|
|
160
174
|
|
161
|
-
var List =
|
162
|
-
/*#__PURE__*/
|
163
|
-
function () {
|
175
|
+
var List = /*#__PURE__*/function () {
|
164
176
|
function List(type) {
|
165
177
|
this.ofType = type;
|
166
178
|
this._typeString = "[".concat(String(this.ofType), "]");
|
@@ -183,9 +195,7 @@ function () {
|
|
183
195
|
*/
|
184
196
|
|
185
197
|
|
186
|
-
var NonNull =
|
187
|
-
/*#__PURE__*/
|
188
|
-
function () {
|
198
|
+
var NonNull = /*#__PURE__*/function () {
|
189
199
|
function NonNull(type) {
|
190
200
|
this.ofType = type;
|
191
201
|
this._typeString = "".concat(String(this.ofType), "!");
|
@@ -208,19 +218,12 @@ function () {
|
|
208
218
|
*/
|
209
219
|
|
210
220
|
|
211
|
-
var Field = function Field(schema, name, type, belongsTo,
|
221
|
+
var Field = function Field(schema, name, type, belongsTo, args, isClient) {
|
212
222
|
this.name = name;
|
213
223
|
this.type = type;
|
214
224
|
this.belongsTo = belongsTo;
|
215
|
-
this.
|
216
|
-
|
217
|
-
|
218
|
-
return [arg.name, {
|
219
|
-
name: arg.name,
|
220
|
-
type: schema.assertInputType(schema.expectTypeFromAST(nullthrows((_arg$astNode = arg.astNode) === null || _arg$astNode === void 0 ? void 0 : _arg$astNode.type))),
|
221
|
-
defaultValue: arg.defaultValue
|
222
|
-
}];
|
223
|
-
}));
|
225
|
+
this.isClient = isClient;
|
226
|
+
this.args = parseInputArgumentDefinitionsMap(schema, args);
|
224
227
|
};
|
225
228
|
/**
|
226
229
|
* @private
|
@@ -261,6 +264,9 @@ function getConcreteTypes(schema, type) {
|
|
261
264
|
|
262
265
|
var TYPENAME_FIELD = '__typename';
|
263
266
|
var CLIENT_ID_FIELD = '__id';
|
267
|
+
var QUERY_TYPE_KEY = Symbol('Query');
|
268
|
+
var MUTATION_TYPE_KEY = Symbol('Mutation');
|
269
|
+
var SUBSCRIPTION_TYPE_KEY = Symbol('Subscription');
|
264
270
|
|
265
271
|
function _isScalar(type) {
|
266
272
|
return type instanceof ScalarType;
|
@@ -306,45 +312,34 @@ function _isInputType(type) {
|
|
306
312
|
return type instanceof InputObjectType || type instanceof ScalarType || type instanceof EnumType;
|
307
313
|
}
|
308
314
|
|
309
|
-
var Schema =
|
310
|
-
/*#__PURE__*/
|
311
|
-
function () {
|
315
|
+
var Schema = /*#__PURE__*/function () {
|
312
316
|
/**
|
313
317
|
* @private
|
314
318
|
*/
|
315
|
-
function Schema(
|
316
|
-
var
|
317
|
-
|
318
|
-
var _directivesMap;
|
319
|
+
function Schema(typeMap) {
|
320
|
+
var _this2 = this;
|
319
321
|
|
320
|
-
this.QUERY_TYPE_KEY = QUERY_TYPE_KEY;
|
321
|
-
this.MUTATION_TYPE_KEY = MUTATION_TYPE_KEY;
|
322
|
-
this.SUBSCRIPTION_TYPE_KEY = SUBSCRIPTION_TYPE_KEY;
|
323
|
-
this._baseSchema = baseSchema;
|
324
|
-
this._extendedSchema = extendedSchema;
|
325
322
|
this._typeMap = typeMap;
|
326
|
-
this.
|
327
|
-
this.
|
328
|
-
this.
|
329
|
-
this.
|
330
|
-
this.
|
323
|
+
this._typeWrappersMap = new Map();
|
324
|
+
this._fieldsMap = new Map();
|
325
|
+
this._typeNameMap = new Map();
|
326
|
+
this._clientIdMap = new Map();
|
327
|
+
this._directiveMap = new Map(typeMap.getDirectives().map(function (directive) {
|
331
328
|
return [directive.name, {
|
332
|
-
clientOnlyDirective: _this._baseSchema.getDirective(directive.name) == null,
|
333
|
-
name: directive.name,
|
334
329
|
locations: directive.locations,
|
335
|
-
args: directive.args
|
336
|
-
|
337
|
-
|
338
|
-
type: _this.assertInputType(arg.astNode ? _this.expectTypeFromAST(arg.astNode.type) : _this.expectTypeFromString(String(arg.type))),
|
339
|
-
defaultValue: arg.defaultValue
|
340
|
-
};
|
341
|
-
})
|
330
|
+
args: parseInputArgumentDefinitions(_this2, directive.args),
|
331
|
+
name: directive.name,
|
332
|
+
isClient: directive.isClient
|
342
333
|
}];
|
343
334
|
}));
|
344
335
|
}
|
345
336
|
|
346
337
|
var _proto4 = Schema.prototype;
|
347
338
|
|
339
|
+
_proto4.getTypes = function getTypes() {
|
340
|
+
return this._typeMap.getTypes();
|
341
|
+
};
|
342
|
+
|
348
343
|
_proto4.getTypeFromAST = function getTypeFromAST(typeNode) {
|
349
344
|
if (typeNode.kind === 'NonNullType') {
|
350
345
|
var innerType = this.getTypeFromAST(typeNode.type);
|
@@ -359,7 +354,7 @@ function () {
|
|
359
354
|
|
360
355
|
var cacheKey = "".concat(this.getTypeString(innerType), "!");
|
361
356
|
|
362
|
-
var type = this.
|
357
|
+
var type = this._typeWrappersMap.get(cacheKey);
|
363
358
|
|
364
359
|
if (type) {
|
365
360
|
return type;
|
@@ -367,7 +362,7 @@ function () {
|
|
367
362
|
|
368
363
|
type = new NonNull(innerType);
|
369
364
|
|
370
|
-
this.
|
365
|
+
this._typeWrappersMap.set(cacheKey, type);
|
371
366
|
|
372
367
|
return type;
|
373
368
|
} else if (typeNode.kind === 'ListType') {
|
@@ -379,7 +374,7 @@ function () {
|
|
379
374
|
|
380
375
|
var _cacheKey = "[".concat(this.getTypeString(_innerType), "]");
|
381
376
|
|
382
|
-
var _type = this.
|
377
|
+
var _type = this._typeWrappersMap.get(_cacheKey);
|
383
378
|
|
384
379
|
if (_type) {
|
385
380
|
return _type;
|
@@ -387,52 +382,16 @@ function () {
|
|
387
382
|
|
388
383
|
_type = new List(_innerType);
|
389
384
|
|
390
|
-
this.
|
385
|
+
this._typeWrappersMap.set(_cacheKey, _type);
|
391
386
|
|
392
387
|
return _type;
|
393
|
-
} else {
|
394
|
-
var name = typeNode.name.value;
|
395
|
-
|
396
|
-
var _type2 = this._typeMap.get(name);
|
397
|
-
|
398
|
-
if (_type2) {
|
399
|
-
return _type2;
|
400
|
-
}
|
401
|
-
|
402
|
-
var graphQLType = this._extendedSchema.getType(name);
|
403
|
-
|
404
|
-
if (!graphQLType) {
|
405
|
-
return;
|
406
|
-
}
|
407
|
-
|
408
|
-
var TypeClass = Type;
|
409
|
-
|
410
|
-
if (graphQLType instanceof GraphQLScalarType) {
|
411
|
-
TypeClass = ScalarType;
|
412
|
-
} else if (graphQLType instanceof GraphQLInputObjectType) {
|
413
|
-
TypeClass = InputObjectType;
|
414
|
-
} else if (graphQLType instanceof GraphQLEnumType) {
|
415
|
-
TypeClass = EnumType;
|
416
|
-
} else if (graphQLType instanceof GraphQLUnionType) {
|
417
|
-
TypeClass = UnionType;
|
418
|
-
} else if (graphQLType instanceof GraphQLInterfaceType) {
|
419
|
-
TypeClass = InterfaceType;
|
420
|
-
} else if (graphQLType instanceof GraphQLObjectType) {
|
421
|
-
TypeClass = ObjectType;
|
422
|
-
} else {
|
423
|
-
throw createCompilerError("Unknown GraphQL type: ".concat(graphQLType));
|
424
|
-
}
|
425
|
-
|
426
|
-
_type2 = new TypeClass(name);
|
427
|
-
|
428
|
-
this._typeMap.set(name, _type2);
|
429
|
-
|
430
|
-
return _type2;
|
431
388
|
}
|
389
|
+
|
390
|
+
return this._typeMap.getTypeByName(typeNode.name.value);
|
432
391
|
};
|
433
392
|
|
434
393
|
_proto4._getRawType = function _getRawType(typeName) {
|
435
|
-
var type = this.
|
394
|
+
var type = this._typeWrappersMap.get(typeName);
|
436
395
|
|
437
396
|
if (type) {
|
438
397
|
return type;
|
@@ -441,23 +400,17 @@ function () {
|
|
441
400
|
if (typeof typeName === 'string') {
|
442
401
|
return this.getTypeFromAST(parseType(typeName));
|
443
402
|
} else {
|
444
|
-
var
|
445
|
-
|
446
|
-
if (typeName ===
|
447
|
-
|
448
|
-
} else if (typeName ===
|
449
|
-
|
450
|
-
} else if (typeName ===
|
451
|
-
|
403
|
+
var operationType;
|
404
|
+
|
405
|
+
if (typeName === QUERY_TYPE_KEY) {
|
406
|
+
operationType = this._typeMap.getQueryType();
|
407
|
+
} else if (typeName === MUTATION_TYPE_KEY) {
|
408
|
+
operationType = this._typeMap.getMutationType();
|
409
|
+
} else if (typeName === SUBSCRIPTION_TYPE_KEY) {
|
410
|
+
operationType = this._typeMap.getSubscriptionType();
|
452
411
|
}
|
453
412
|
|
454
|
-
if (
|
455
|
-
var operationType = new ObjectType(graphQLType.name);
|
456
|
-
|
457
|
-
this._typeMap.set(typeName, operationType);
|
458
|
-
|
459
|
-
this._typeMap.set(graphQLType.name, operationType);
|
460
|
-
|
413
|
+
if (operationType instanceof ObjectType) {
|
461
414
|
return operationType;
|
462
415
|
}
|
463
416
|
}
|
@@ -494,7 +447,7 @@ function () {
|
|
494
447
|
|
495
448
|
var cacheKey = "".concat(String(type), "!");
|
496
449
|
|
497
|
-
var nonNullType = this.
|
450
|
+
var nonNullType = this._typeWrappersMap.get(cacheKey);
|
498
451
|
|
499
452
|
if (nonNullType) {
|
500
453
|
return nonNullType;
|
@@ -502,7 +455,7 @@ function () {
|
|
502
455
|
|
503
456
|
nonNullType = new NonNull(type);
|
504
457
|
|
505
|
-
this.
|
458
|
+
this._typeWrappersMap.set(cacheKey, nonNullType);
|
506
459
|
|
507
460
|
return nonNullType;
|
508
461
|
};
|
@@ -560,10 +513,10 @@ function () {
|
|
560
513
|
};
|
561
514
|
|
562
515
|
_proto4.implementsInterface = function implementsInterface(type, interfaceType) {
|
563
|
-
var
|
516
|
+
var _this3 = this;
|
564
517
|
|
565
518
|
return this.getInterfaces(type).some(function (typeInterface) {
|
566
|
-
return
|
519
|
+
return _this3.areEqualTypes(typeInterface, interfaceType);
|
567
520
|
});
|
568
521
|
};
|
569
522
|
|
@@ -630,7 +583,7 @@ function () {
|
|
630
583
|
;
|
631
584
|
|
632
585
|
_proto4.doTypesOverlap = function doTypesOverlap(typeA, typeB) {
|
633
|
-
var
|
586
|
+
var _this4 = this;
|
634
587
|
|
635
588
|
// Equivalent types overlap
|
636
589
|
if (typeA === typeB) {
|
@@ -643,7 +596,7 @@ function () {
|
|
643
596
|
// between possible concrete types of each.
|
644
597
|
return Array.from(this.getPossibleTypes(typeA)).some(function (type) {
|
645
598
|
if (_isObject(type)) {
|
646
|
-
return
|
599
|
+
return _this4.isPossibleType(typeB, type);
|
647
600
|
}
|
648
601
|
});
|
649
602
|
} // Determine if the latter type is a possible concrete type of the former.
|
@@ -662,7 +615,7 @@ function () {
|
|
662
615
|
};
|
663
616
|
|
664
617
|
_proto4.isPossibleType = function isPossibleType(superType, maybeSubType) {
|
665
|
-
return this.
|
618
|
+
return this._typeMap.getPossibleTypeSet(superType).has(maybeSubType);
|
666
619
|
};
|
667
620
|
|
668
621
|
_proto4.assertScalarFieldType = function assertScalarFieldType(type) {
|
@@ -843,7 +796,7 @@ function () {
|
|
843
796
|
};
|
844
797
|
|
845
798
|
_proto4.getQueryType = function getQueryType() {
|
846
|
-
var queryType = this._getRawType(
|
799
|
+
var queryType = this._getRawType(QUERY_TYPE_KEY);
|
847
800
|
|
848
801
|
if (queryType && _isObject(queryType)) {
|
849
802
|
return queryType;
|
@@ -851,7 +804,7 @@ function () {
|
|
851
804
|
};
|
852
805
|
|
853
806
|
_proto4.getMutationType = function getMutationType() {
|
854
|
-
var mutationType = this._getRawType(
|
807
|
+
var mutationType = this._getRawType(MUTATION_TYPE_KEY);
|
855
808
|
|
856
809
|
if (mutationType && _isObject(mutationType)) {
|
857
810
|
return mutationType;
|
@@ -859,7 +812,7 @@ function () {
|
|
859
812
|
};
|
860
813
|
|
861
814
|
_proto4.getSubscriptionType = function getSubscriptionType() {
|
862
|
-
var subscriptionType = this._getRawType(
|
815
|
+
var subscriptionType = this._getRawType(SUBSCRIPTION_TYPE_KEY);
|
863
816
|
|
864
817
|
if (subscriptionType && _isObject(subscriptionType)) {
|
865
818
|
return subscriptionType;
|
@@ -996,15 +949,13 @@ function () {
|
|
996
949
|
return true;
|
997
950
|
}
|
998
951
|
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
-
if (gqlType instanceof GraphQLObjectType || gqlType instanceof GraphQLInterfaceType || gqlType instanceof GraphQLInputObjectType) {
|
1004
|
-
return gqlType.getFields()[fieldName] != null;
|
952
|
+
if (type instanceof ObjectType || type instanceof InterfaceType) {
|
953
|
+
return this._typeMap.getField(type, fieldName) != null;
|
954
|
+
} else if (type instanceof InputObjectType) {
|
955
|
+
return this._typeMap.getInputField(type, fieldName) != null;
|
1005
956
|
}
|
1006
957
|
|
1007
|
-
|
958
|
+
return false;
|
1008
959
|
};
|
1009
960
|
|
1010
961
|
_proto4.hasId = function hasId(type) {
|
@@ -1023,8 +974,6 @@ function () {
|
|
1023
974
|
};
|
1024
975
|
|
1025
976
|
_proto4._getFieldsMap = function _getFieldsMap(type) {
|
1026
|
-
var _this4 = this;
|
1027
|
-
|
1028
977
|
var cachedMap = this._fieldsMap.get(type);
|
1029
978
|
|
1030
979
|
if (cachedMap != null) {
|
@@ -1032,38 +981,55 @@ function () {
|
|
1032
981
|
}
|
1033
982
|
|
1034
983
|
var fieldsMap = new Map();
|
1035
|
-
var name = type.name;
|
1036
984
|
|
1037
|
-
|
985
|
+
if (type instanceof ObjectType || type instanceof InterfaceType) {
|
986
|
+
var fields = this._typeMap.getFieldMap(type);
|
1038
987
|
|
1039
|
-
|
1040
|
-
|
1041
|
-
|
1042
|
-
fieldNames.forEach(function (fieldName) {
|
1043
|
-
var field = typeFields[fieldName];
|
988
|
+
if (fields) {
|
989
|
+
var _iterator = _createForOfIteratorHelper(fields),
|
990
|
+
_step;
|
1044
991
|
|
1045
|
-
|
1046
|
-
|
992
|
+
try {
|
993
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
994
|
+
var _step$value = _step.value,
|
995
|
+
fieldName = _step$value[0],
|
996
|
+
fieldDefinition = _step$value[1];
|
997
|
+
var fieldType = this.expectTypeFromAST(fieldDefinition.type);
|
998
|
+
fieldsMap.set(fieldName, new Field(this, fieldName, fieldType, this.assertCompositeType(type), fieldDefinition.arguments, fieldDefinition.isClient));
|
999
|
+
}
|
1000
|
+
} catch (err) {
|
1001
|
+
_iterator.e(err);
|
1002
|
+
} finally {
|
1003
|
+
_iterator.f();
|
1047
1004
|
}
|
1005
|
+
}
|
1006
|
+
} else if (type instanceof InputObjectType) {
|
1007
|
+
var _fields = this._typeMap.getInputFieldMap(type);
|
1048
1008
|
|
1049
|
-
|
1050
|
-
|
1051
|
-
|
1052
|
-
} else if (gqlType instanceof GraphQLInputObjectType) {
|
1053
|
-
var _typeFields = gqlType.getFields();
|
1009
|
+
if (_fields) {
|
1010
|
+
var _iterator2 = _createForOfIteratorHelper(_fields),
|
1011
|
+
_step2;
|
1054
1012
|
|
1055
|
-
|
1013
|
+
try {
|
1014
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
1015
|
+
var _step2$value = _step2.value,
|
1016
|
+
_fieldName = _step2$value[0],
|
1017
|
+
typeNode = _step2$value[1];
|
1056
1018
|
|
1057
|
-
|
1058
|
-
var field = _typeFields[fieldName];
|
1019
|
+
var _fieldType = this.expectTypeFromAST(typeNode);
|
1059
1020
|
|
1060
|
-
|
1061
|
-
|
1021
|
+
fieldsMap.set(_fieldName, new Field(this, _fieldName, _fieldType, type, [], false));
|
1022
|
+
}
|
1023
|
+
} catch (err) {
|
1024
|
+
_iterator2.e(err);
|
1025
|
+
} finally {
|
1026
|
+
_iterator2.f();
|
1062
1027
|
}
|
1028
|
+
}
|
1029
|
+
}
|
1063
1030
|
|
1064
|
-
|
1065
|
-
|
1066
|
-
});
|
1031
|
+
if (fieldsMap.size === 0) {
|
1032
|
+
throw createCompilerError("_getFieldsMap: Type '".concat(type.name, "' should have fields."));
|
1067
1033
|
}
|
1068
1034
|
|
1069
1035
|
this._fieldsMap.set(type, fieldsMap);
|
@@ -1082,7 +1048,7 @@ function () {
|
|
1082
1048
|
var typename = this._typeNameMap.get(type);
|
1083
1049
|
|
1084
1050
|
if (!typename) {
|
1085
|
-
typename = new Field(this, TYPENAME_FIELD, this.getNonNullType(this.expectStringType()), type, []);
|
1051
|
+
typename = new Field(this, TYPENAME_FIELD, this.getNonNullType(this.expectStringType()), type, [], false);
|
1086
1052
|
|
1087
1053
|
this._typeNameMap.set(type, typename);
|
1088
1054
|
}
|
@@ -1094,7 +1060,7 @@ function () {
|
|
1094
1060
|
var clientId = this._clientIdMap.get(type);
|
1095
1061
|
|
1096
1062
|
if (!clientId) {
|
1097
|
-
clientId = new Field(this, CLIENT_ID_FIELD, this.getNonNullType(this.expectIdType()), type, []);
|
1063
|
+
clientId = new Field(this, CLIENT_ID_FIELD, this.getNonNullType(this.expectIdType()), type, [], true);
|
1098
1064
|
|
1099
1065
|
this._clientIdMap.set(type, clientId);
|
1100
1066
|
}
|
@@ -1149,226 +1115,751 @@ function () {
|
|
1149
1115
|
};
|
1150
1116
|
|
1151
1117
|
_proto4.getEnumValues = function getEnumValues(type) {
|
1152
|
-
|
1118
|
+
return type.values;
|
1119
|
+
};
|
1153
1120
|
|
1154
|
-
|
1155
|
-
|
1156
|
-
|
1157
|
-
|
1158
|
-
|
1121
|
+
_proto4.getUnionTypes = function getUnionTypes(type) {
|
1122
|
+
return Array.from(this._typeMap.getPossibleTypeSet(type));
|
1123
|
+
};
|
1124
|
+
|
1125
|
+
_proto4.getInterfaces = function getInterfaces(type) {
|
1126
|
+
if (type instanceof ObjectType) {
|
1127
|
+
return this._typeMap.getInterfaces(type);
|
1159
1128
|
}
|
1160
1129
|
|
1161
|
-
|
1130
|
+
return [];
|
1162
1131
|
};
|
1163
1132
|
|
1164
|
-
_proto4.
|
1165
|
-
|
1133
|
+
_proto4.getPossibleTypes = function getPossibleTypes(type) {
|
1134
|
+
return this._typeMap.getPossibleTypeSet(type);
|
1135
|
+
};
|
1166
1136
|
|
1167
|
-
|
1137
|
+
_proto4.getFetchableFieldName = function getFetchableFieldName(type) {
|
1138
|
+
return this._typeMap.getFetchableFieldName(type);
|
1139
|
+
};
|
1168
1140
|
|
1169
|
-
|
1170
|
-
|
1171
|
-
|
1172
|
-
|
1141
|
+
_proto4.parseLiteral = function parseLiteral(type, valueNode) {
|
1142
|
+
if (type instanceof EnumType && valueNode.kind === 'EnumValue') {
|
1143
|
+
return this.parseValue(type, valueNode.value);
|
1144
|
+
} else if (type instanceof ScalarType) {
|
1145
|
+
if (valueNode.kind === 'BooleanValue' && type.name === 'Boolean') {
|
1146
|
+
return GraphQLBoolean.parseLiteral(valueNode);
|
1147
|
+
} else if (valueNode.kind === 'FloatValue' && type.name === 'Float') {
|
1148
|
+
return GraphQLFloat.parseLiteral(valueNode);
|
1149
|
+
} else if (valueNode.kind === 'IntValue' && (type.name === 'Int' || type.name === 'ID' || type.name === 'Float')) {
|
1150
|
+
return GraphQLInt.parseLiteral(valueNode);
|
1151
|
+
} else if (valueNode.kind === 'StringValue' && (type.name === 'String' || type.name === 'ID')) {
|
1152
|
+
return GraphQLString.parseLiteral(valueNode);
|
1153
|
+
} else if (!isDefaultScalar(type.name)) {
|
1154
|
+
return valueFromASTUntyped(valueNode);
|
1155
|
+
}
|
1156
|
+
}
|
1157
|
+
};
|
1158
|
+
|
1159
|
+
_proto4.parseValue = function parseValue(type, value) {
|
1160
|
+
if (type instanceof EnumType) {
|
1161
|
+
return type.values.includes(value) ? value : undefined;
|
1162
|
+
} else if (type instanceof ScalarType) {
|
1163
|
+
switch (type.name) {
|
1164
|
+
case 'Boolean':
|
1165
|
+
return GraphQLBoolean.parseValue(value);
|
1166
|
+
|
1167
|
+
case 'Float':
|
1168
|
+
return GraphQLFloat.parseValue(value);
|
1169
|
+
|
1170
|
+
case 'Int':
|
1171
|
+
return GraphQLInt.parseValue(value);
|
1172
|
+
|
1173
|
+
case 'String':
|
1174
|
+
return GraphQLString.parseValue(value);
|
1175
|
+
|
1176
|
+
case 'ID':
|
1177
|
+
return GraphQLID.parseValue(value);
|
1178
|
+
|
1179
|
+
default:
|
1180
|
+
return value;
|
1181
|
+
}
|
1173
1182
|
}
|
1183
|
+
};
|
1184
|
+
|
1185
|
+
_proto4.serialize = function serialize(type, value) {
|
1186
|
+
if (type instanceof EnumType) {
|
1187
|
+
return type.values.includes(value) ? value : undefined;
|
1188
|
+
} else if (type instanceof ScalarType) {
|
1189
|
+
switch (type.name) {
|
1190
|
+
case 'Boolean':
|
1191
|
+
return GraphQLBoolean.serialize(value);
|
1192
|
+
|
1193
|
+
case 'Float':
|
1194
|
+
return GraphQLFloat.serialize(value);
|
1174
1195
|
|
1175
|
-
|
1196
|
+
case 'Int':
|
1197
|
+
return GraphQLInt.serialize(value);
|
1198
|
+
|
1199
|
+
case 'String':
|
1200
|
+
return GraphQLString.serialize(value);
|
1201
|
+
|
1202
|
+
case 'ID':
|
1203
|
+
return GraphQLID.serialize(value);
|
1204
|
+
|
1205
|
+
default:
|
1206
|
+
return value;
|
1207
|
+
}
|
1208
|
+
}
|
1176
1209
|
};
|
1177
1210
|
|
1178
|
-
_proto4.
|
1179
|
-
|
1211
|
+
_proto4.getDirectives = function getDirectives() {
|
1212
|
+
return Array.from(this._directiveMap.values());
|
1213
|
+
};
|
1180
1214
|
|
1181
|
-
|
1215
|
+
_proto4.getDirective = function getDirective(directiveName) {
|
1216
|
+
return this._directiveMap.get(directiveName);
|
1217
|
+
};
|
1182
1218
|
|
1183
|
-
|
1184
|
-
|
1185
|
-
|
1186
|
-
|
1219
|
+
_proto4.isServerType = function isServerType(type) {
|
1220
|
+
if (_isObject(type)) {
|
1221
|
+
return type.isClient === false;
|
1222
|
+
} else if (_isEnum(type)) {
|
1223
|
+
return type.isClient === false;
|
1187
1224
|
}
|
1188
1225
|
|
1189
|
-
return
|
1226
|
+
return true;
|
1190
1227
|
};
|
1191
1228
|
|
1192
|
-
_proto4.
|
1193
|
-
|
1229
|
+
_proto4.isServerField = function isServerField(field) {
|
1230
|
+
return field.isClient === false;
|
1231
|
+
};
|
1194
1232
|
|
1195
|
-
|
1233
|
+
_proto4.isServerDirective = function isServerDirective(directiveName) {
|
1234
|
+
var directive = this._directiveMap.get(directiveName);
|
1196
1235
|
|
1197
|
-
|
1198
|
-
|
1236
|
+
return (directive === null || directive === void 0 ? void 0 : directive.isClient) === false;
|
1237
|
+
};
|
1199
1238
|
|
1200
|
-
|
1201
|
-
|
1202
|
-
|
1203
|
-
|
1239
|
+
_proto4.isServerDefinedField = function isServerDefinedField(type, field) {
|
1240
|
+
return this.isAbstractType(type) && field.directives.some(function (_ref) {
|
1241
|
+
var name = _ref.name;
|
1242
|
+
return name === 'fixme_fat_interface';
|
1243
|
+
}) || this.hasField(type, field.name) && this.isServerField(this.expectField(type, field.name));
|
1244
|
+
};
|
1204
1245
|
|
1205
|
-
|
1206
|
-
|
1207
|
-
|
1246
|
+
_proto4.isClientDefinedField = function isClientDefinedField(type, field) {
|
1247
|
+
return !this.isServerDefinedField(type, field);
|
1248
|
+
};
|
1249
|
+
|
1250
|
+
_proto4.extend = function extend(extensions) {
|
1251
|
+
var doc = Array.isArray(extensions) ? parse(extensions.join('\n')) : extensions;
|
1252
|
+
var schemaExtensions = [];
|
1253
|
+
doc.definitions.forEach(function (definition) {
|
1254
|
+
if (isSchemaDefinitionAST(definition)) {
|
1255
|
+
schemaExtensions.push(definition);
|
1208
1256
|
}
|
1257
|
+
});
|
1258
|
+
|
1259
|
+
if (schemaExtensions.length > 0) {
|
1260
|
+
return new Schema(this._typeMap.extend(schemaExtensions));
|
1209
1261
|
}
|
1210
1262
|
|
1211
|
-
return
|
1263
|
+
return this;
|
1212
1264
|
};
|
1213
1265
|
|
1214
|
-
|
1215
|
-
|
1266
|
+
return Schema;
|
1267
|
+
}();
|
1268
|
+
|
1269
|
+
var TypeMap = /*#__PURE__*/function () {
|
1270
|
+
function TypeMap(source, extensions) {
|
1271
|
+
this._types = new Map([['ID', new ScalarType('ID', false)], ['String', new ScalarType('String', false)], ['Boolean', new ScalarType('Boolean', false)], ['Float', new ScalarType('Float', false)], ['Int', new ScalarType('Int', false)]]);
|
1272
|
+
this._typeInterfaces = new Map();
|
1273
|
+
this._unionTypes = new Map();
|
1274
|
+
this._interfaceImplementations = new Map();
|
1275
|
+
this._fields = new Map();
|
1276
|
+
this._inputFields = new Map();
|
1277
|
+
this._directives = new Map([['include', {
|
1278
|
+
name: 'include',
|
1279
|
+
isClient: false,
|
1280
|
+
locations: ['FIELD', 'FRAGMENT_SPREAD', 'INLINE_FRAGMENT'],
|
1281
|
+
args: [{
|
1282
|
+
name: 'if',
|
1283
|
+
typeNode: parseType('Boolean!'),
|
1284
|
+
defaultValue: undefined
|
1285
|
+
}]
|
1286
|
+
}], ['skip', {
|
1287
|
+
name: 'skip',
|
1288
|
+
isClient: false,
|
1289
|
+
locations: ['FIELD', 'FRAGMENT_SPREAD', 'INLINE_FRAGMENT'],
|
1290
|
+
args: [{
|
1291
|
+
name: 'if',
|
1292
|
+
typeNode: parseType('Boolean!'),
|
1293
|
+
defaultValue: undefined
|
1294
|
+
}]
|
1295
|
+
}], ['deprecated', {
|
1296
|
+
name: 'deprecated',
|
1297
|
+
isClient: false,
|
1298
|
+
locations: ['FIELD_DEFINITION', 'ENUM_VALUE'],
|
1299
|
+
args: [{
|
1300
|
+
name: 'reason',
|
1301
|
+
typeNode: parseType('String'),
|
1302
|
+
defaultValue: {
|
1303
|
+
kind: 'StringValue',
|
1304
|
+
value: 'No longer supported'
|
1305
|
+
}
|
1306
|
+
}]
|
1307
|
+
}]]);
|
1308
|
+
this._queryTypeName = 'Query';
|
1309
|
+
this._mutationTypeName = 'Mutation';
|
1310
|
+
this._subscriptionTypeName = 'Subscription';
|
1311
|
+
this._source = source;
|
1312
|
+
this._extensions = extensions;
|
1313
|
+
this._fetchable = new Map();
|
1314
|
+
|
1315
|
+
this._parse(source);
|
1316
|
+
|
1317
|
+
this._extend(extensions);
|
1318
|
+
}
|
1319
|
+
|
1320
|
+
var _proto5 = TypeMap.prototype;
|
1321
|
+
|
1322
|
+
_proto5._parse = function _parse(source) {
|
1323
|
+
var _this5 = this;
|
1324
|
+
|
1325
|
+
var document = parse(source, {
|
1326
|
+
noLocation: true
|
1327
|
+
});
|
1328
|
+
document.definitions.forEach(function (definition) {
|
1329
|
+
switch (definition.kind) {
|
1330
|
+
case 'SchemaDefinition':
|
1331
|
+
{
|
1332
|
+
_this5._parseSchemaDefinition(definition);
|
1333
|
+
|
1334
|
+
break;
|
1335
|
+
}
|
1336
|
+
|
1337
|
+
case 'ScalarTypeDefinition':
|
1338
|
+
{
|
1339
|
+
_this5._parseScalarNode(definition, false);
|
1340
|
+
|
1341
|
+
break;
|
1342
|
+
}
|
1343
|
+
|
1344
|
+
case 'EnumTypeDefinition':
|
1345
|
+
{
|
1346
|
+
_this5._parseEnumNode(definition, false);
|
1347
|
+
|
1348
|
+
break;
|
1349
|
+
}
|
1350
|
+
|
1351
|
+
case 'ObjectTypeDefinition':
|
1352
|
+
{
|
1353
|
+
_this5._parseObjectTypeNode(definition, false);
|
1354
|
+
|
1355
|
+
break;
|
1356
|
+
}
|
1357
|
+
|
1358
|
+
case 'InputObjectTypeDefinition':
|
1359
|
+
{
|
1360
|
+
_this5._parseInputObjectTypeNode(definition, false);
|
1361
|
+
|
1362
|
+
break;
|
1363
|
+
}
|
1364
|
+
|
1365
|
+
case 'UnionTypeDefinition':
|
1366
|
+
{
|
1367
|
+
_this5._parseUnionNode(definition, false);
|
1368
|
+
|
1369
|
+
break;
|
1370
|
+
}
|
1371
|
+
|
1372
|
+
case 'InterfaceTypeDefinition':
|
1373
|
+
{
|
1374
|
+
_this5._parseInterfaceNode(definition, false);
|
1375
|
+
|
1376
|
+
break;
|
1377
|
+
}
|
1378
|
+
|
1379
|
+
case 'DirectiveDefinition':
|
1380
|
+
{
|
1381
|
+
_this5._parseDirective(definition, false);
|
1382
|
+
|
1383
|
+
break;
|
1384
|
+
}
|
1385
|
+
}
|
1386
|
+
});
|
1216
1387
|
};
|
1217
1388
|
|
1218
|
-
|
1219
|
-
var
|
1389
|
+
_proto5._parseSchemaDefinition = function _parseSchemaDefinition(node) {
|
1390
|
+
var _this6 = this;
|
1391
|
+
|
1392
|
+
node.operationTypes.forEach(function (operationType) {
|
1393
|
+
switch (operationType.operation) {
|
1394
|
+
case 'query':
|
1395
|
+
_this6._queryTypeName = operationType.type.name.value;
|
1396
|
+
break;
|
1397
|
+
|
1398
|
+
case 'mutation':
|
1399
|
+
_this6._mutationTypeName = operationType.type.name.value;
|
1400
|
+
break;
|
1401
|
+
|
1402
|
+
case 'subscription':
|
1403
|
+
_this6._subscriptionTypeName = operationType.type.name.value;
|
1404
|
+
break;
|
1405
|
+
}
|
1406
|
+
});
|
1407
|
+
};
|
1408
|
+
|
1409
|
+
_proto5._parseScalarNode = function _parseScalarNode(node, isClient) {
|
1410
|
+
var name = node.name.value;
|
1220
1411
|
|
1221
|
-
if (
|
1222
|
-
|
1412
|
+
if (!isDefaultScalar(name) && this._types.has(name)) {
|
1413
|
+
throw createCompilerError("_parseScalarNode: Duplicate definition for type ".concat(name, "."), null, [node]);
|
1223
1414
|
}
|
1224
1415
|
|
1225
|
-
|
1416
|
+
this._types.set(name, new ScalarType(name, isClient));
|
1226
1417
|
};
|
1227
1418
|
|
1228
|
-
|
1229
|
-
var
|
1419
|
+
_proto5._parseEnumNode = function _parseEnumNode(node, isClient) {
|
1420
|
+
var name = node.name.value;
|
1421
|
+
|
1422
|
+
if (this._types.has(name)) {
|
1423
|
+
throw createCompilerError("_parseEnumNode: Duplicate definition for type ".concat(name, "."), null, [node]);
|
1424
|
+
} // SDL doesn't have information about the actual ENUM values
|
1425
|
+
|
1426
|
+
|
1427
|
+
var values = node.values ? node.values.map(function (value) {
|
1428
|
+
return value.name.value;
|
1429
|
+
}) : [];
|
1430
|
+
|
1431
|
+
this._types.set(name, new EnumType(name, values, isClient));
|
1432
|
+
};
|
1433
|
+
|
1434
|
+
_proto5._parseObjectTypeNode = function _parseObjectTypeNode(node, isClient) {
|
1435
|
+
var _this7 = this;
|
1436
|
+
|
1437
|
+
var _this$_types$get;
|
1438
|
+
|
1439
|
+
var name = node.name.value; // Objects may be created by _parseUnionNode
|
1440
|
+
|
1441
|
+
var type = (_this$_types$get = this._types.get(name)) !== null && _this$_types$get !== void 0 ? _this$_types$get : new ObjectType(name, isClient);
|
1230
1442
|
|
1231
|
-
if (
|
1232
|
-
|
1443
|
+
if (!(type instanceof ObjectType)) {
|
1444
|
+
throw createCompilerError("_parseObjectTypeNode: Expected object type, got ".concat(String(type)), null, [node]);
|
1233
1445
|
}
|
1234
1446
|
|
1235
|
-
|
1447
|
+
if (type.isClient !== isClient) {
|
1448
|
+
throw createCompilerError("_parseObjectTypeNode: Cannot create object type '".concat(name, "' defined as a client type."), null, [node]);
|
1449
|
+
}
|
1450
|
+
|
1451
|
+
var typeInterfaces = [];
|
1452
|
+
node.interfaces && node.interfaces.forEach(function (interfaceTypeNode) {
|
1453
|
+
var _this$_interfaceImple;
|
1454
|
+
|
1455
|
+
var interfaceName = interfaceTypeNode.name.value;
|
1456
|
+
|
1457
|
+
var interfaceType = _this7._types.get(interfaceName);
|
1458
|
+
|
1459
|
+
if (!interfaceType) {
|
1460
|
+
interfaceType = new InterfaceType(interfaceName, isClient);
|
1461
|
+
|
1462
|
+
_this7._types.set(interfaceName, interfaceType);
|
1463
|
+
}
|
1464
|
+
|
1465
|
+
if (!(interfaceType instanceof InterfaceType)) {
|
1466
|
+
throw createCompilerError('_parseObjectTypeNode: Expected interface type', null, [interfaceTypeNode]);
|
1467
|
+
}
|
1468
|
+
|
1469
|
+
var implementations = (_this$_interfaceImple = _this7._interfaceImplementations.get(interfaceType)) !== null && _this$_interfaceImple !== void 0 ? _this$_interfaceImple : new Set();
|
1470
|
+
implementations.add(type);
|
1471
|
+
|
1472
|
+
_this7._interfaceImplementations.set(interfaceType, implementations);
|
1473
|
+
|
1474
|
+
typeInterfaces.push(interfaceType);
|
1475
|
+
});
|
1476
|
+
var fetchable = null;
|
1477
|
+
node.directives && node.directives.forEach(function (directiveNode) {
|
1478
|
+
if (directiveNode.name.value === 'fetchable') {
|
1479
|
+
var field_name_arg = directiveNode.arguments && directiveNode.arguments.find(function (arg) {
|
1480
|
+
return arg.name.value === 'field_name';
|
1481
|
+
});
|
1482
|
+
|
1483
|
+
if (field_name_arg != null && field_name_arg.value.kind === 'StringValue') {
|
1484
|
+
fetchable = {
|
1485
|
+
field_name: field_name_arg.value.value
|
1486
|
+
};
|
1487
|
+
}
|
1488
|
+
}
|
1489
|
+
});
|
1490
|
+
|
1491
|
+
this._typeInterfaces.set(type, typeInterfaces);
|
1492
|
+
|
1493
|
+
this._types.set(name, type);
|
1494
|
+
|
1495
|
+
if (fetchable != null) {
|
1496
|
+
this._fetchable.set(type, fetchable);
|
1497
|
+
}
|
1498
|
+
|
1499
|
+
node.fields && this._handleTypeFieldsStrict(type, node.fields, isClient);
|
1236
1500
|
};
|
1237
1501
|
|
1238
|
-
|
1239
|
-
var
|
1502
|
+
_proto5._parseInputObjectTypeNode = function _parseInputObjectTypeNode(node, isClient) {
|
1503
|
+
var name = node.name.value;
|
1240
1504
|
|
1241
|
-
if (
|
1242
|
-
|
1505
|
+
if (this._types.has(name)) {
|
1506
|
+
throw createCompilerError('_parseInputObjectTypeNode: Unable to parse schema file. Duplicate definition for object type', null, [node]);
|
1243
1507
|
}
|
1244
1508
|
|
1245
|
-
|
1509
|
+
var type = new InputObjectType(name, isClient);
|
1510
|
+
|
1511
|
+
this._types.set(name, type);
|
1512
|
+
|
1513
|
+
this._parseInputObjectFields(type, node);
|
1246
1514
|
};
|
1247
1515
|
|
1248
|
-
|
1249
|
-
|
1516
|
+
_proto5._parseUnionNode = function _parseUnionNode(node, isClient) {
|
1517
|
+
var _this8 = this;
|
1518
|
+
|
1519
|
+
var name = node.name.value;
|
1520
|
+
|
1521
|
+
if (this._types.has(name)) {
|
1522
|
+
throw createCompilerError('_parseUnionNode: Unable to parse schema file. Duplicate definition for object type', null, [node]);
|
1523
|
+
}
|
1524
|
+
|
1525
|
+
var union = new UnionType(name, isClient);
|
1526
|
+
|
1527
|
+
this._types.set(name, union);
|
1528
|
+
|
1529
|
+
this._unionTypes.set(union, new Set(node.types ? node.types.map(function (typeInUnion) {
|
1530
|
+
var _this$_types$get2;
|
1531
|
+
|
1532
|
+
var typeInUnionName = typeInUnion.name.value;
|
1533
|
+
var object = (_this$_types$get2 = _this8._types.get(typeInUnionName)) !== null && _this$_types$get2 !== void 0 ? _this$_types$get2 : new ObjectType(typeInUnionName, false);
|
1534
|
+
|
1535
|
+
if (!(object instanceof ObjectType)) {
|
1536
|
+
throw createCompilerError('_parseUnionNode: Expected object type', null, [typeInUnion]);
|
1537
|
+
}
|
1538
|
+
|
1539
|
+
_this8._types.set(typeInUnionName, object);
|
1540
|
+
|
1541
|
+
return object;
|
1542
|
+
}) : []));
|
1250
1543
|
};
|
1251
1544
|
|
1252
|
-
|
1253
|
-
|
1545
|
+
_proto5._parseInterfaceNode = function _parseInterfaceNode(node, isClient) {
|
1546
|
+
var name = node.name.value;
|
1547
|
+
|
1548
|
+
var type = this._types.get(name);
|
1549
|
+
|
1550
|
+
if (!type) {
|
1551
|
+
type = new InterfaceType(name, isClient);
|
1552
|
+
|
1553
|
+
this._types.set(name, type);
|
1554
|
+
}
|
1555
|
+
|
1556
|
+
if (!(type instanceof InterfaceType)) {
|
1557
|
+
throw createCompilerError("_parseInterfaceNode: Expected interface type. Got ".concat(String(type)), null, [node]);
|
1558
|
+
}
|
1559
|
+
|
1560
|
+
if (type.isClient !== isClient) {
|
1561
|
+
throw createCompilerError("_parseInterfaceNode: Cannot create interface '".concat(name, "' defined as a client interface"), null, [node]);
|
1562
|
+
}
|
1563
|
+
|
1564
|
+
node.fields && this._handleTypeFieldsStrict(type, node.fields, isClient);
|
1254
1565
|
};
|
1255
1566
|
|
1256
|
-
|
1257
|
-
|
1258
|
-
|
1567
|
+
_proto5._handleTypeFieldsStrict = function _handleTypeFieldsStrict(type, fields, isClient) {
|
1568
|
+
if (this._fields.has(type)) {
|
1569
|
+
throw createCompilerError('_handleTypeFieldsStrict: Unable to parse schema file. Duplicate definition for object type');
|
1570
|
+
}
|
1571
|
+
|
1572
|
+
this._handleTypeFields(type, fields, isClient);
|
1259
1573
|
};
|
1260
1574
|
|
1261
|
-
|
1262
|
-
var
|
1575
|
+
_proto5._handleTypeFields = function _handleTypeFields(type, fields, isClient) {
|
1576
|
+
var _this$_fields$get;
|
1263
1577
|
|
1264
|
-
|
1265
|
-
|
1266
|
-
|
1578
|
+
var fieldsMap = (_this$_fields$get = this._fields.get(type)) !== null && _this$_fields$get !== void 0 ? _this$_fields$get : new Map();
|
1579
|
+
fields.forEach(function (fieldNode) {
|
1580
|
+
var fieldName = fieldNode.name.value;
|
1267
1581
|
|
1268
|
-
|
1269
|
-
|
1582
|
+
if (fieldsMap.has(fieldName)) {
|
1583
|
+
throw createCompilerError("_handleTypeFields: Duplicate definition for field '".concat(fieldName, "'."));
|
1584
|
+
}
|
1270
1585
|
|
1271
|
-
|
1272
|
-
|
1586
|
+
fieldsMap.set(fieldName, {
|
1587
|
+
arguments: fieldNode.arguments ? fieldNode.arguments.map(function (arg) {
|
1588
|
+
return {
|
1589
|
+
name: arg.name.value,
|
1590
|
+
typeNode: arg.type,
|
1591
|
+
defaultValue: arg.defaultValue
|
1592
|
+
};
|
1593
|
+
}) : [],
|
1594
|
+
type: fieldNode.type,
|
1595
|
+
isClient: isClient
|
1596
|
+
});
|
1597
|
+
});
|
1598
|
+
|
1599
|
+
this._fields.set(type, fieldsMap);
|
1600
|
+
};
|
1601
|
+
|
1602
|
+
_proto5._parseInputObjectFields = function _parseInputObjectFields(type, node) {
|
1603
|
+
if (this._inputFields.has(type)) {
|
1604
|
+
throw createCompilerError('_parseInputObjectFields: Unable to parse schema file. Duplicate definition for type', null, [node]);
|
1273
1605
|
}
|
1274
1606
|
|
1275
|
-
var
|
1607
|
+
var fields = new Map();
|
1276
1608
|
|
1609
|
+
if (node.fields) {
|
1610
|
+
node.fields.forEach(function (fieldNode) {
|
1611
|
+
fields.set(fieldNode.name.value, fieldNode.type);
|
1612
|
+
});
|
1613
|
+
}
|
1277
1614
|
|
1278
|
-
|
1279
|
-
|
1280
|
-
|
1281
|
-
|
1282
|
-
|
1283
|
-
|
1284
|
-
|
1615
|
+
this._inputFields.set(type, fields);
|
1616
|
+
};
|
1617
|
+
|
1618
|
+
_proto5._parseDirective = function _parseDirective(node, isClient) {
|
1619
|
+
var name = node.name.value;
|
1620
|
+
|
1621
|
+
this._directives.set(name, {
|
1622
|
+
name: name,
|
1623
|
+
args: node.arguments ? node.arguments.map(function (arg) {
|
1624
|
+
return {
|
1625
|
+
name: arg.name.value,
|
1626
|
+
typeNode: arg.type,
|
1627
|
+
defaultValue: arg.defaultValue
|
1628
|
+
};
|
1629
|
+
}) : [],
|
1630
|
+
locations: node.locations.map(function (location) {
|
1631
|
+
switch (location.value) {
|
1632
|
+
case 'QUERY':
|
1633
|
+
case 'MUTATION':
|
1634
|
+
case 'SUBSCRIPTION':
|
1635
|
+
case 'FIELD':
|
1636
|
+
case 'FRAGMENT_DEFINITION':
|
1637
|
+
case 'FRAGMENT_SPREAD':
|
1638
|
+
case 'INLINE_FRAGMENT':
|
1639
|
+
case 'VARIABLE_DEFINITION':
|
1640
|
+
case 'SCHEMA':
|
1641
|
+
case 'SCALAR':
|
1642
|
+
case 'OBJECT':
|
1643
|
+
case 'FIELD_DEFINITION':
|
1644
|
+
case 'ARGUMENT_DEFINITION':
|
1645
|
+
case 'INTERFACE':
|
1646
|
+
case 'UNION':
|
1647
|
+
case 'ENUM':
|
1648
|
+
case 'ENUM_VALUE':
|
1649
|
+
case 'INPUT_OBJECT':
|
1650
|
+
case 'INPUT_FIELD_DEFINITION':
|
1651
|
+
return location.value;
|
1652
|
+
|
1653
|
+
default:
|
1654
|
+
throw createCompilerError('Invalid directive location');
|
1285
1655
|
}
|
1656
|
+
}),
|
1657
|
+
isClient: isClient
|
1658
|
+
});
|
1659
|
+
};
|
1660
|
+
|
1661
|
+
_proto5._parseObjectTypeExtension = function _parseObjectTypeExtension(node) {
|
1662
|
+
var type = this._types.get(node.name.value);
|
1663
|
+
|
1664
|
+
if (!(type instanceof ObjectType)) {
|
1665
|
+
throw createCompilerError("_parseObjectTypeExtension: Expected to find type with the name '".concat(node.name.value, "'"), null, [node]);
|
1666
|
+
}
|
1667
|
+
|
1668
|
+
node.fields && this._handleTypeFields(type, node.fields, true
|
1669
|
+
/** client fields */
|
1670
|
+
);
|
1671
|
+
};
|
1672
|
+
|
1673
|
+
_proto5._parseInterfaceTypeExtension = function _parseInterfaceTypeExtension(node) {
|
1674
|
+
var type = this._types.get(node.name.value);
|
1675
|
+
|
1676
|
+
if (!(type instanceof InterfaceType)) {
|
1677
|
+
throw createCompilerError('_parseInterfaceTypeExtension: Expected to have an interface type');
|
1678
|
+
}
|
1679
|
+
|
1680
|
+
node.fields && this._handleTypeFields(type, node.fields, true);
|
1681
|
+
};
|
1682
|
+
|
1683
|
+
_proto5._extend = function _extend(extensions) {
|
1684
|
+
var _this9 = this;
|
1685
|
+
|
1686
|
+
extensions.forEach(function (definition) {
|
1687
|
+
if (definition.kind === 'ObjectTypeDefinition') {
|
1688
|
+
_this9._parseObjectTypeNode(definition, true);
|
1689
|
+
} else if (definition.kind === 'InterfaceTypeDefinition') {
|
1690
|
+
_this9._parseInterfaceNode(definition, true);
|
1691
|
+
} else if (definition.kind === 'ScalarTypeDefinition') {
|
1692
|
+
_this9._parseScalarNode(definition, true);
|
1693
|
+
} else if (definition.kind === 'EnumTypeDefinition') {
|
1694
|
+
_this9._parseEnumNode(definition, true);
|
1695
|
+
} else if (definition.kind === 'InterfaceTypeExtension') {
|
1696
|
+
_this9._parseInterfaceTypeExtension(definition);
|
1697
|
+
} else if (definition.kind === 'ObjectTypeExtension') {
|
1698
|
+
_this9._parseObjectTypeExtension(definition);
|
1699
|
+
} else if (definition.kind === 'DirectiveDefinition') {
|
1700
|
+
_this9._parseDirective(definition, true
|
1701
|
+
/* client directive */
|
1702
|
+
);
|
1286
1703
|
} else {
|
1287
|
-
|
1704
|
+
throw createCompilerError("Unexpected extension kind: '".concat(definition.kind, "'"), null, [definition]);
|
1288
1705
|
}
|
1706
|
+
});
|
1707
|
+
};
|
1708
|
+
|
1709
|
+
_proto5.getTypes = function getTypes() {
|
1710
|
+
return Array.from(this._types.values());
|
1711
|
+
};
|
1712
|
+
|
1713
|
+
_proto5.getTypeByName = function getTypeByName(typename) {
|
1714
|
+
return this._types.get(typename);
|
1715
|
+
};
|
1716
|
+
|
1717
|
+
_proto5.getInterfaces = function getInterfaces(type) {
|
1718
|
+
var _this$_typeInterfaces;
|
1719
|
+
|
1720
|
+
return (_this$_typeInterfaces = this._typeInterfaces.get(type)) !== null && _this$_typeInterfaces !== void 0 ? _this$_typeInterfaces : [];
|
1721
|
+
};
|
1722
|
+
|
1723
|
+
_proto5.getPossibleTypeSet = function getPossibleTypeSet(type) {
|
1724
|
+
var set;
|
1725
|
+
|
1726
|
+
if (type instanceof InterfaceType) {
|
1727
|
+
var _this$_interfaceImple2;
|
1728
|
+
|
1729
|
+
set = (_this$_interfaceImple2 = this._interfaceImplementations.get(type)) !== null && _this$_interfaceImple2 !== void 0 ? _this$_interfaceImple2 : new Set();
|
1730
|
+
} else if (type instanceof UnionType) {
|
1731
|
+
var _this$_unionTypes$get;
|
1732
|
+
|
1733
|
+
set = (_this$_unionTypes$get = this._unionTypes.get(type)) !== null && _this$_unionTypes$get !== void 0 ? _this$_unionTypes$get : new Set();
|
1734
|
+
} else {
|
1735
|
+
throw createCompilerError('Invalid type supplied to "getPossibleTypeSet"');
|
1289
1736
|
}
|
1290
1737
|
|
1291
|
-
|
1738
|
+
if (!set) {
|
1739
|
+
throw createCompilerError("Unable to find possible types for ".concat(type.name));
|
1740
|
+
}
|
1741
|
+
|
1742
|
+
return set;
|
1292
1743
|
};
|
1293
1744
|
|
1294
|
-
|
1295
|
-
var
|
1745
|
+
_proto5.getFetchableFieldName = function getFetchableFieldName(type) {
|
1746
|
+
var _this$_fetchable$get$, _this$_fetchable$get;
|
1296
1747
|
|
1297
|
-
return (
|
1748
|
+
return (_this$_fetchable$get$ = (_this$_fetchable$get = this._fetchable.get(type)) === null || _this$_fetchable$get === void 0 ? void 0 : _this$_fetchable$get.field_name) !== null && _this$_fetchable$get$ !== void 0 ? _this$_fetchable$get$ : null;
|
1298
1749
|
};
|
1299
1750
|
|
1300
|
-
|
1301
|
-
return this.
|
1302
|
-
var name = _ref2.name;
|
1303
|
-
return name === 'fixme_fat_interface';
|
1304
|
-
}) || this.hasField(type, field.name) && this.isServerField(this.expectField(type, field.name));
|
1751
|
+
_proto5.getQueryType = function getQueryType() {
|
1752
|
+
return this._types.get(this._queryTypeName);
|
1305
1753
|
};
|
1306
1754
|
|
1307
|
-
|
1308
|
-
return
|
1309
|
-
}
|
1310
|
-
/**
|
1311
|
-
* The only consumer of this is RelayParser.parse(...)
|
1312
|
-
* We should either refactor RelayParser.parse(...) to not-rely on the `
|
1313
|
-
* extendSchema` method. Or actually implement it here.
|
1314
|
-
*/
|
1315
|
-
;
|
1755
|
+
_proto5.getMutationType = function getMutationType() {
|
1756
|
+
return this._types.get(this._mutationTypeName);
|
1757
|
+
};
|
1316
1758
|
|
1317
|
-
|
1318
|
-
|
1319
|
-
assumeValid: true
|
1320
|
-
});
|
1321
|
-
return new Schema(this._baseSchema, extendedSchema, this._typeMap, this._fieldsMap, this._typeNameMap, this._clientIdMap, this._possibleTypesMap, this._directivesMap, this.QUERY_TYPE_KEY, this.MUTATION_TYPE_KEY, this.SUBSCRIPTION_TYPE_KEY);
|
1759
|
+
_proto5.getSubscriptionType = function getSubscriptionType() {
|
1760
|
+
return this._types.get(this._subscriptionTypeName);
|
1322
1761
|
};
|
1323
1762
|
|
1324
|
-
|
1325
|
-
|
1763
|
+
_proto5.getField = function getField(type, fieldName) {
|
1764
|
+
var fields = this._fields.get(type);
|
1765
|
+
|
1766
|
+
if (fields) {
|
1767
|
+
return fields.get(fieldName);
|
1768
|
+
}
|
1769
|
+
};
|
1326
1770
|
|
1327
|
-
|
1771
|
+
_proto5.getFieldMap = function getFieldMap(type) {
|
1772
|
+
return this._fields.get(type);
|
1773
|
+
};
|
1328
1774
|
|
1329
|
-
function
|
1330
|
-
|
1775
|
+
_proto5.getInputField = function getInputField(type, fieldName) {
|
1776
|
+
var inputFields = this._inputFields.get(type);
|
1331
1777
|
|
1332
|
-
|
1333
|
-
|
1334
|
-
|
1778
|
+
if (inputFields) {
|
1779
|
+
return inputFields.get(fieldName);
|
1780
|
+
}
|
1781
|
+
};
|
1782
|
+
|
1783
|
+
_proto5.getInputFieldMap = function getInputFieldMap(type) {
|
1784
|
+
return this._inputFields.get(type);
|
1785
|
+
};
|
1786
|
+
|
1787
|
+
_proto5.getDirectives = function getDirectives() {
|
1788
|
+
return Array.from(this._directives.values());
|
1789
|
+
};
|
1790
|
+
|
1791
|
+
_proto5.extend = function extend(extensions) {
|
1792
|
+
return new TypeMap(this._source, this._extensions.concat(extensions));
|
1793
|
+
};
|
1335
1794
|
|
1336
|
-
|
1337
|
-
|
1338
|
-
|
1795
|
+
return TypeMap;
|
1796
|
+
}();
|
1797
|
+
|
1798
|
+
function create(baseSchema, schemaExtensionDocuments, schemaExtensions) {
|
1799
|
+
var extensions = [];
|
1800
|
+
schemaExtensions && schemaExtensions.forEach(function (source) {
|
1801
|
+
var doc = parse(source, {
|
1802
|
+
noLocation: true
|
1339
1803
|
});
|
1340
|
-
|
1341
|
-
|
1342
|
-
|
1343
|
-
|
1344
|
-
message: "Caught an error \"".concat(error.message, "\" while loading and parsing schema file: ").concat(source.name, ". Please make sure that schema is valid.")
|
1804
|
+
doc.definitions.forEach(function (definition) {
|
1805
|
+
if (isSchemaDefinitionAST(definition)) {
|
1806
|
+
extensions.push(definition);
|
1807
|
+
}
|
1345
1808
|
});
|
1346
|
-
}
|
1809
|
+
});
|
1810
|
+
schemaExtensionDocuments && schemaExtensionDocuments.forEach(function (doc) {
|
1811
|
+
doc.definitions.forEach(function (definition) {
|
1812
|
+
if (isSchemaDefinitionAST(definition)) {
|
1813
|
+
extensions.push(definition);
|
1814
|
+
}
|
1815
|
+
});
|
1816
|
+
});
|
1817
|
+
return new Schema(new TypeMap(baseSchema, extensions));
|
1347
1818
|
}
|
1348
|
-
/**
|
1349
|
-
* We need this in order to make unit-test works
|
1350
|
-
* In most of the unit-tests the schema is created from the instance of the
|
1351
|
-
* GraphQLSchema.
|
1352
|
-
*/
|
1353
1819
|
|
1820
|
+
function parseInputArgumentDefinitions(schema, args) {
|
1821
|
+
return args.map(function (arg) {
|
1822
|
+
var argType = schema.assertInputType(schema.expectTypeFromAST(arg.typeNode));
|
1823
|
+
var defaultValue;
|
1824
|
+
var defaultValueNode = arg.defaultValue;
|
1825
|
+
|
1826
|
+
if (defaultValueNode != null) {
|
1827
|
+
var nullableType = schema.getNullableType(argType);
|
1828
|
+
var isNullable = schema.isNonNull(argType) === false;
|
1829
|
+
|
1830
|
+
if (isNullable && defaultValueNode.kind === 'NullValue') {
|
1831
|
+
defaultValue = null;
|
1832
|
+
} else {
|
1833
|
+
if (nullableType instanceof ScalarType || nullableType instanceof EnumType) {
|
1834
|
+
defaultValue = schema.parseLiteral(nullableType, defaultValueNode);
|
1835
|
+
} else if (nullableType instanceof List && defaultValueNode.kind === 'ListValue' || nullableType instanceof InputObjectType && defaultValueNode.kind === 'ObjectValue') {
|
1836
|
+
defaultValue = valueFromASTUntyped(defaultValueNode);
|
1837
|
+
}
|
1838
|
+
}
|
1354
1839
|
|
1355
|
-
|
1356
|
-
|
1840
|
+
if (defaultValue === undefined) {
|
1841
|
+
throw createCompilerError("parseInputArgumentDefinitions: Unexpected default value: ".concat(String(defaultValueNode), ". Expected to have a value of type ").concat(String(nullableType), "."));
|
1842
|
+
}
|
1843
|
+
}
|
1357
1844
|
|
1358
|
-
|
1845
|
+
return {
|
1846
|
+
name: arg.name,
|
1847
|
+
type: argType,
|
1848
|
+
defaultValue: defaultValue
|
1849
|
+
};
|
1850
|
+
});
|
1359
1851
|
}
|
1360
1852
|
|
1361
|
-
function
|
1362
|
-
|
1853
|
+
function parseInputArgumentDefinitionsMap(schema, args) {
|
1854
|
+
return new Map(parseInputArgumentDefinitions(schema, args).map(function (arg) {
|
1855
|
+
return [arg.name, arg];
|
1856
|
+
}));
|
1857
|
+
}
|
1363
1858
|
|
1364
|
-
|
1365
|
-
|
1366
|
-
var extendedSchema = ASTConvert.extendASTSchema(transformedSchema, (_schemaExtensionDocum = schemaExtensionDocuments) !== null && _schemaExtensionDocum !== void 0 ? _schemaExtensionDocum : []);
|
1367
|
-
return new Schema(schema, extendedSchema, new Map(), new Map(), new Map(), new Map(), new Map(), null, Symbol('Query'), Symbol('Mutation'), Symbol('Subsription'));
|
1859
|
+
function isDefaultScalar(name) {
|
1860
|
+
return new Set(['ID', 'String', 'Boolean', 'Int', 'Float']).has(name);
|
1368
1861
|
}
|
1369
1862
|
|
1370
1863
|
module.exports = {
|
1371
|
-
DEPRECATED__buildGraphQLSchema: DEPRECATED__buildGraphQLSchema,
|
1372
|
-
DEPRECATED__create: DEPRECATED__create,
|
1373
1864
|
create: create
|
1374
1865
|
};
|