Skip to content

Commit

Permalink
perf: improve count and ids query (#144)
Browse files Browse the repository at this point in the history
  • Loading branch information
erikgaal authored May 13, 2021
1 parent 8f97f81 commit 690e0d3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Types/EntityType.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,9 @@ protected function getPluralRelationFields(string $key, EloquentField $field): C
->resolve(function (Model $model, string $accessor, Arguments $args) use ($field) {
$relation = $field->getRelation($model);

$result = $args->isEmpty() ? $field->getResult($model) : $this->getRelationQuery($relation, $args)->get();
$query = $args->isEmpty() ? $relation : $this->getRelationQuery($relation, $args);

return $result->pluck($relation->getRelated()->getKeyName());
return $query->pluck($relation->getRelated()->getKeyName());
})
);

Expand All @@ -156,9 +156,9 @@ protected function getPluralRelationFields(string $key, EloquentField $field): C
->resolve(function (Model $model, string $accessor, Arguments $args) use ($field) {
$relation = $field->getRelation($model);

$result = $args->isEmpty() ? $field->getResult($model) : $this->getRelationQuery($relation, $args)->get();
$query = $args->isEmpty() ? $relation : $this->getRelationQuery($relation, $args);

return $result->count();
return $query->count();
})
);

Expand Down

0 comments on commit 690e0d3

Please sign in to comment.