Skip to content

apollo-composable "enabled/disable" query, not working #1422

Closed
@tcastelly

Description

@tcastelly

Describe the bug
I would want to launch a query using the "enabled" property in the useQuery

const periodSelected = ref<string>();

const { result } = useQuery(REPORT, () => ({}), () => ({
  fetchPolicy: 'no-cache',
  enabled: !!periodSelected.value,
}));

By default the result of !!periodSelected.value is false. But the query is launched.

If I try to use a static false

const { result } = useQuery(REPORT, () => ({}), () => ({
  fetchPolicy: 'no-cache',
  enabled: false,
}));

It works.

Versions
vue: 3.2.41
vue-apollo: 3.1.0
@apollo/client: 3.7.1

Additional context
I've tried with computed options:

const { result } = useQuery(REPORT, () => ({}), computed(() => ({
  fetchPolicy: 'no-cache',
  enabled: !!periodSelected.value,
})));

Not working.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions