Skip to content

Commit

Permalink
[smart-subscriptions] handle subscribe method being async
Browse files Browse the repository at this point in the history
  • Loading branch information
hayes committed Oct 23, 2024
1 parent 69024a6 commit 71a722a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/slow-kings-stare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@pothos/plugin-smart-subscriptions": patch
---

Handle async subsdcribe methods
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ export default function resolveWithCache<Types extends SchemaTypes>(
function cacheResult(result: unknown) {
const cacheNode = cache.add(info, key, canRefetch, result);

subscribe?.(cacheNode.managerForField(), parent, args, context, info);
const sub = subscribe?.(cacheNode.managerForField(), parent, args, context, info);

if (isThenable(sub)) {
return sub.then(() => result);
}

return result;
}
Expand Down

0 comments on commit 71a722a

Please sign in to comment.