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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
ExecutionResult.Builder<B extends ExecutionResult.Builder<B>>
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description <T> T
getData()
java.util.List<GraphQLError>
getErrors()
java.util.Map<java.lang.Object,java.lang.Object>
getExtensions()
boolean
isDataPresent()
The graphql specification specifies: "If an error was encountered before execution begins, the data entry should not be present in the result.static ExecutionResult.Builder<?>
newExecutionResult()
java.util.Map<java.lang.String,java.lang.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.default ExecutionResult
transform(java.util.function.Consumer<ExecutionResult.Builder<?>> builderConsumer)
This helps you transform the currentExecutionResult
object into another one by starting a builder with all the current values and allows you to transform it how you want.
-
-
-
Method Detail
-
getErrors
java.util.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 wheregetData()
returns null. See : https://graphql.github.io/graphql-spec/June2018/#sec-Data- Returns:
true
if the entry "data" should be present in the resultfalse
otherwise
-
getExtensions
java.util.Map<java.lang.Object,java.lang.Object> getExtensions()
- Returns:
- a map of extensions or null if there are none
-
toSpecification
java.util.Map<java.lang.String,java.lang.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 interpretExecutionResult
to spec, so this method is provided to produce a map that strictly follows the specification. See : https://spec.graphql.org/October2021/#sec-Response-Format- Returns:
- a map of the result that strictly follows the spec
-
transform
default ExecutionResult transform(java.util.function.Consumer<ExecutionResult.Builder<?>> builderConsumer)
This helps you transform the currentExecutionResult
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
-
-