Skip to content

Commit

Permalink
[PLA-1612] Fix external id empty (#134)
Browse files Browse the repository at this point in the history
  • Loading branch information
enjinabner authored Feb 15, 2024
1 parent a3e80f8 commit e46a0ff
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ public function args(): array
*/
public function resolve($root, array $args, $context, ResolveInfo $resolveInfo, Closure $getSelectFields, TransactionService $transactionService): mixed
{
$transactions = Transaction::where('state', '=', TransactionState::PENDING->name)
$transactions = Transaction::loadSelectFields($resolveInfo, $this->name)
->where('state', '=', TransactionState::PENDING->name)
->when(
$args['accounts'] ?? false,
function (Builder $query) use ($args) {
Expand All @@ -84,8 +85,12 @@ function (Builder $query) {
)->cursorPaginateWithTotal('id', $args['first'], false);

if (true === $args['markAsProcessing'] || null === $args['markAsProcessing']) {
$transactionsToMark = clone $transactions['items']->getCollection();
$transactionsToMark->each(fn ($transaction) => $transactionService->update($transaction, ['state' => TransactionState::PROCESSING->name]));
$transactions['items']->getCollection()->each(
fn ($transaction) => $transactionService->update(
clone $transaction,
['state' => TransactionState::PROCESSING->name]
)
);
}

return $transactions;
Expand Down
3 changes: 2 additions & 1 deletion src/Models/Laravel/Traits/EagerLoadSelectFields.php
Original file line number Diff line number Diff line change
Expand Up @@ -398,9 +398,10 @@ public static function selectFields(ResolveInfo $resolveInfo, string $query): ar
break;
case 'GetTransaction':
case 'GetTransactions':
case 'MarkAndListPendingTransactions':
[$select, $with, $withCount] = static::loadTransaction(
$queryPlan,
$query == 'GetTransactions' ? 'edges.fields.node.fields' : '',
in_array($query, ['GetTransactions', 'MarkAndListPendingTransactions']) ? 'edges.fields.node.fields' : '',
[],
null,
true
Expand Down

0 comments on commit e46a0ff

Please sign in to comment.