Package org.springframework.graphql
Interface GraphQlResponse
- All Known Subinterfaces:
ClientGraphQlResponse,ExecutionGraphQlResponse
- All Known Implementing Classes:
AbstractGraphQlResponse,DefaultExecutionGraphQlResponse,RSocketGraphQlResponse,WebGraphQlResponse
public interface GraphQlResponse
Represents a GraphQL response with the result of executing a request operation.
- Since:
- 1.0.0
- Author:
- Rossen Stoyanchev
-
Method Summary
Modifier and TypeMethodDescriptionNavigate to the given path under the "data" key of the response map where the path is a dot-separated string with optional array indexes.<T> TgetData()Return the data part of the response, ornullwhen the response is notvalid.Return errors included in the response.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.
-
Method Details
-
isValid
boolean isValid()Whether 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.
- the
-
getData
Return the data part of the response, ornullwhen the response is notvalid.- Type Parameters:
T- a map or a list
-
getErrors
List<ResponseError> getErrors()Return 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.
-
field
Navigate to the given path under the "data" key of the response map where the path is a dot-separated string with optional array indexes.Example paths:
"hero" "hero.name" "hero.friends" "hero.friends[2]" "hero.friends[2].name"
- Parameters:
path- relative to the "data" key- Returns:
- representation for the field with further options to inspect or
decode its value; use
ResponseField.getValue()to check if the field actually has a value.
-
getExtensions
Return implementor specific, protocol extensions, if any. -
toMap
Return a map representation of the response, formatted as required in the "Response" section of the GraphQL spec.
-