Search in sources :

Example 1 with ResolvedValue

use of graphql.execution.nextgen.result.ResolvedValue 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)

Example 2 with ResolvedValue

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

the class DefaultExecutionStrategy method resolveNode.

private CompletableFuture<NodeZipper<ExecutionResultNode>> resolveNode(ExecutionContext executionContext, NodeZipper<ExecutionResultNode> unresolvedNode) {
    ExecutionStepInfo executionStepInfo = unresolvedNode.getCurNode().getExecutionStepInfo();
    ResolvedValue resolvedValue = unresolvedNode.getCurNode().getResolvedValue();
    FieldSubSelection fieldSubSelection = util.createFieldSubSelection(executionContext, executionStepInfo, resolvedValue);
    return resolveSubSelection(executionContext, fieldSubSelection).thenApply(resolvedChildMap -> unresolvedNode.withNewNode(new ObjectExecutionResultNode(executionStepInfo, resolvedValue, resolvedChildMap)));
}
Also used : ExecutionStepInfo(graphql.execution.ExecutionStepInfo) ObjectExecutionResultNode(graphql.execution.nextgen.result.ObjectExecutionResultNode) ResolvedValue(graphql.execution.nextgen.result.ResolvedValue)

Aggregations

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