1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.FragmentsOnCompositeTypesRule = FragmentsOnCompositeTypesRule;
|
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 |
|
23 | function FragmentsOnCompositeTypesRule(context) {
|
24 | return {
|
25 | InlineFragment: function InlineFragment(node) {
|
26 | var typeCondition = node.typeCondition;
|
27 |
|
28 | if (typeCondition) {
|
29 | var type = (0, _typeFromAST.typeFromAST)(context.getSchema(), typeCondition);
|
30 |
|
31 | if (type && !(0, _definition.isCompositeType)(type)) {
|
32 | var typeStr = (0, _printer.print)(typeCondition);
|
33 | context.reportError(new _GraphQLError.GraphQLError("Fragment cannot condition on non composite type \"".concat(typeStr, "\"."), typeCondition));
|
34 | }
|
35 | }
|
36 | },
|
37 | FragmentDefinition: function FragmentDefinition(node) {
|
38 | var type = (0, _typeFromAST.typeFromAST)(context.getSchema(), node.typeCondition);
|
39 |
|
40 | if (type && !(0, _definition.isCompositeType)(type)) {
|
41 | var typeStr = (0, _printer.print)(node.typeCondition);
|
42 | context.reportError(new _GraphQLError.GraphQLError("Fragment \"".concat(node.name.value, "\" cannot condition on non composite type \"").concat(typeStr, "\"."), node.typeCondition));
|
43 | }
|
44 | }
|
45 | };
|
46 | }
|