- my ($resp) = @_;
-
- if (eval { $resp->isa('Future') }) {
- return $resp->followed_by(sub {
- my $f = shift;
- if (my ($exception, $category, @details) = $f->failure) {
- if (!$exception->{errors}) {
- return Future->fail($exception, $category, @details);
- }
- if ($self->unpack) {
- return Future->fail($ERROR_MESSAGE, 'graphql', $exception, @details);
- }
- return Future->done($exception);
- }
- else {
- my ($resp, @other) = $f->get;
- if ($self->unpack) {
- if ($resp->{errors}) {
- return Future->fail($ERROR_MESSAGE, 'graphql', $resp, @other);
- }
- return Future->done($resp->{data});
- }
- return Future->done($resp);
- }
- });
- }
- else {
+ my ($result) = @_;
+
+ my $handle_result = sub {
+ my $result = shift;
+ my $resp = $result->{response};
+ if (my $exception = $result->{error}) {
+ unshift @{$resp->{errors}}, {
+ message => "$exception",
+ };
+ }