Skip to content

Commit

Permalink
chore: FilterTotalCount should be resolver is now deferred to optimiz…
Browse files Browse the repository at this point in the history
…e call flow - in the best case this saves an entire call to the search index.
  • Loading branch information
das-peter committed Aug 23, 2024
1 parent 1737eda commit d0dcde1
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/GraphQL/Resolver/QueryType.php
Original file line number Diff line number Diff line change
Expand Up @@ -1047,7 +1047,13 @@ public function resolveFilter($value = null, $args = [], $context = [], ResolveI
*/
public function resolveFilterTotalCount($value = null, $args = [], $context = [], ResolveInfo $resolveInfo = null)
{
return $value['totalCount']();
// Run this deferred because it is very likely that the edges are
// resolved "later" which means at this point the totalCount resolved
// will be able to re-use the results loaded by them. This can save a
// complete call to the search index.
return new Deferred(function () use ($value) {
return $value['totalCount']();
});
}

/**
Expand Down

0 comments on commit d0dcde1

Please sign in to comment.