File tree Expand file tree Collapse file tree 1 file changed +11
-18
lines changed Expand file tree Collapse file tree 1 file changed +11
-18
lines changed Original file line number Diff line number Diff line change 1- import { inspect } from '../jsutils/inspect' ;
2- import { invariant } from '../jsutils/invariant' ;
3-
41import type {
52 TypeNode ,
63 NamedTypeNode ,
@@ -41,20 +38,16 @@ export function typeFromAST(
4138 schema : GraphQLSchema ,
4239 typeNode : TypeNode ,
4340) : GraphQLType | undefined {
44- let innerType ;
45- if ( typeNode . kind === Kind . LIST_TYPE ) {
46- innerType = typeFromAST ( schema , typeNode . type ) ;
47- return innerType && new GraphQLList ( innerType ) ;
48- }
49- if ( typeNode . kind === Kind . NON_NULL_TYPE ) {
50- innerType = typeFromAST ( schema , typeNode . type ) ;
51- return innerType && new GraphQLNonNull ( innerType ) ;
41+ switch ( typeNode . kind ) {
42+ case Kind . LIST_TYPE : {
43+ const innerType = typeFromAST ( schema , typeNode . type ) ;
44+ return innerType && new GraphQLList ( innerType ) ;
45+ }
46+ case Kind . NON_NULL_TYPE : {
47+ const innerType = typeFromAST ( schema , typeNode . type ) ;
48+ return innerType && new GraphQLNonNull ( innerType ) ;
49+ }
50+ case Kind . NAMED_TYPE :
51+ return schema . getType ( typeNode . name . value ) ;
5252 }
53- // istanbul ignore else (See: 'https://github.com/graphql/graphql-js/issues/2618')
54- if ( typeNode . kind === Kind . NAMED_TYPE ) {
55- return schema . getType ( typeNode . name . value ) ;
56- }
57-
58- // istanbul ignore next (Not reachable. All possible type nodes have been considered)
59- invariant ( false , 'Unexpected type node: ' + inspect ( typeNode ) ) ;
6053}
You can’t perform that action at this time.
0 commit comments