use of com.graphql_java_generator.annotation.GraphQLEnumType in project graphql-maven-plugin-project by graphql-java-generator.
the class GraphqlClientUtils method getGraphQLTypeNameFromClass.
/**
* Retrieves the GraphQL type name (as defined in the GraphQL schema), from the GraphQL annotation added in the
* generated code by the plugin.
*
* @param clazz
* @return
*/
public String getGraphQLTypeNameFromClass(Class<?> clazz) {
// Object
GraphQLObjectType graphQLObjectType = clazz.getAnnotation(GraphQLObjectType.class);
if (graphQLObjectType != null) {
return graphQLObjectType.value();
}
// Interface
GraphQLInterfaceType graphQLInterfaceType = clazz.getAnnotation(GraphQLInterfaceType.class);
if (graphQLInterfaceType != null) {
return graphQLInterfaceType.value();
}
// Union
GraphQLUnionType graphQLUnionType = clazz.getAnnotation(GraphQLUnionType.class);
if (graphQLUnionType != null) {
return graphQLUnionType.value();
}
// Enum
GraphQLEnumType graphQLEnumType = clazz.getAnnotation(GraphQLEnumType.class);
if (graphQLEnumType != null) {
return graphQLEnumType.value();
}
throw new RuntimeException("Could not find the GraphQL type for the class " + clazz.getName());
}
Aggregations