public interface ResponseField
Modifier and Type | Method and Description |
---|---|
ResponseError |
getError()
Deprecated.
since 1.0.3 in favor of
getErrors() |
List<ResponseError> |
getErrors()
Return all errors that have a path, and it is at above, or below the field path.
|
List<Object> |
getParsedPath()
Return a parsed representation of the field path, in the format described
for error paths in Section 7.1.2, "Response Format" of the GraphQL spec.
|
String |
getPath()
Return a String representation of the field path as described in
ClientGraphQlResponse.field(String) . |
<T> T |
getValue()
Return the raw field value, e.g.
|
boolean |
hasValue()
Deprecated.
as of 1.0.3 in favor of checking via
getValue() |
@Deprecated boolean hasValue()
getValue()
"true"
means the field is not null
, and therefore valid,
although it may be partial with nested field errors
.
"false"
means the field is null
or doesn't exist; use
getErrors()
to check for field errors, and
GraphQlResponse.isValid()
to check if the entire response is
valid or not.
String getPath()
ClientGraphQlResponse.field(String)
.List<Object> getParsedPath()
ResponseError.getParsedPath()
@Nullable <T> T getValue()
T
- the expected value type to cast to@Nullable @Deprecated ResponseError getError()
getErrors()
When the field is null
, this method looks for the first field
error. According to the GraphQL spec, section 6.4.4, "Handling Field
Errors", there should be only one error per field. The returned field
error may be:
non-null
nested field error bubbles up
As a fallback, this method also checks "request errors" in case the
entire response is not valid
. If there
are no errors at all, null
is returned, and it implies the field
value was set to null
by its DataFetcher
.
When the field does have a value, it is considered
valid and this method returns null
, although the field may be
partial and contain errors
on nested fields.
null
if there is no
error with the same path as the field pathList<ResponseError> getErrors()
According to the GraphQL spec, section 6.4.4, "Handling Field Errors"
if a field has an error it is set to null
. That means a field
has either a value or an error, and there is only one error per field.
Errors may also occur at paths above or below the field path. Consider the following cases:
Value | Errors | Case |
---|---|---|
Non-null |
Empty | Success |
Non-null |
Errors below | Partial with errors on nested fields |
null |
Error at field | Field failure |
null |
Error above field | Parent field failure |
null |
Error below field | Nested field failure bubbles up because field is required |