ApolloFragment ​
Props ​
| Name | Type | Default | Description |
|---|---|---|---|
fragment (required) | DocumentNode | TypedDocumentNode<TData, TVariables> | Â | A GraphQL fragment document. |
from (required) | NonNullable<useFragment.FromValue<TData>> | Â | Cache identifiable entity to read the fragment from. Accepts a masked object from a parent query, a { __ref } reference, or a cache ID string. |
fragmentName | string | undefined | Â | Name of the fragment to use, when the document declares more than one. |
variables | TVariables | undefined | Â | Variables used when reading the fragment. |
optimistic | boolean | undefined | Â | Read from optimistic cache data. |
clientId | string | undefined | Â | Name of the client to use, from the provided ApolloClients map. |
options | useFragment.Options<TData, TVariables> | undefined | Â | Escape hatch for any other useFragment option. |
Events ​
| Name | Payload |
|---|---|
nextState | [state: RenameKey<RenameKey<ApolloCache.WatchFragmentResult<TData>, "dataState", "resultState">, "data", "result">] |
Slots ​
#data ​
Opinionated mode. Providing this slot selects it, and data has every field.
| Slot prop | Type |
|---|---|
data | TData |
#incomplete ​
Shown while fields are still missing from the cache. Opinionated mode only.
| Slot prop | Type |
|---|---|
data | DeepPartial<TData> |
missing | MissingTree | undefined |
#default ​
Raw mode. Receives the flattened fragment state.
Rendered in both modes, so nested children still mount.
Receives RenameKey<RenameKey<ApolloCache.WatchFragmentResult<TData>, "dataState", "resultState">, "data", "result">.
Exposed ​
A template ref receives the full useFragment.Result surface, with refs unwrapped.
vue
<template>
<ApolloFragment ref="apollo" ... />
</template>