use of graphql.GarfieldSchema.Dog in project graphql-java by graphql-java.
the class ReadmeExamples method unionType.
void unionType() {
TypeResolver typeResolver = new TypeResolver() {
@Override
public GraphQLObjectType getType(TypeResolutionEnvironment env) {
if (env.getObject() instanceof Cat) {
return CatType;
}
if (env.getObject() instanceof Dog) {
return DogType;
}
return null;
}
};
GraphQLUnionType PetType = newUnionType().name("Pet").possibleType(CatType).possibleType(DogType).build();
GraphQLCodeRegistry codeRegistry = newCodeRegistry().typeResolver("Pet", typeResolver).build();
}
Aggregations