1 | import { GraphQLError } from "../../error/GraphQLError.mjs";
|
2 | import { Kind } from "../../language/kinds.mjs";
|
3 | import { isExecutableDefinitionNode } from "../../language/predicates.mjs";
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | export function ExecutableDefinitionsRule(context) {
|
12 | return {
|
13 | Document: function Document(node) {
|
14 | for (var _i2 = 0, _node$definitions2 = node.definitions; _i2 < _node$definitions2.length; _i2++) {
|
15 | var definition = _node$definitions2[_i2];
|
16 |
|
17 | if (!isExecutableDefinitionNode(definition)) {
|
18 | var defName = definition.kind === Kind.SCHEMA_DEFINITION || definition.kind === Kind.SCHEMA_EXTENSION ? 'schema' : '"' + definition.name.value + '"';
|
19 | context.reportError(new GraphQLError("The ".concat(defName, " definition is not executable."), definition));
|
20 | }
|
21 | }
|
22 |
|
23 | return false;
|
24 | }
|
25 | };
|
26 | }
|