public final class GraphQLResponse<T>
- Object
- GraphQLResponse
Result of a GraphQL query or mutation. Mirrors the shape of
Response and
GrpcResponse so call sites feel familiar,
but reflects a GraphQL-specific reality: a single response can
carry both mapped data and a non-empty errors array (a
partial result). Always check hasErrors() in addition to
getData().
getResponseCode() returns the underlying HTTP status (usually
200, since GraphQL surfaces logical failures in the body rather
than via HTTP status). 0 is used for transport-level failures
that never reached an HTTP response.
Constructors
public GraphQLResponse(int httpCode, T data, List<GraphQLError> errors, String responseErrorMessage) |
Methods
public T getData() | The mapped data payload, or null when the server returned no data (a fatal error, or an empty/transport-failed response). |
public List<GraphQLError> getErrors() | The errors array, never null (empty when the call succeeded cleanly). |
public boolean hasErrors() | true when the response carried at least one GraphQL error. |
public int getResponseCode() | The underlying HTTP status code. |
public boolean isOk() | true iff the response carried no GraphQL errors. |
public String getResponseErrorMessage() | The first error message (a transport-failure description when the call never reached the server), or null on clean success. |
Inherited methods
Constructor details
GraphQLResponse
public GraphQLResponse(int httpCode, T data, List<GraphQLError> errors, String responseErrorMessage)Method details
getData
public T getData()The mapped
data payload, or null when the server returned no
data (a fatal error, or an empty/transport-failed response).getErrors
public List<GraphQLError> getErrors()The
errors array, never null (empty when the call succeeded
cleanly).hasErrors
public boolean hasErrors()true when the response carried at least one GraphQL error.getResponseCode
public int getResponseCode()The underlying HTTP status code.
0 signals a transport-level
failure (network error, unparseable body) that never produced
an HTTP response.isOk
public boolean isOk()true iff the response carried no GraphQL errors. Note this is
independent of getData() being non-null – a valid response
to a nullable root field can be error-free with null data.getResponseErrorMessage
public String getResponseErrorMessage()The first error message (a transport-failure description when
the call never reached the server), or null on clean success.