github logaretm/villus v1.2.0

latest releases: v3.5.1, v3.5.0, v3.4.0...
2 years ago

🆕 New Features

  • Added skip option to useQuery which prevents executing queries if it is evaluated to true.
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 to useQuery.
const route = useRoute();

const { data, isFetching } = useQuery({
  variables: () => {
    return { id: route.params.id };
  },
});

Don't miss a new villus release

NewReleases is sending notifications on new releases.