Package graphql

Interface ExecutionResult

All Known Subinterfaces:
IncrementalExecutionResult
All Known Implementing Classes:
ExecutionResultImpl, IncrementalExecutionResultImpl

@PublicApi public interface ExecutionResult
This simple value class represents the result of performing a graphql query.
  • Method Details

    • getErrors

      List<GraphQLError> getErrors()
      Returns:
      the errors that occurred during execution or empty list if there is none
    • getData

      <T> T getData()
      Type Parameters:
      T - allows type coercion
      Returns:
      the data in the result or null if there is none
    • isDataPresent

      boolean isDataPresent()
      The graphql specification specifies: "If an error was encountered before execution begins, the data entry should not be present in the result. If an error was encountered during the execution that prevented a valid response, the data entry in the response should be null." This allows to distinguish between the cases where getData() returns null. See : http://graphql.github.io/graphql-spec/June2018/#sec-Data
      Returns:
      true if the entry "data" should be present in the result false otherwise
    • getExtensions

      Map<Object,Object> getExtensions()
      Returns:
      a map of extensions or null if there are none
    • toSpecification

      Map<String,Object> toSpecification()
      The graphql specification says that result of a call should be a map that follows certain rules on what items should be present. Certain JSON serializers may or may interpret ExecutionResult to spec, so this method is provided to produce a map that strictly follows the specification. See : http://spec.graphql.org/October2021/#sec-Response-Format
      Returns:
      a map of the result that strictly follows the spec
    • fromSpecification

      static ExecutionResult fromSpecification(Map<String,Object> specificationMap)
      This allows you to turn a map of results from toSpecification() and turn it back into a ExecutionResult
      Parameters:
      specificationMap - the specification result map
      Returns:
      a new ExecutionResult from that map
    • transform

      default ExecutionResult transform(Consumer<ExecutionResult.Builder<?>> builderConsumer)
      This helps you transform the current ExecutionResult 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 ExecutionResult object based on calling build on that builder
    • newExecutionResult

      static ExecutionResult.Builder<?> newExecutionResult()
      Returns:
      a builder that allows you to build a new execution result