Package graphql

Class ExecutionInput

java.lang.Object
graphql.ExecutionInput

@PublicApi @NullMarked public class ExecutionInput extends Object
This represents the series of values that can be input on a graphql query execution
  • Field Details

    • PERSISTED_QUERY_MARKER

      public static final String PERSISTED_QUERY_MARKER
      In order for getQuery() to never be null, use this to mark them so that invariant can be satisfied while assuming that the persisted query id is elsewhere.
      See Also:
  • Method Details

    • getQuery

      public String getQuery()
      Returns:
      the query text
    • getOperationName

      public @Nullable String getOperationName()
      Returns:
      the name of the query operation
    • getContext

      @Deprecated(since="2021-07-05") public @Nullable Object getContext()
      Deprecated.
      The legacy context object has been deprecated in favour of the more shareable getGraphQLContext()
      Returns:
      the context object to pass to all data fetchers
    • getGraphQLContext

      public GraphQLContext getGraphQLContext()
      Returns:
      the shared GraphQLContext object to pass to all data fetchers
    • getLocalContext

      public @Nullable Object getLocalContext()
      Returns:
      the local context object to pass to all top level (i.e. query, mutation, subscription) data fetchers
    • getRoot

      public @Nullable Object getRoot()
      Returns:
      the root object to start the query execution on
    • getVariables

      public Map<String,Object> getVariables()
      Returns:
      a map of raw variables that can be referenced via $syntax in the query.
    • getRawVariables

      public RawVariables getRawVariables()
      Returns:
      a map of raw variables that can be referenced via $syntax in the query.
    • getDataLoaderRegistry

      public org.dataloader.DataLoaderRegistry getDataLoaderRegistry()
      Returns:
      the data loader registry associated with this execution
    • getExecutionId

      public @Nullable ExecutionId getExecutionId()
      This value can be null before the execution starts, but once the execution starts, it will be set to a non-null value. See #getExecutionIdNonNull() for a non-null version of this.
      Returns:
      Id that will be/was used to execute this operation.
    • getExecutionIdNonNull

      public ExecutionId getExecutionIdNonNull()
      Once the execution starts, GraphQL Java will make sure that this execution id is non-null. Therefore use this method if you are sue that the execution has started to get a guaranteed non-null execution id.
      Returns:
      the non null execution id of this operation.
    • getLocale

      public Locale getLocale()
      This returns the locale of this operation.
      Returns:
      the locale of this operation
    • getExtensions

      public Map<String,Object> getExtensions()
      Returns:
      a map of extension values that can be sent in to a request
    • isCancelled

      public boolean isCancelled()
      The graphql engine will check this frequently and if that is true, it will throw a AbortExecutionException to cancel the execution.

      This is a cooperative cancellation. Some asynchronous data fetching code may still continue to run but there will be no more efforts run future field fetches say.

      Returns:
      true if the execution should be cancelled
    • cancel

      public void cancel()
      This can be called to cancel the graphql execution. Remember this is a cooperative cancellation and the graphql engine needs to be running on a thread to allow is to respect this flag.
    • isProfileExecution

      public boolean isProfileExecution()
    • transform

      public ExecutionInput transform(Consumer<ExecutionInput.Builder> builderConsumer)
      This helps you transform the current ExecutionInput object into another one by starting a builder with all the current values and allows you to transform it how you want.
      Parameters:
      builderConsumer - the consumer code that will be given a builder to transform
      Returns:
      a new ExecutionInput object based on calling build on that builder
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • newExecutionInput

      public static ExecutionInput.Builder newExecutionInput()
      Returns:
      a new builder of ExecutionInput objects
    • newExecutionInput

      public static ExecutionInput.Builder newExecutionInput(String query)
      Creates a new builder of ExecutionInput objects with the given query
      Parameters:
      query - the query to execute
      Returns:
      a new builder of ExecutionInput objects