Package graphql
Interface ExecutionResult
- All Known Subinterfaces:
IncrementalExecutionResult
- All Known Implementing Classes:
ExecutionResultImpl,IncrementalExecutionResultImpl
This simple value class represents the result of performing a graphql query.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceExecutionResult.Builder<B extends ExecutionResult.Builder<B>> -
Method Summary
Modifier and TypeMethodDescriptionstatic ExecutionResultfromSpecification(Map<String, Object> specificationMap) This allows you to turn a map of results fromtoSpecification()and turn it back into aExecutionResult<T> @Nullable TgetData()booleanThe graphql specification specifies:static ExecutionResult.Builder<?> The graphql specification says that result of a call should be a map that follows certain rules on what items should be present.default ExecutionResulttransform(Consumer<ExecutionResult.Builder<?>> builderConsumer) This helps you transform the currentExecutionResultobject into another one by starting a builder with all the current values and allows you to transform it how you want.
-
Method Details
-
getErrors
List<GraphQLError> getErrors()- Returns:
- the errors that occurred during execution or empty list if there is none
-
getData
<T> @Nullable 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 : https://graphql.github.io/graphql-spec/June2018/#sec-Data
- Returns:
trueif the entry "data" should be present in the resultfalseotherwise
-
getExtensions
- Returns:
- a map of extensions or null if there are none
-
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 interpretExecutionResultto 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
-
fromSpecification
This allows you to turn a map of results fromtoSpecification()and turn it back into aExecutionResult- Parameters:
specificationMap- the specification result map- Returns:
- a new
ExecutionResultfrom that map
-
transform
This helps you transform the currentExecutionResultobject 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
ExecutionResultobject based on calling build on that builder
-
newExecutionResult
- Returns:
- a builder that allows you to build a new execution result
-