Class DefaultExecutionGraphQlRequest

java.lang.Object
org.springframework.graphql.support.DefaultGraphQlRequest
org.springframework.graphql.support.DefaultExecutionGraphQlRequest
All Implemented Interfaces:
ExecutionGraphQlRequest, GraphQlRequest
Direct Known Subclasses:
RSocketGraphQlRequest, WebGraphQlRequest

public class DefaultExecutionGraphQlRequest extends DefaultGraphQlRequest implements ExecutionGraphQlRequest
GraphQlRequest for server side handling, adding the transport (e.g. HTTP or WebSocket handler) assigned id and locale in the addition to the GraphQlRequest inputs.

Supports the initialization of ExecutionInput that is passed to GraphQL. You can customize that via configureExecutionInput(BiFunction).

Since:
1.0.0
Author:
Rossen Stoyanchev, Brian Clozel
  • Constructor Details

    • DefaultExecutionGraphQlRequest

      public DefaultExecutionGraphQlRequest(String document, @Nullable String operationName, @Nullable Map<String,Object> variables, @Nullable Map<String,Object> extensions, String id, @Nullable Locale locale)
      Create an instance.
      Parameters:
      document - textual representation of the operation(s)
      operationName - optionally, the name of the operation to execute
      variables - variables by which the query is parameterized
      extensions - implementor specific, protocol extensions
      id - the request id, to be used as the ExecutionId
      locale - the locale associated with the request
  • Method Details

    • getId

      public String getId()
      Description copied from interface: ExecutionGraphQlRequest
      Return the transport assigned id for the request that in turn sets executionId.

      By default, the id is initialized as follows:

      • On WebFlux, this is the ServerHttpRequest id which correlates to WebFlux log messages. For Reactor Netty, it also correlates to server log messages.
      • On Spring MVC, the id is generated via AlternativeJdkIdGenerator, which does not correlate to anything, but is more efficient than the default ExecutionIdProvider which relies on UUID.randomUUID().
      • On WebSocket, the id is set to the message id of the "subscribe" message from the GraphQL over WebSocket protocol that is used to correlate request and response messages on the the WebSocket.

      To override this id, use ExecutionGraphQlRequest.executionId(ExecutionId) or configure GraphQL with an ExecutionIdProvider.

      Specified by:
      getId in interface ExecutionGraphQlRequest
      Returns:
      the request id
    • executionId

      public void executionId(graphql.execution.ExecutionId executionId)
      Description copied from interface: ExecutionGraphQlRequest
      Configure the ExecutionId to set on ExecutionInput.getExecutionId(), overriding the transport assigned id.
      Specified by:
      executionId in interface ExecutionGraphQlRequest
      Parameters:
      executionId - the id to use
    • getExecutionId

      public @Nullable graphql.execution.ExecutionId getExecutionId()
      Description copied from interface: ExecutionGraphQlRequest
      Return the configured executionId.
      Specified by:
      getExecutionId in interface ExecutionGraphQlRequest
    • getLocale

      public Locale getLocale()
      Description copied from interface: ExecutionGraphQlRequest
      Return the transport assigned locale value, if any.
      Specified by:
      getLocale in interface ExecutionGraphQlRequest
    • configureExecutionInput

      public void configureExecutionInput(BiFunction<graphql.ExecutionInput, graphql.ExecutionInput.Builder, graphql.ExecutionInput> configurer)
      Description copied from interface: ExecutionGraphQlRequest
      Provide a BiFunction to help initialize the ExecutionInput passed to GraphQL. The ExecutionInput is first pre-populated with values from "this" ExecutionGraphQlRequest, and is then customized with the functions provided here.
      Specified by:
      configureExecutionInput in interface ExecutionGraphQlRequest
      Parameters:
      configurer - a BiFunction that accepts the ExecutionInput initialized so far, and a builder to customize it.
    • toExecutionInput

      public graphql.ExecutionInput toExecutionInput()
      Description copied from interface: ExecutionGraphQlRequest
      Create the ExecutionInput to pass to GraphQL. passed to GraphQL. The ExecutionInput is populated with values from "this" ExecutionGraphQlRequest, and then customized with functions provided via ExecutionGraphQlRequest.configureExecutionInput(BiFunction).
      Specified by:
      toExecutionInput in interface ExecutionGraphQlRequest
      Returns:
      the resulting ExecutionInput
    • toString

      public String toString()
      Overrides:
      toString in class DefaultGraphQlRequest