Search in sources :

Example 1 with TypeResolutionEnvironment

use of graphql.TypeResolutionEnvironment in project graphql-java by graphql-java.

the class ExecutionStrategy method resolveTypeForUnion.

/**
 * Called to resolve a {@link GraphQLUnionType} into a specific {@link GraphQLObjectType} so the object can be executed in terms of that type
 *
 * @param params the params needed for type resolution
 *
 * @return a {@link GraphQLObjectType}
 */
protected GraphQLObjectType resolveTypeForUnion(TypeResolutionParameters params) {
    TypeResolutionEnvironment env = new TypeResolutionEnvironment(params.getValue(), params.getArgumentValues(), params.getField(), params.getGraphQLUnionType(), params.getSchema(), params.getContext());
    GraphQLObjectType result = params.getGraphQLUnionType().getTypeResolver().getType(env);
    if (result == null) {
        throw new UnresolvedTypeException(params.getGraphQLUnionType());
    }
    return result;
}
Also used : GraphQLObjectType(graphql.schema.GraphQLObjectType) TypeResolutionEnvironment(graphql.TypeResolutionEnvironment)

Example 2 with TypeResolutionEnvironment

use of graphql.TypeResolutionEnvironment in project graphql-java by graphql-java.

the class ExecutionStrategy method resolveTypeForInterface.

/**
 * Called to resolve a {@link GraphQLInterfaceType} into a specific {@link GraphQLObjectType} so the object can be executed in terms of that type
 *
 * @param params the params needed for type resolution
 *
 * @return a {@link GraphQLObjectType}
 */
protected GraphQLObjectType resolveTypeForInterface(TypeResolutionParameters params) {
    TypeResolutionEnvironment env = new TypeResolutionEnvironment(params.getValue(), params.getArgumentValues(), params.getField(), params.getGraphQLInterfaceType(), params.getSchema(), params.getContext());
    GraphQLObjectType result = params.getGraphQLInterfaceType().getTypeResolver().getType(env);
    if (result == null) {
        throw new UnresolvedTypeException(params.getGraphQLInterfaceType());
    }
    return result;
}
Also used : GraphQLObjectType(graphql.schema.GraphQLObjectType) TypeResolutionEnvironment(graphql.TypeResolutionEnvironment)

Aggregations

TypeResolutionEnvironment (graphql.TypeResolutionEnvironment)2 GraphQLObjectType (graphql.schema.GraphQLObjectType)2