org.springframework.graphql.WebInput

Here are the examples of the java api org.springframework.graphql.WebInput taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

2 Examples 7

19 Source : GraphQLHttpHandler.java
with Apache License 2.0
from spring-projects-experimental

/**
 * {@inheritDoc}
 *
 * @throws ServletException may be raised when reading the request body,
 * e.g. {@link HttpMediaTypeNotSupportedException}.
 */
public ServerResponse handle(ServerRequest request) throws ServletException {
    WebInput webInput = new WebInput(request.uri(), request.headers().asHttpHeaders(), readBody(request));
    if (logger.isDebugEnabled()) {
        logger.debug("Executing: " + webInput);
    }
    Mono<ServerResponse> responseMono = this.executionChain.execute(webInput).map(output -> {
        if (logger.isDebugEnabled()) {
            logger.debug("Execution complete");
        }
        ServerResponse.BodyBuilder builder = ServerResponse.ok();
        if (output.getHeaders() != null) {
            builder.headers(headers -> headers.putAll(output.getHeaders()));
        }
        return builder.body(output.toSpecification());
    });
    return ServerResponse.async(responseMono);
}

18 Source : GraphQLHttpHandler.java
with Apache License 2.0
from spring-projects-experimental

/**
 * Handle GraphQL query requests over HTTP.
 */
public Mono<ServerResponse> handleQuery(ServerRequest request) {
    return request.bodyToMono(MAP_PARAMETERIZED_TYPE_REF).flatMap(body -> {
        WebInput webInput = new WebInput(request.uri(), request.headers().asHttpHeaders(), body);
        if (logger.isDebugEnabled()) {
            logger.debug("Executing: " + webInput);
        }
        return this.executionChain.execute(webInput);
    }).flatMap(output -> {
        Map<String, Object> spec = output.toSpecification();
        if (logger.isDebugEnabled()) {
            logger.debug("Execution complete");
        }
        ServerResponse.BodyBuilder builder = ServerResponse.ok();
        if (output.getHeaders() != null) {
            builder.headers(headers -> headers.putAll(output.getHeaders()));
        }
        return builder.bodyValue(spec);
    });
}