public class ClassNameTypeResolver extends Object implements TypeResolver
TypeResolver that tries to find a GraphQL Object type based on the
class name of a value returned from a DataFetcher. If necessary, it
walks up the base class and interface hierarchy to find a match.| Constructor and Description |
|---|
ClassNameTypeResolver() |
| Modifier and Type | Method and Description |
|---|---|
void |
addMapping(Class<?> clazz,
String graphQlTypeName)
Add a mapping from a Java
Class to a GraphQL Object type name. |
GraphQLObjectType |
getType(TypeResolutionEnvironment environment) |
void |
setClassNameExtractor(Function<Class<?>,String> classNameExtractor)
Customize how the name of a class, or a base class/interface, is determined.
|
public void setClassNameExtractor(Function<Class<?>,String> classNameExtractor)
By default, this is just Class.getSimpleName().
classNameExtractor - the function to usepublic void addMapping(Class<?> clazz, String graphQlTypeName)
Class to a GraphQL Object type name.
The mapping applies to the given type and to all of its sub-classes
(for a base class) or implementations (for an interface).clazz - the Java class to mapgraphQlTypeName - the matching GraphQL object type@Nullable public GraphQLObjectType getType(TypeResolutionEnvironment environment)
getType in interface TypeResolver