Skip to content

Commit

Permalink
fix(datastore): List errors that are returned from AppSync (#2801)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattcreaser authored May 3, 2024
1 parent 2438647 commit 8927058
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import java.util.List;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;

import io.reactivex.rxjava3.core.Completable;
import io.reactivex.rxjava3.core.Flowable;
Expand Down Expand Up @@ -320,8 +321,13 @@ private <T extends Model> Single<GraphQLResponse<PaginatedResult<ModelWithMetada
return Single.create(emitter -> {
Cancelable cancelable = appSync.sync(request, result -> {
if (!result.hasData()) {
List<String> errorStrings = result.getErrors().stream()
.map(GraphQLResponse.Error::toString)
.collect(Collectors.toList());
String errors = String.join(",\n", errorStrings);

emitter.onError(new DataStoreException.IrRecoverableException(
"Empty response from AppSync.", "Report to AWS team."
"Received errors from AppSync: " + errors, "Report to AWS team."
));
} else {
if (result.hasErrors()) {
Expand Down

0 comments on commit 8927058

Please sign in to comment.