1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.VariablesAreInputTypesRule = VariablesAreInputTypesRule;
|
7 |
|
8 | var _GraphQLError = require("../../error/GraphQLError.js");
|
9 |
|
10 | var _printer = require("../../language/printer.js");
|
11 |
|
12 | var _definition = require("../../type/definition.js");
|
13 |
|
14 | var _typeFromAST = require("../../utilities/typeFromAST.js");
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 | function VariablesAreInputTypesRule(context) {
|
23 | return {
|
24 | VariableDefinition: function VariableDefinition(node) {
|
25 | var type = (0, _typeFromAST.typeFromAST)(context.getSchema(), node.type);
|
26 |
|
27 | if (type && !(0, _definition.isInputType)(type)) {
|
28 | var variableName = node.variable.name.value;
|
29 | var typeName = (0, _printer.print)(node.type);
|
30 | context.reportError(new _GraphQLError.GraphQLError("Variable \"$".concat(variableName, "\" cannot be non-input type \"").concat(typeName, "\"."), node.type));
|
31 | }
|
32 | }
|
33 | };
|
34 | }
|