Class GraphQlHttpHandler

java.lang.Object
org.springframework.graphql.server.webflux.AbstractGraphQlHttpHandler
org.springframework.graphql.server.webflux.GraphQlHttpHandler

public class GraphQlHttpHandler extends AbstractGraphQlHttpHandler
WebFlux.fn Handler for GraphQL over HTTP requests.
Since:
1.0.0
Author:
Rossen Stoyanchev, Brian Clozel
  • Constructor Details

    • GraphQlHttpHandler

      public GraphQlHttpHandler(WebGraphQlHandler graphQlHandler)
      Create a new instance.
      Parameters:
      graphQlHandler - common handler for GraphQL over HTTP requests
    • GraphQlHttpHandler

      public GraphQlHttpHandler(WebGraphQlHandler graphQlHandler, CodecConfigurer codecConfigurer)
      Create a new instance.
      Parameters:
      graphQlHandler - common handler for GraphQL over HTTP requests
      codecConfigurer - codec configurer for JSON encoding and decoding
  • Method Details

    • isHttpOkOnValidationErrors

      public boolean isHttpOkOnValidationErrors()
      Return whether this HTTP handler should use HTTP 200 OK responses if an error occurs before the GraphQL request execution phase starts; for example, if JSON parsing, GraphQL document parsing, or GraphQL document validation fail.

      This option only applies to MediaTypes.APPLICATION_GRAPHQL_RESPONSE responses, as legacy MediaType.APPLICATION_JSON responses always use HTTP 200 OK in such cases. Enabling this option means the server will not conform to the "GraphQL over HTTP specification".

      By default, this is set to false.

      Since:
      1.4.0
      See Also:
    • setHttpOkOnValidationErrors

      @Deprecated(since="1.4.0", forRemoval=true) public void setHttpOkOnValidationErrors(boolean httpOkOnValidationErrors)
      Deprecated, for removal: This API element is subject to removal in a future version.
      since 1.4, will be made false permanently in a future release
      Set whether this HTTP handler should use HTTP 200 OK responses if an error occurs before the GraphQL request execution phase starts.
      Parameters:
      httpOkOnValidationErrors - whether "HTTP 200 OK" responses should always be used
      Since:
      1.4.0
      See Also:
    • prepareResponse

      protected reactor.core.publisher.Mono<ServerResponse> prepareResponse(ServerRequest request, WebGraphQlResponse response)
      Description copied from class: AbstractGraphQlHttpHandler
      Prepare the ServerResponse for the given GraphQL response.
      Specified by:
      prepareResponse in class AbstractGraphQlHttpHandler
      Parameters:
      request - the current request
      response - the GraphQL response
      Returns:
      the server response
    • selectResponseStatus

      protected HttpStatus selectResponseStatus(WebGraphQlResponse response, MediaType responseMediaType)