Class DefaultExecutionGraphQlResponse
java.lang.Object
org.springframework.graphql.support.AbstractGraphQlResponse
org.springframework.graphql.support.DefaultExecutionGraphQlResponse
- All Implemented Interfaces:
ExecutionGraphQlResponse
,GraphQlResponse
- Direct Known Subclasses:
RSocketGraphQlResponse
,WebGraphQlResponse
public class DefaultExecutionGraphQlResponse
extends AbstractGraphQlResponse
implements ExecutionGraphQlResponse
GraphQlResponse
for server use that wraps the ExecutionResult
returned from GraphQL
and also exposes the actual
ExecutionInput
instance passed into it.- Since:
- 1.0.0
- Author:
- Rossen Stoyanchev
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
DefaultExecutionGraphQlResponse.Builder<B extends DefaultExecutionGraphQlResponse.Builder<B,
R>, R extends ExecutionGraphQlResponse> Builder to transform the response'sExecutionResult
. -
Constructor Summary
ModifierConstructorDescriptionDefaultExecutionGraphQlResponse
(ExecutionInput input, ExecutionResult result) Constructor to create initial instance.protected
Constructor to re-wrap from transport specific subclass. -
Method Summary
Modifier and TypeMethodDescription<T> T
getData()
Return the data part of the response, ornull
when the response is notvalid
.Return errors included in the response.Return theExecutionInput
that was prepared through theExecutionGraphQlRequest
and passed toGraphQL
.Return theExecutionResult
that was returned from the invocation toGraphQL
.Return implementor specific, protocol extensions, if any.boolean
isValid()
Whether the response is valid.toMap()
Return a map representation of the response, formatted as required in the "Response" section of the GraphQL spec.toString()
Methods inherited from class org.springframework.graphql.support.AbstractGraphQlResponse
field
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.springframework.graphql.GraphQlResponse
field
-
Constructor Details
-
DefaultExecutionGraphQlResponse
Constructor to create initial instance.- Parameters:
input
- the execution input for this graphql operationresult
- the execution result for this graphql operation
-
DefaultExecutionGraphQlResponse
Constructor to re-wrap from transport specific subclass.- Parameters:
response
- the execution response
-
-
Method Details
-
getExecutionInput
Description copied from interface:ExecutionGraphQlResponse
Return theExecutionInput
that was prepared through theExecutionGraphQlRequest
and passed toGraphQL
.- Specified by:
getExecutionInput
in interfaceExecutionGraphQlResponse
-
getExecutionResult
Description copied from interface:ExecutionGraphQlResponse
Return theExecutionResult
that was returned from the invocation toGraphQL
.- Specified by:
getExecutionResult
in interfaceExecutionGraphQlResponse
-
isValid
public boolean isValid()Description copied from interface:GraphQlResponse
Whether the response is valid. A response is invalid in one of the following two cases:- the
response map
has no "data" entry indicating errors before execution, e.g. grammar parse and validation - the "data" entry has a
null
value indicating errors during execution that prevented a valid response
A valid response has a "data" key with a
non-null
value, but it may still be partial and have some fields set tonull
due to field errors.For more details, see section 7 "Response" in the GraphQL spec.
- Specified by:
isValid
in interfaceGraphQlResponse
- the
-
getData
Description copied from interface:GraphQlResponse
Return the data part of the response, ornull
when the response is notvalid
.- Specified by:
getData
in interfaceGraphQlResponse
- Type Parameters:
T
- a map or a list
-
getErrors
Description copied from interface:GraphQlResponse
Return errors included in the response.A response that is not
valid
contains "request errors". Those are errors that apply to the request as a whole, and have an empty errorpath
.A response that is valid may still be partial and contain "field errors". Those are errors associated with a specific field through their error path.
- Specified by:
getErrors
in interfaceGraphQlResponse
-
getExtensions
Description copied from interface:GraphQlResponse
Return implementor specific, protocol extensions, if any.- Specified by:
getExtensions
in interfaceGraphQlResponse
-
toMap
Description copied from interface:GraphQlResponse
Return a map representation of the response, formatted as required in the "Response" section of the GraphQL spec.- Specified by:
toMap
in interfaceGraphQlResponse
-
toString
-