Skip to content

Commit 0d14faf

Browse files
committed
fix(delegate): handle leftovers async in the correct place
1 parent f6c1457 commit 0d14faf

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

.changeset/two-pugs-punch.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@graphql-tools/delegate': patch
3+
---
4+
5+
Fix leftover handling 2nd take

packages/delegate/src/defaultMergedResolver.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,7 @@ export function defaultMergedResolver(
101101
} else {
102102
// not all fields are present, we need to resolve more leftovers
103103
// this can occur when there are circular @requires, see requires-circular audit test
104-
setTimeout(() => {
105-
handleLeftOver(parent, context, info, leftOver);
106-
}, 0);
104+
handleLeftOver(parent, context, info, leftOver);
107105
}
108106
return deferred.promise;
109107
}
@@ -420,7 +418,9 @@ function handleDeferredResolverResult<TContext extends Record<string, any>>(
420418
})
421419
) {
422420
// requirements are satisfied, trigger handleLeftOver to fetch this field
423-
handleLeftOver(leftOverParent, context, info, leftOver);
421+
setTimeout(() => {
422+
handleLeftOver(leftOverParent, context, info, leftOver);
423+
}, 0);
424424
}
425425
}
426426
}

0 commit comments

Comments
 (0)