1 | import { GraphQLError } from "../../error/GraphQLError.mjs";
|
2 | import { print } from "../../language/printer.mjs";
|
3 | import { isInputType } from "../../type/definition.mjs";
|
4 | import { typeFromAST } from "../../utilities/typeFromAST.mjs";
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | export function VariablesAreInputTypesRule(context) {
|
13 | return {
|
14 | VariableDefinition: function VariableDefinition(node) {
|
15 | var type = typeFromAST(context.getSchema(), node.type);
|
16 |
|
17 | if (type && !isInputType(type)) {
|
18 | var variableName = node.variable.name.value;
|
19 | var typeName = print(node.type);
|
20 | context.reportError(new GraphQLError("Variable \"$".concat(variableName, "\" cannot be non-input type \"").concat(typeName, "\"."), node.type));
|
21 | }
|
22 | }
|
23 | };
|
24 | }
|