Skip to content

Conversation

jerelmiller
Copy link
Member

@jerelmiller jerelmiller commented Oct 13, 2025

Add support for lists with useFragment, useSuspenseFragment, and client.watchFragment.

const result = useFragment({
  fragment,
  from: [item1, item2]
});

console.log(result); // { data: [{...}, {...}], dataState: "complete", complete: true }

@changeset-bot
Copy link

changeset-bot bot commented Oct 13, 2025

🦋 Changeset detected

Latest commit: 1d0e27c

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@apollo-librarian
Copy link

apollo-librarian bot commented Oct 13, 2025

✅ Docs preview ready

The preview is ready to be viewed. View the preview

File Changes

0 new, 10 changed, 0 removed
* (developer-tools)/react/(latest)/caching/cache-configuration.mdx
* (developer-tools)/react/(latest)/data/fragments.mdx
* (developer-tools)/react/(latest)/data/mutations.mdx
* (developer-tools)/react/(latest)/data/persisted-queries.mdx
* (developer-tools)/react/(latest)/data/queries.mdx
* (developer-tools)/react/(latest)/integrations/react-native.mdx
* (developer-tools)/react/(latest)/migrating/apollo-client-4-migration.mdx
* (developer-tools)/react/(latest)/performance/server-side-rendering.mdx
* (developer-tools)/react/(latest)/VERSIONING_POLICY.md
* (developer-tools)/react/(latest)/versioning-policy.md

Build ID: 8b14569e469e89d32b062239
Build Logs: View logs

URL: https://www.apollographql.com/docs/deploy-preview/8b14569e469e89d32b062239

@pkg-pr-new
Copy link

pkg-pr-new bot commented Oct 13, 2025

npm i https://pkg.pr.new/apollographql/apollo-client/@apollo/client@12971

commit: 1d0e27c

}) as Observable<any>;

return Object.assign(observable, {
getCurrentResult: () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we return something with a changeTargets property here? That way we wouldn't need to unwatch/rewatch 999 unrelated elements if one id changed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! I was planning to do that next 🙂.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is now implemented with reobserve which will only watch new ids and keep ids that haven't changed around 🙂

@jerelmiller jerelmiller changed the title [WIP] Add list support to useFragment Add list support to useFragment, useSuspenseFragment, and client.watchFragment Oct 18, 2025
@jerelmiller jerelmiller force-pushed the jerel/use-fragment-list branch from c427a20 to d4072da Compare October 21, 2025 01:23
@jerelmiller jerelmiller requested a review from a team as a code owner October 21, 2025 15:49
@jerelmiller jerelmiller force-pushed the jerel/use-fragment-list branch from f542b84 to 1d0e27c Compare October 21, 2025 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants