Skip to content

Commit 5c9a005

Browse files
committed
add support for collections in executor
1 parent 91384be commit 5c9a005

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/Execution/Executor.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -445,10 +445,13 @@ private function completeListValue(ExecutionContext $executionContext, GraphQLLi
445445
}
446446

447447
$itemType = $returnType->getInnerType();
448-
return array_map(function ($item, $index) use ($executionContext, $returnType, $fieldNodes, $info, $path, $result, $itemType) {
448+
449+
// iterate over all entries in the list and complete the values
450+
$completedListValue = [];
451+
foreach ($result as $index => $item) {
449452
$itemPath = [$index, null, $path];
450453
try {
451-
return $this->completeValue(
454+
$completedListValue[] = $this->completeValue(
452455
$executionContext,
453456
$itemType,
454457
$fieldNodes,
@@ -458,9 +461,12 @@ private function completeListValue(ExecutionContext $executionContext, GraphQLLi
458461
);
459462
} catch (GraphQLError $error) {
460463
$error = LocatedError::from($error, $fieldNodes, $path);
461-
return $this->handleFieldError($error, $returnType, $executionContext);
464+
$completedListValue[] = $this->handleFieldError($error, $returnType, $executionContext);
462465
}
463-
}, $result, array_keys($result));
466+
}
467+
468+
// return the completed list
469+
return $completedListValue;
464470
}
465471

466472
private function completeLeafValue(GraphQLType $returnType, $result)

0 commit comments

Comments
 (0)