UNPKG

715 BJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, '__esModule', {
4 value: true,
5});
6exports.typeFromAST = typeFromAST;
7
8var _kinds = require('../language/kinds.js');
9
10var _definition = require('../type/definition.js');
11
12function typeFromAST(schema, typeNode) {
13 switch (typeNode.kind) {
14 case _kinds.Kind.LIST_TYPE: {
15 const innerType = typeFromAST(schema, typeNode.type);
16 return innerType && new _definition.GraphQLList(innerType);
17 }
18
19 case _kinds.Kind.NON_NULL_TYPE: {
20 const innerType = typeFromAST(schema, typeNode.type);
21 return innerType && new _definition.GraphQLNonNull(innerType);
22 }
23
24 case _kinds.Kind.NAMED_TYPE:
25 return schema.getType(typeNode.name.value);
26 }
27}