Search in sources :

Example 1 with LeafExecutionResultNode

use of graphql.execution.nextgen.result.LeafExecutionResultNode in project graphql-java by graphql-java.

the class ResultNodesCreator method createResultNode.

public ExecutionResultNode createResultNode(FetchedValueAnalysis fetchedValueAnalysis) {
    ResolvedValue resolvedValue = createResolvedValue(fetchedValueAnalysis);
    ExecutionStepInfo executionStepInfo = fetchedValueAnalysis.getExecutionStepInfo();
    if (fetchedValueAnalysis.isNullValue() && executionStepInfo.isNonNullType()) {
        NonNullableFieldWasNullException nonNullableFieldWasNullException = new NonNullableFieldWasNullException(executionStepInfo, executionStepInfo.getPath());
        return new LeafExecutionResultNode(executionStepInfo, resolvedValue, nonNullableFieldWasNullException);
    }
    if (fetchedValueAnalysis.isNullValue()) {
        return new LeafExecutionResultNode(executionStepInfo, resolvedValue, null);
    }
    if (fetchedValueAnalysis.getValueType() == FetchedValueAnalysis.FetchedValueType.OBJECT) {
        return createUnresolvedNode(fetchedValueAnalysis);
    }
    if (fetchedValueAnalysis.getValueType() == FetchedValueAnalysis.FetchedValueType.LIST) {
        return createListResultNode(fetchedValueAnalysis);
    }
    return new LeafExecutionResultNode(executionStepInfo, resolvedValue, null);
}
Also used : NonNullableFieldWasNullException(graphql.execution.NonNullableFieldWasNullException) ExecutionStepInfo(graphql.execution.ExecutionStepInfo) ResolvedValue(graphql.execution.nextgen.result.ResolvedValue) LeafExecutionResultNode(graphql.execution.nextgen.result.LeafExecutionResultNode)

Aggregations

ExecutionStepInfo (graphql.execution.ExecutionStepInfo)1 NonNullableFieldWasNullException (graphql.execution.NonNullableFieldWasNullException)1 LeafExecutionResultNode (graphql.execution.nextgen.result.LeafExecutionResultNode)1 ResolvedValue (graphql.execution.nextgen.result.ResolvedValue)1