Class AbstractGraphQlHttpHandler

java.lang.Object
org.springframework.graphql.server.webmvc.AbstractGraphQlHttpHandler
Direct Known Subclasses:
GraphQlHttpHandler, GraphQlSseHandler

public abstract class AbstractGraphQlHttpHandler extends Object
Abstract base class for GraphQL over HTTP handlers.
Since:
1.3.0
Author:
Brian Clozel, Rossen Stoyanchev
  • Field Details

    • logger

      protected final org.apache.commons.logging.Log logger
  • Constructor Details

  • Method Details

    • prepareResponse

      protected abstract ServerResponse prepareResponse(ServerRequest request, reactor.core.publisher.Mono<WebGraphQlResponse> responseMono) throws jakarta.servlet.ServletException
      Prepare the ServerResponse for the given GraphQL response.
      Parameters:
      request - the current request
      responseMono - the GraphQL response
      Returns:
      the server response
      Throws:
      jakarta.servlet.ServletException
    • getSupportedOperations

      protected abstract Set<graphql.language.OperationDefinition.Operation> getSupportedOperations()
      Return the GraphQL operation types that this handler supports, regardless of the semantics of any particular request.
      Since:
      2.1.0
    • handleRequest

      public ServerResponse handleRequest(ServerRequest request) throws jakarta.servlet.ServletException
      Handle GraphQL over HTTP requests.
      Parameters:
      request - the current request
      Returns:
      the resulting response
      Throws:
      jakarta.servlet.ServletException - may be raised when reading the request body, e.g. HttpMediaTypeNotSupportedException.
    • getWriteFunction

      protected ServerResponse.HeadersBuilder.WriteFunction getWriteFunction(ServerRequest request, Map<String,Object> resultMap, MediaType contentType)
      Exposes a ServerResponse.HeadersBuilder.WriteFunction that writes the GraphQL response as JSON using a custom message converter, or one that is available in the configured message converters.
      Parameters:
      request - the server request
      resultMap - the result map to write
      contentType - to set the response content type to
      Returns:
      the write function
    • findRejection

      protected static @Nullable OperationNotAllowedException findRejection(WebGraphQlResponse response)
      Find an OperationNotAllowedException rejection in the response errors, if any.

      Must be called on the WebGraphQlResponse before it is serialized.

      Parameters:
      response - the GraphQL response
      Since:
      2.1.0