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

fix(vue): Fix regression causing `pause` argument to not be reactive #3595

Closed arkandias closed 1 month ago

arkandias commented 1 month ago

Summary

Solves https://github.com/urql-graphql/urql/issues/3594#issue-2316403034

Set of changes

This is just a quick fix for getting isPaused reactive, but there might be some issues with the reactivity of other parameters.

changeset-bot[bot] commented 1 month ago

🦋 Changeset detected

Latest commit: dbbfa3747faff0835fb4eef924e76d01fd94c9d7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package | Name | Type | | --------- | ----- | | @urql/vue | Patch |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

kitten commented 1 month ago

Hiya :wave: We'll need a patch changeset here to merge this, i.e. a changelog entry, e.g.

Fix regression causing pause argument on useQuery and useSubscription to not be reactive

I tried to quickly push one but push access for maintainers may not be enabled on your PR. You can read more about this here though ❤️ https://github.com/urql-graphql/urql/blob/main/CONTRIBUTING.md#how-do-i-document-a-change-for-the-changelog

negezor commented 1 month ago

The type MaybeRef<T> = T | (() => T) | Ref<T>; is specified to support getters.

This is not working as it should at the moment:

const skip = ref(0);

const pokemons = await useQuery({
  query: gql`
    query ($skip: Int!) {
      pokemons(limit: 10, skip: $skip) {
        id
        name
      }
    }
  `,
  variables: { skip },
  pause: () => {
    return skip.value > 1000 || skip.value === -1
  },
});

Of course this can be solved using manual toRef() or computed(). But maybe we can replace it with toRef() by default? The only thing is that it will require vue 3.3+

arkandias commented 1 month ago

Hi @negezor, I'm working on it. I'll make a PR very soon (with some other minor updates).