Search in sources :

Example 1 with GraphQLResponseBody

use of io.micronaut.configuration.graphql.GraphQLResponseBody in project micronaut-graphql by micronaut-projects.

the class GraphQLWsMessageHandler method executeRequest.

@SuppressWarnings("rawtypes")
private Publisher<GraphQLWsResponse> executeRequest(String operationId, GraphQLRequestBody payload, WebSocketSession session) {
    GraphQLInvocationData invocationData = new GraphQLInvocationData(payload.getQuery(), payload.getOperationName(), payload.getVariables());
    HttpRequest httpRequest = session.get(HTTP_REQUEST_KEY, HttpRequest.class).orElseThrow(() -> new RuntimeException("HttpRequest could not be retrieved from websocket session"));
    Publisher<ExecutionResult> executionResult = graphQLInvocation.invoke(invocationData, httpRequest, null);
    Publisher<GraphQLResponseBody> responseBody = graphQLExecutionResultHandler.handleExecutionResult(executionResult);
    return Flux.from(responseBody).flatMap(body -> responseSender.send(operationId, body, session));
}
Also used : HttpRequest(io.micronaut.http.HttpRequest) GraphQLInvocationData(io.micronaut.configuration.graphql.GraphQLInvocationData) ExecutionResult(graphql.ExecutionResult) GraphQLResponseBody(io.micronaut.configuration.graphql.GraphQLResponseBody)

Aggregations

ExecutionResult (graphql.ExecutionResult)1 GraphQLInvocationData (io.micronaut.configuration.graphql.GraphQLInvocationData)1 GraphQLResponseBody (io.micronaut.configuration.graphql.GraphQLResponseBody)1 HttpRequest (io.micronaut.http.HttpRequest)1