Class GraphQlHttpHandler

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

public class GraphQlHttpHandler extends AbstractGraphQlHttpHandler
GraphQL handler to expose as a WebMvc functional endpoint via RouterFunctions.
Since:
1.0.0
Author:
Rossen Stoyanchev, Brian Clozel
  • Constructor Details

  • Method Details

    • builder

      public static GraphQlHttpHandler.Builder builder(WebGraphQlHandler graphQlHandler)
      Return a builder to create a GraphQlHttpHandler, e.g. to configure which HTTP methods it should support.
      Parameters:
      graphQlHandler - common handler for GraphQL over HTTP requests
      Since:
      2.1.0
    • getHttpMethods

      public Set<HttpMethod> getHttpMethods()
      Return the HTTP methods this handler is configured to support.

      Applications should use this value when configuring the matching RequestPredicate, so that both stay in sync.

      Since:
      2.1.0
    • 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:
    • prepareResponse

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

      protected HttpStatus selectResponseStatus(ServerRequest request, WebGraphQlResponse response, MediaType responseMediaType)
      Select the HTTP response status, taking into account any rejection of the request's operation type based on the semantics of the current HTTP method.
      Parameters:
      request - the HTTP request
      response - the GraphQL response
      responseMediaType - the HTTP response media type
    • getSupportedOperations

      protected Set<graphql.language.OperationDefinition.Operation> getSupportedOperations()
      Description copied from class: AbstractGraphQlHttpHandler
      Return the GraphQL operation types that this handler supports, regardless of the semantics of any particular request.
      Specified by:
      getSupportedOperations in class AbstractGraphQlHttpHandler