Skip to content

Commit

Permalink
fix(package/gqty): properly batch with microtask
Browse files Browse the repository at this point in the history
  • Loading branch information
vicary committed Feb 25, 2024
1 parent 2642c1f commit fb99004
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/gqty/src/Client/resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,8 @@ export const createResolvers = <TSchema extends BaseGeneratedSchema>({
if (!pendingQueries.has(pendingSelections)) {
pendingQueries.set(
pendingSelections,
(async () => {
// Batching happens at the end of microtask queue
Promise.resolve().then(async () => {
const uniqueSelections = new Set<Selection>();

getSelectionsSet(clientCache, selectionsCacheKey)?.forEach(
Expand Down Expand Up @@ -279,7 +280,7 @@ export const createResolvers = <TSchema extends BaseGeneratedSchema>({
);

return results;
})()
})
);
}

Expand Down

0 comments on commit fb99004

Please sign in to comment.