Skip to content

ApolloFragment ​

Props ​

NameTypeDefaultDescription
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.
fragmentNamestring | undefined Name of the fragment to use, when the document declares more than one.
variablesTVariables | undefined Variables used when reading the fragment.
optimisticboolean | undefined Read from optimistic cache data.
clientIdstring | undefined Name of the client to use, from the provided ApolloClients map.
optionsuseFragment.Options<TData, TVariables> | undefined Escape hatch for any other useFragment option.

Events ​

NamePayload
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 propType
dataTData

#incomplete ​

Shown while fields are still missing from the cache. Opinionated mode only.

Slot propType
dataDeepPartial<TData>
missingMissingTree | 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>

Released under the MIT License.