forked from graphql-java/graphql-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGraphQLTypeUtil.java
More file actions
30 lines (27 loc) · 893 Bytes
/
GraphQLTypeUtil.java
File metadata and controls
30 lines (27 loc) · 893 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.schema;
import graphql.Internal;
@Internal
public class GraphQLTypeUtil {
/**
* This will get the unwrapped type name that includes the non null and list wrappers
* so it might be '[typeName!]'
*
* @param type the type in play
*
* @return the unwrapped type name
*/
public static String getUnwrappedTypeName(GraphQLType type) {
StringBuilder sb = new StringBuilder();
if (type instanceof GraphQLNonNull) {
sb.append(getUnwrappedTypeName(((GraphQLNonNull) type).getWrappedType()));
sb.append("!");
} else if (type instanceof GraphQLList) {
sb.append("[");
sb.append(getUnwrappedTypeName(((GraphQLList) type).getWrappedType()));
sb.append("]");
} else {
sb.append(type.getName());
}
return sb.toString();
}
}