urql-graphql / urql

The highly customizable and versatile GraphQL client with which you add on features like normalized caching as you grow.
https://urql.dev/goto/docs
MIT License
8.54k stars 444 forks source link

(vue) useQuery pause does not update when passing a ref #3594

Closed arkandias closed 1 month ago

arkandias commented 1 month ago

Describe the bug

According to the doc, we can pass a reactive pause input to useQuery. Yet, the pause status of the query does not update when the reference's value changes. I have linked a StackBlitz with the following example from the doc:

const skip = ref(0);
    const shouldPause = ref(true);

    const pokemons = await useQuery({
      query: gql`
        query ($skip: Int!) {
          pokemons(limit: 10, skip: $skip) {
            id
            name
          }
        }
      `,
      variables: { skip },
      pause: shouldPause,
    });

You can see that the query stays on pause (it does not fetch and the property isPaused is indeed staying to true) even when shouldPause's value is switched to false. On the other hand, if you start with const shouldPause = ref(true);, then the query never pauses.

Reproduction

https://stackblitz.com/edit/github-uroxw1?file=src%2FPokemonList.vue

Urql version

@urql/vue: 1.2.0

Validations

JoviDeCroock commented 1 month ago

Hmm, that is correct we might need to change that... Currently we return a pause/resume function and only use args.pause as the initial value.

JoviDeCroock commented 1 month ago

Fixed in #3595