@vue/apollo-composable / useFragment
Function: useFragment() ​
useFragment(
options):Result
A composable for reading fragment data from the Apollo cache with full reactivity.
Watches fragment data and automatically updates when the cache changes. Supports both single entities and arrays of entities.
Note
This only works for data that can be identified by the cache via cache.identify(). Entities must have a unique cache ID (typically __typename + id).
Parameters ​
options ​
Configuration options for the fragment.
Returns ​
Fragment result object with reactive refs.
Example ​
ts
const { current } = useFragment({
fragment: gql`fragment UserFields on User { id name }`,
from: { __typename: 'User', id: '1' },
})