Skip to content

Commit

Permalink
chore: adds changeset, reverts removal of comment
Browse files Browse the repository at this point in the history
  • Loading branch information
alessbell committed Jan 25, 2024
1 parent 8090a61 commit 13fa56e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/tasty-pillows-ring.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@apollo/client": minor
---

Add `watchFragment` method to the cache and expose it on ApolloClient, refactor `useFragment` using `watchFragment`.
5 changes: 4 additions & 1 deletion src/react/hooks/useFragment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ export function useFragment<TData = any, TVars = OperationVariables>(
const subscription = cache.watchFragment(options).subscribe({
next: (result) => {
resultRef.current = result;
// TODO: add comment back here
// If we get another update before we've re-rendered, bail out of
// the update and try again. This ensures that the relative timing
// between useQuery and useFragment stays roughly the same as
// fixed in https://github.com/apollographql/apollo-client/pull/11083
clearTimeout(lastTimeout);
lastTimeout = setTimeout(forceUpdate) as any;
},
Expand Down

0 comments on commit 13fa56e

Please sign in to comment.