Query

The Query component uses scoped slots to provide the query state to the slot template.

tip

The Query component is renderless by default, meaning it will not render any extra HTML other than its slot.

Props

The Query component accepts the following props:

PropTypeRequiredDescription
querystring or DocumentNodeYesThe query to be executed
variablesobjectNoThe query variables
cachePolicyA string with those possible values cache-and-network or network-only or cache-firstNoThe cache policy to execute the query with, defaults to the value configured with the provided client
fetchOnMountbooleanNoIf the query should be be executed on onMounted lifecycle hook, default is true
suspendedbooleanNoIf the component is suspended with Suspend or not, defaults to false
watchVariablesbooleanNoIf the query variable watching is disabled or not, defaults to true

Slot Props

The Query component exposes a single default slot with the following properties:

PropertyTypeDescription
dataany/nullThe GraphQL query result's data
errorCombinedErrorAny errors encountered during query execution
execute({cachePolicy: CachePolicy}) => Promise<OperationResult<TData>>Executes the query and returns the operation result containing data and error values
isDonebooleanSet to true when the query is executed at least once, never resets to false
isFetchingbooleanSet to true when the query is executing either by calling execute explicitly or by watch effect due to reactive variables or queries

Events

The Query component does not emit any events at the moment