+5
.changeset/beige-candles-kneel.md
+5
.changeset/beige-candles-kneel.md
···+A `useClientHandle()` function has been added. This creates a `handle` on which all `use*` hooks can be called, like `await handle.useQuery(...)` or `await handle.useSubscription(...)` which is useful for sequentially chaining hook calls in an `async setup()` function or preserve the right instance of a `Client` across lifecycle hooks.
+5
.changeset/fluffy-ligers-draw.md
+5
.changeset/fluffy-ligers-draw.md
+16
-2
docs/api/vue.md
+16
-2
docs/api/vue.md
···+`setup()` or another lifecycle hook, and returns a so called "client handle". Using this `handle` we+can access the [`Client`](./core.md#client) directly via the `client` property or call the other+`use*` functions as methods, which will be directly bound to this `client`. This may be useful when+| ---------------------- | ------------------------------------------------------------------------------------------------------------------------- |+| `client` | Contains the raw [`Client`](./core.md#client) reference, which allows the `Client` to be used directly. |+| `useQuery(...)` | Accepts the same arguments as the `useQuery` function, but will always use the `Client` from the handle's context. |+| `useMutation(...)` | Accepts the same arguments as the `useMutation` function, but will always use the `Client` from the handle's context. |+| `useSubscription(...)` | Accepts the same arguments as the `useSubscription` function, but will always use the `Client` from the handle's context. |In Vue the [`Client`](./core.md#client) is provided either to your app or to a parent component of agiven subtree and is then subsequently injected whenever one of the above composition functions is-You can manually retrieve the `Client` in your component by calling `useClient`. Symmetrically youAlternatively, `@urql/vue` also has a default export of a [Vue Plugin function](https://v3.vuejs.org/guide/plugins.html#using-a-plugin).
+46
docs/basics/vue.md
+46
docs/basics/vue.md
···suspends this component will switch to using its `#fallback` template rather than its `#default`+As shown [above](#vue-suspense), in Vue Suspense the `async setup()` lifecycle function can be used+to set up queries in advance, wait for them to have fetched some data, and then let the component+However, because the `async setup()` function can be used with `await`-ed promise calls, we may run+into situations where we're trying to call functions like `useQuery()` after we've already awaited+another promise and will be outside of the synchronous scope of the `setup()` lifecycle. This means+that the `useQuery` (and `useSubscription` & `useMutation`) functions won't have access to the+As we can see, when we use `handle.useQuery()` we're able to still create query results although we've+interrupted the synchronous `setup()` lifecycle with a `Promise.resolve()` delay. This would also+[`computed`](https://v3.vuejs.org/guide/reactivity-computed-watchers.html#computed-values) to use an
+1
-1
packages/vue-urql/example/package.json
+1
-1
packages/vue-urql/example/package.json
+1
-1
packages/vue-urql/example/src/App.vue
+1
-1
packages/vue-urql/example/src/App.vue
+44
-11
packages/vue-urql/example/src/components/HelloWorld.vue
+44
-11
packages/vue-urql/example/src/components/HelloWorld.vue
···
+67
-4
packages/vue-urql/example/yarn.lock
+67
-4
packages/vue-urql/example/yarn.lock
···+resolved "https://registry.yarnpkg.com/@graphql-typed-document-node/core/-/core-3.1.0.tgz#0eee6373e11418bfe0b5638f654df7a4ca6a3950"+integrity sha512-wYn6r8zVZyQJ6rQaALBEln5B1pzxb9shV5Ef97kTvn6yVGrqyXVnDqnU24MXnFubR+rZjBY9NWuxX3FB2sTsjg==resolved "https://registry.yarnpkg.com/@koa/cors/-/cors-3.1.0.tgz#618bb073438cfdbd3ebd0e648a76e33b84f3a3b2"···-resolved "https://registry.yarnpkg.com/@urql/core/-/core-1.13.1.tgz#7247c27dccd7570010de91730d1f16fd15892829"-integrity sha512-Zl4UwvcE9JbWKzrtxnlmfF+rkX50GzK5dpMlB6FnUYF0sLmuGMxp67lnhTQsfTNJ+41bkj4lk0PMWEnG7KUsTw==+resolved "https://registry.yarnpkg.com/@urql/core/-/core-2.0.0.tgz#b4936dd51fe84cb570506d9ee2579149689f7535"+integrity sha512-Qj24CG8ullqZZsYmjrSH0JhH+nY7kj8GbVbA9si3KUjlYs75A/MBQU3i97j6oWyGldDBapyis2CfaQeXKbv8rA==+resolved "https://registry.yarnpkg.com/@vue/compiler-core/-/compiler-core-3.0.11.tgz#5ef579e46d7b336b8735228758d1c2c505aae69a"+integrity sha512-6sFj6TBac1y2cWCvYCA8YzHJEbsVkX7zdRs/3yK/n1ilvRqcn983XvpBbnN3v4mZ1UiQycTvOiajJmOgN9EVgw==resolved "https://registry.yarnpkg.com/@vue/compiler-core/-/compiler-core-3.0.2.tgz#7790b7a1fcbba5ace4d81a70ce59096fa5c95734"···+resolved "https://registry.yarnpkg.com/@vue/compiler-dom/-/compiler-dom-3.0.11.tgz#b15fc1c909371fd671746020ba55b5dab4a730ee"+integrity sha512-+3xB50uGeY5Fv9eMKVJs2WSRULfgwaTJsy23OIltKgMrynnIj8hTYY2UL97HCoz78aDw1VDXdrBQ4qepWjnQcw==···+resolved "https://registry.yarnpkg.com/@vue/reactivity/-/reactivity-3.0.11.tgz#07b588349fd05626b17f3500cbef7d4bdb4dbd0b"+integrity sha512-SKM3YKxtXHBPMf7yufXeBhCZ4XZDKP9/iXeQSC8bBO3ivBuzAi4aZi0bNoeE2IF2iGfP/AHEt1OU4ARj4ao/Xw==resolved "https://registry.yarnpkg.com/@vue/reactivity/-/reactivity-3.0.2.tgz#42ed5af6025b494a5e69b05169fcddf04eebfe77"integrity sha512-GdRloNcBar4yqWGXOcba1t//j/WizwfthfPUYkjcIPHjYnA/vTEQYp0C9+ZjPdinv1WRK1BSMeN/xj31kQES4A==+resolved "https://registry.yarnpkg.com/@vue/runtime-core/-/runtime-core-3.0.11.tgz#c52dfc6acf3215493623552c1c2919080c562e44"+integrity sha512-87XPNwHfz9JkmOlayBeCCfMh9PT2NBnv795DSbi//C/RaAnc/bGZgECjmkD7oXJ526BZbgk9QZBPdFT8KMxkAg==···+resolved "https://registry.yarnpkg.com/@vue/runtime-dom/-/runtime-dom-3.0.11.tgz#7a552df21907942721feb6961c418e222a699337"+integrity sha512-jm3FVQESY3y2hKZ2wlkcmFDDyqaPyU3p1IdAX92zTNeCH7I8zZ37PtlE1b9NlCtzV53WjB4TZAYh9yDCMIEumA==resolved "https://registry.yarnpkg.com/@vue/runtime-dom/-/runtime-dom-3.0.2.tgz#9d166d03225558025d3d80f5039b646e0051b71c"···+resolved "https://registry.yarnpkg.com/@vue/shared/-/shared-3.0.11.tgz#20d22dd0da7d358bb21c17f9bde8628152642c77"+integrity sha512-b+zB8A2so8eCE0JsxjL24J7vdGl8rzPQ09hZNhystm+KqSbKcAej1A+Hbva1rCMmTTqA+hFnUSDc5kouEo0JzA==···+resolved "https://registry.yarnpkg.com/vue/-/vue-3.0.11.tgz#c82f9594cbf4dcc869241d4c8dd3e08d9a8f4b5f"+integrity sha512-3/eUi4InQz8MPzruHYSTQPxtM3LdZ1/S/BvaU021zBnZi0laRUyH6pfuE4wtUeLvI8wmUNwj5wrZFvbHUXL9dw==
+1
-1
packages/vue-urql/package.json
+1
-1
packages/vue-urql/package.json
+26
-4
packages/vue-urql/src/index.ts
+26
-4
packages/vue-urql/src/index.ts
···
+7
-1
packages/vue-urql/src/useClient.ts
+7
-1
packages/vue-urql/src/useClient.ts
······
+104
packages/vue-urql/src/useClientHandle.ts
+104
packages/vue-urql/src/useClientHandle.ts
···
+5
-8
packages/vue-urql/src/useMutation.test.ts
+5
-8
packages/vue-urql/src/useMutation.test.ts
···
+9
-1
packages/vue-urql/src/useMutation.ts
+9
-1
packages/vue-urql/src/useMutation.ts
······
+5
-9
packages/vue-urql/src/useQuery.test.ts
+5
-9
packages/vue-urql/src/useQuery.test.ts
···
+76
-59
packages/vue-urql/src/useQuery.ts
+76
-59
packages/vue-urql/src/useQuery.ts
···············
+5
-8
packages/vue-urql/src/useSubscription.test.ts
+5
-8
packages/vue-urql/src/useSubscription.test.ts
···
+69
-50
packages/vue-urql/src/useSubscription.ts
+69
-50
packages/vue-urql/src/useSubscription.ts
············
+1
-1
yarn.lock
+1
-1
yarn.lock
···resolved "https://registry.yarnpkg.com/vm-browserify/-/vm-browserify-1.1.2.tgz#78641c488b8e6ca91a75f511e7a3b32a86e5dda0"integrity sha512-2ham8XPWTONajOR0ohOKOHXkm3+gaBmGut3SRuu75xLd/RRaY6vqgh8NBYYk7+RW3u5AtzPQZG8F10LHkl0lAQ==resolved "https://registry.yarnpkg.com/vue/-/vue-3.0.11.tgz#c82f9594cbf4dcc869241d4c8dd3e08d9a8f4b5f"