Search in sources :

Example 1 with GraphQLSuccessResponse

use of org.hyperledger.besu.ethereum.api.graphql.internal.response.GraphQLSuccessResponse in project besu by hyperledger.

the class GraphQLHttpService method process.

private GraphQLResponse process(final String requestJson, final String operationName, final Map<String, Object> variables) {
    Map<GraphQLContextType, Object> contextMap = new ConcurrentHashMap<>();
    contextMap.putAll(graphQlContextMap);
    contextMap.put(GraphQLContextType.IS_ALIVE_HANDLER, new IsAliveHandler(scheduler, config.getHttpTimeoutSec()));
    final ExecutionInput executionInput = ExecutionInput.newExecutionInput().query(requestJson).operationName(operationName).variables(variables).graphQLContext(contextMap).build();
    final ExecutionResult result = graphQL.execute(executionInput);
    final Map<String, Object> toSpecificationResult = result.toSpecification();
    final List<GraphQLError> errors = result.getErrors();
    if (errors.size() == 0) {
        return new GraphQLSuccessResponse(toSpecificationResult);
    } else {
        return new GraphQLErrorResponse(toSpecificationResult);
    }
}
Also used : GraphQLErrorResponse(org.hyperledger.besu.ethereum.api.graphql.internal.response.GraphQLErrorResponse) ExecutionResult(graphql.ExecutionResult) IsAliveHandler(org.hyperledger.besu.ethereum.api.handlers.IsAliveHandler) GraphQLSuccessResponse(org.hyperledger.besu.ethereum.api.graphql.internal.response.GraphQLSuccessResponse) GraphQLError(graphql.GraphQLError) ExecutionInput(graphql.ExecutionInput) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap)

Aggregations

ExecutionInput (graphql.ExecutionInput)1 ExecutionResult (graphql.ExecutionResult)1 GraphQLError (graphql.GraphQLError)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 GraphQLErrorResponse (org.hyperledger.besu.ethereum.api.graphql.internal.response.GraphQLErrorResponse)1 GraphQLSuccessResponse (org.hyperledger.besu.ethereum.api.graphql.internal.response.GraphQLSuccessResponse)1 IsAliveHandler (org.hyperledger.besu.ethereum.api.handlers.IsAliveHandler)1