forked from graphql-java/graphql-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTypeFromAST.java
More file actions
30 lines (24 loc) · 962 Bytes
/
TypeFromAST.java
File metadata and controls
30 lines (24 loc) · 962 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package graphql.execution;
import graphql.Internal;
import graphql.language.ListType;
import graphql.language.NonNullType;
import graphql.language.Type;
import graphql.language.TypeName;
import graphql.schema.GraphQLList;
import graphql.schema.GraphQLNonNull;
import graphql.schema.GraphQLSchema;
import graphql.schema.GraphQLType;
@Internal
public class TypeFromAST {
public static GraphQLType getTypeFromAST(GraphQLSchema schema, Type type) {
GraphQLType innerType;
if (type instanceof ListType) {
innerType = getTypeFromAST(schema, ((ListType) type).getType());
return innerType != null ? new GraphQLList(innerType) : null;
} else if (type instanceof NonNullType) {
innerType = getTypeFromAST(schema, ((NonNullType) type).getType());
return innerType != null ? new GraphQLNonNull(innerType) : null;
}
return schema.getType(((TypeName) type).getName());
}
}