public interface GraphQlResponse
Modifier and Type | Method and Description |
---|---|
ResponseField |
field(String path)
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.
|
<T> T |
getData()
Return the data part of the response, or
null when the response
is not valid . |
List<ResponseError> |
getErrors()
Return errors included in the response.
|
Map<Object,Object> |
getExtensions()
Return implementor specific, protocol extensions, if any.
|
boolean |
isValid()
Whether the response is valid.
|
Map<String,Object> |
toMap()
Return a map representation of the response, formatted as required in the
"Response" section of the GraphQL spec.
|
boolean isValid()
response map
has no "data" entry indicating
errors before execution, e.g. grammar parse and validation
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 to null
due to
field errors.
For more details, see section 7 "Response" in the GraphQL spec.
@Nullable <T> T getData()
null
when the response
is not valid
.T
- a map or a listList<ResponseError> getErrors()
A response that is not valid
contains "request
errors". Those are errors that apply to the request as a whole, and have
an empty error path
.
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.
ResponseField field(String path)
Example paths:
"hero" "hero.name" "hero.friends" "hero.friends[2]" "hero.friends[2].name"
path
- relative to the "data" keyResponseField.hasValue()
to check if
the field actually exists and has a value.Map<Object,Object> getExtensions()