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
Nested ClassesModifier and TypeClassDescriptionstatic classDefaultExecutionGraphQlResponse.Builder<B extends DefaultExecutionGraphQlResponse.Builder<B,R>, R extends ExecutionGraphQlResponse> Builder to transform the response'sExecutionResult. -
Constructor Summary
ConstructorsModifierConstructorDescriptionDefaultExecutionGraphQlResponse(ExecutionInput input, ExecutionResult result) Constructor to create initial instance.protectedConstructor to re-wrap from transport specific subclass. -
Method Summary
Modifier and TypeMethodDescription<T> TgetData()Return the data part of the response, ornullwhen the response is notvalid.Return errors included in the response.Return theExecutionInputthat was prepared through theExecutionGraphQlRequestand passed toGraphQL.Return theExecutionResultthat was returned from the invocation toGraphQL.Return implementor specific, protocol extensions, if any.booleanisValid()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
fieldMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.springframework.graphql.GraphQlResponse
field
-
Constructor Details
-
DefaultExecutionGraphQlResponse
Constructor to create initial instance. -
DefaultExecutionGraphQlResponse
Constructor to re-wrap from transport specific subclass.
-
-
Method Details
-
getExecutionInput
Description copied from interface:ExecutionGraphQlResponseReturn theExecutionInputthat was prepared through theExecutionGraphQlRequestand passed toGraphQL.- Specified by:
getExecutionInputin interfaceExecutionGraphQlResponse
-
getExecutionResult
Description copied from interface:ExecutionGraphQlResponseReturn theExecutionResultthat was returned from the invocation toGraphQL.- Specified by:
getExecutionResultin interfaceExecutionGraphQlResponse
-
isValid
public boolean isValid()Description copied from interface:GraphQlResponseWhether the response is valid. A response is invalid in one of the following two cases:- the
response maphas no "data" entry indicating errors before execution, e.g. grammar parse and validation - the "data" entry has a
nullvalue indicating errors during execution that prevented a valid response
A valid response has a "data" key with a
non-nullvalue, but it may still be partial and have some fields set tonulldue to field errors.For more details, see section 7 "Response" in the GraphQL spec.
- Specified by:
isValidin interfaceGraphQlResponse
- the
-
getData
Description copied from interface:GraphQlResponseReturn the data part of the response, ornullwhen the response is notvalid.- Specified by:
getDatain interfaceGraphQlResponse- Type Parameters:
T- a map or a list
-
getErrors
Description copied from interface:GraphQlResponseReturn errors included in the response.A response that is not
validcontains "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:
getErrorsin interfaceGraphQlResponse
-
getExtensions
Description copied from interface:GraphQlResponseReturn implementor specific, protocol extensions, if any.- Specified by:
getExtensionsin interfaceGraphQlResponse
-
toMap
Description copied from interface:GraphQlResponseReturn a map representation of the response, formatted as required in the "Response" section of the GraphQL spec.- Specified by:
toMapin interfaceGraphQlResponse
-
toString
-