1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.typeFromAST = typeFromAST;
|
7 |
|
8 | var _kinds = require('../language/kinds');
|
9 |
|
10 | var Kind = _interopRequireWildcard(_kinds);
|
11 |
|
12 | var _wrappers = require('../type/wrappers');
|
13 |
|
14 | function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 | function typeFromAST(schema, typeNode) {
|
34 |
|
35 | var innerType = void 0;
|
36 | if (typeNode.kind === Kind.LIST_TYPE) {
|
37 | innerType = typeFromAST(schema, typeNode.type);
|
38 | return innerType && (0, _wrappers.GraphQLList)(innerType);
|
39 | }
|
40 | if (typeNode.kind === Kind.NON_NULL_TYPE) {
|
41 | innerType = typeFromAST(schema, typeNode.type);
|
42 | return innerType && (0, _wrappers.GraphQLNonNull)(innerType);
|
43 | }
|
44 | if (typeNode.kind === Kind.NAMED_TYPE) {
|
45 | return schema.getType(typeNode.name.value);
|
46 | }
|
47 |
|
48 | throw new Error('Unexpected type kind: ' + typeNode.kind + '.');
|
49 | } |
\ | No newline at end of file |