Merge multiple queries into a single query like relay

Does Apollo Client have future plans to merge multiple queries / fragments into a single query like relay? Or is there a tool out there that can do this? I know about the batch link, but that isn’t the same as merging queries into one. Thanks in advance!

Hi! We’re actually working on a useFragment hook for the 3.5 release. There isn’t anything formal written up yet, but you can see some of the thinking here: Feature: useFragment hook · Issue #8236 · apollographql/apollo-client · GitHub

1 Like

Thanks for the quick reply!

Was this functionality actually added along with useQuery? It’s very difficult to tell reading the docs, as the Example doesn’t specify what the useQuery looks like after migrating from interpolated fragments to useFragment, and the Best Practices still recommend multiple queries instead of one single query.

Hello,
Apollo Client doesn’t have immediate plans to merge multiple queries or fragments into a single query similar to Relay’s approach. While the batch link can group requests, it doesn’t consolidate them into one query.