use of com.apollographql.apollo.internal.response.RealResponseReader in project apollo-android by apollographql.
the class OperationResponseParser method parse.
@SuppressWarnings("unchecked")
public Response<W> parse(@Nonnull Map<String, Object> payload) {
checkNotNull(payload, "payload == null");
D data = null;
if (payload.containsKey("data")) {
Map<String, Object> buffer = (Map<String, Object>) payload.get("data");
RealResponseReader<Map<String, Object>> realResponseReader = new RealResponseReader<>(operation.variables(), buffer, new MapFieldValueResolver(), scalarTypeAdapters, responseNormalizer);
data = (D) responseFieldMapper.map(realResponseReader);
}
List<Error> errors = null;
if (payload.containsKey("errors")) {
List<Map<String, Object>> errorPayloads = (List<Map<String, Object>>) payload.get("errors");
if (errorPayloads != null) {
errors = new ArrayList<>();
for (Map<String, Object> errorPayload : errorPayloads) {
errors.add(readError(errorPayload));
}
}
}
return Response.<W>builder(operation).data(operation.wrapData(data)).errors(errors).dependentKeys(responseNormalizer.dependentKeys()).build();
}
Aggregations