graphql.schema.TypeResolver Java Examples

The following examples show how to use graphql.schema.TypeResolver. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FullTypeGenerator.java    From graphql-java-type-generator with MIT License 6 votes vote down vote up
protected GraphQLInterfaceType generateInterfaceType(Object object) {
    List<GraphQLFieldDefinition> fieldDefinitions = getOutputFieldDefinitions(object);
    if (fieldDefinitions == null || fieldDefinitions.isEmpty()) {
        return null;
    }
    String name = getGraphQLTypeNameOrIdentityCode(object);
    TypeResolver typeResolver = getTypeResolver(object);
    String description = getTypeDescription(object);
    if (name == null || fieldDefinitions == null || typeResolver == null) {
        return null;
    }
    GraphQLInterfaceType.Builder builder = GraphQLInterfaceType.newInterface()
            .description(description)
            .fields(fieldDefinitions)
            .name(name)
            .typeResolver(typeResolver);
    return builder.build();
}
 
Example #2
Source File: TypeResolverStrategy_Caching.java    From graphql-java-type-generator with MIT License 5 votes vote down vote up
@Override
public TypeResolver getTypeResolver(Object object) {
    if (typeResolver == null) {
        typeResolver = new TypeResolver_BuildContextAware(getContext());
    }
    return typeResolver;
}
 
Example #3
Source File: HumanData.java    From vertx-graphql-service-discovery with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({"unchecked", "SuspiciousMethodCalls"})
static TypeResolver getCharacterTypeResolver() {
    return object -> {
        Object id = ((Map<String, Object>) object).get("id");
        if (humanData.containsKey(id)) {
            return StarWarsSchema.humanType;
        }
        return null;
    };
}
 
Example #4
Source File: DroidsData.java    From vertx-graphql-service-discovery with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({"unchecked", "SuspiciousMethodCalls"})
static TypeResolver getCharacterTypeResolver() {
    return object -> {
        Object id = ((Map<String, Object>) object).get("id");
        if (droidData.containsKey(id)) {
            return DroidsSchema.droidType;
        }
        return null;
    };
}
 
Example #5
Source File: SchemaTransformer.java    From federation-jvm with MIT License 4 votes vote down vote up
@NotNull
public SchemaTransformer resolveEntityType(TypeResolver entityTypeResolver) {
    this.entityTypeResolver = entityTypeResolver;
    return this;
}
 
Example #6
Source File: TypeGenerator.java    From graphql-java-type-generator with MIT License 4 votes vote down vote up
protected TypeResolver getTypeResolver(Object object) {
    return getStrategies().getTypeResolverStrategy().getTypeResolver(object);
}
 
Example #7
Source File: GraphQLSchemaGenerator.java    From graphql-spqr with Apache License 2.0 4 votes vote down vote up
default TypeResolver getTypeResolver(GraphQLInterfaceType interfaceType) {
    return null;
}
 
Example #8
Source File: GraphQLSchemaGenerator.java    From graphql-spqr with Apache License 2.0 4 votes vote down vote up
default TypeResolver getTypeResolver(GraphQLUnionType unionType) {
    return null;
}
 
Example #9
Source File: GraphQLSchemaGenerator.java    From graphql-spqr with Apache License 2.0 4 votes vote down vote up
@Override
public TypeResolver getTypeResolver(GraphQLInterfaceType interfaceType) {
    return codeRegistry.getTypeResolver(interfaceType);
}
 
Example #10
Source File: GraphQLSchemaGenerator.java    From graphql-spqr with Apache License 2.0 4 votes vote down vote up
@Override
public TypeResolver getTypeResolver(GraphQLUnionType unionType) {
    return codeRegistry.getTypeResolver(unionType);
}
 
Example #11
Source File: SchemaCustomizer.java    From engine with GNU General Public License v3.0 4 votes vote down vote up
public ResolverBuilder(final String typeName, final TypeResolver resolver) {
    this.typeName = typeName;
    this.resolver = resolver;
}
 
Example #12
Source File: RdfWiringFactory.java    From timbuctoo with GNU General Public License v3.0 4 votes vote down vote up
@Override
public TypeResolver getTypeResolver(InterfaceWiringEnvironment environment) {
  return objectTypeResolver;
}
 
Example #13
Source File: RdfWiringFactory.java    From timbuctoo with GNU General Public License v3.0 4 votes vote down vote up
@Override
public TypeResolver getTypeResolver(UnionWiringEnvironment environment) {
  return objectTypeResolver;
}
 
Example #14
Source File: TypeResolverStrategy.java    From graphql-java-type-generator with MIT License votes vote down vote up
TypeResolver getTypeResolver(Object object);