🆕 New Features
- Added
skip
option touseQuery
which prevents executing queries if it is evaluated totrue
.
const route = useRoute();
// skip fetching if route param `id` does not exist
const shouldSkip = computed(() => {
return !route.params.id
});
const { data, isFetching } = useQuery({
// pass as ref ...
skip: shouldSkip,
});
// pass as a function, which rescives the current variables as an argument
const { data, isFetching } = useQuery({
// ...,
skip: (variables) => {
return !variables.id;
},
});
useQuery
variables
option can now be a function that returns a variables object. This is mainly a DX improvement to avoid having to create computed properties to pass touseQuery
.
const route = useRoute();
const { data, isFetching } = useQuery({
variables: () => {
return { id: route.params.id };
},
});