1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.findDeprecatedUsages = findDeprecatedUsages;
|
7 |
|
8 | var _GraphQLError = require('../error/GraphQLError');
|
9 |
|
10 | var _visitor = require('../language/visitor');
|
11 |
|
12 | var _definition = require('../type/definition');
|
13 |
|
14 | var _schema = require('../type/schema');
|
15 |
|
16 | var _TypeInfo = require('./TypeInfo');
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 | function findDeprecatedUsages(schema, ast) {
|
24 | var errors = [];
|
25 | var typeInfo = new _TypeInfo.TypeInfo(schema);
|
26 |
|
27 | (0, _visitor.visit)(ast, (0, _visitor.visitWithTypeInfo)(typeInfo, {
|
28 | Field: function Field(node) {
|
29 | var fieldDef = typeInfo.getFieldDef();
|
30 | if (fieldDef && fieldDef.isDeprecated) {
|
31 | var parentType = typeInfo.getParentType();
|
32 | if (parentType) {
|
33 | var reason = fieldDef.deprecationReason;
|
34 | errors.push(new _GraphQLError.GraphQLError('The field ' + parentType.name + '.' + fieldDef.name + ' is deprecated.' + (reason ? ' ' + reason : ''), [node]));
|
35 | }
|
36 | }
|
37 | },
|
38 | EnumValue: function EnumValue(node) {
|
39 | var enumVal = typeInfo.getEnumValue();
|
40 | if (enumVal && enumVal.isDeprecated) {
|
41 | var type = (0, _definition.getNamedType)(typeInfo.getInputType());
|
42 | if (type) {
|
43 | var reason = enumVal.deprecationReason;
|
44 | errors.push(new _GraphQLError.GraphQLError('The enum value ' + type.name + '.' + enumVal.name + ' is deprecated.' + (reason ? ' ' + reason : ''), [node]));
|
45 | }
|
46 | }
|
47 | }
|
48 | }));
|
49 |
|
50 | return errors;
|
51 | } |
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
\ | No newline at end of file |