Skip to content

@vue/apollo-composable / useQuery / ReactiveVariablesParameter

Type Alias: ReactiveVariablesParameter ​

ReactiveVariablesParameter = MaybeRefOrGetter<OperationVariables> | Record<string, MaybeRefOrGetter<any>>

Type for the variables option parameter: either a ref/getter of the full variables object, or an object mapping individual variable names to refs/getters.

Example ​

ts
// Single ref/getter for all variables
const variables = reactive({ id: 1 })
useQuery(query, { variables })

// Object mapping individual variable names to refs/getters
const id = ref(1)
useQuery(query, { variables: { id } })

// With props or any reactive values
const { id } = defineProps<{ id: number }>()
useQuery(query, { variables: () => ({ id }) })

Released under the MIT License.