Skip to content

feat:(vue): Optional injection key to allow multiple clients#3858

Merged
JoviDeCroock merged 2 commits intourql-graphql:mainfrom
albertcito:feat/vue-allow-many-clients-options-by-key
Apr 1, 2026
Merged

feat:(vue): Optional injection key to allow multiple clients#3858
JoviDeCroock merged 2 commits intourql-graphql:mainfrom
albertcito:feat/vue-allow-many-clients-options-by-key

Conversation

@albertcito
Copy link
Copy Markdown
Contributor

@albertcito albertcito commented Mar 16, 2026

Summary

Previously, @urql/vue exposed a single client via Vue’s provide/inject under a fixed key, so apps could not cleanly use multiple urql clients (e.g., different GraphQL services) in the same app. This change adds optional custom injection keys so you can provide and consume several clients under different keys while keeping the default key '$urql' for existing usage.

Set of changes

  • Package: @urql/vue (minor).
  • packages/vue-urql/src/useClient.ts
    • Exported DEFAULT_KEY ('$urql').
    • provideClient(opts, key?), install(app, opts, key?), and useClient(key?) now accept an optional key (default DEFAULT_KEY). Provide and inject use this key so multiple clients can coexist.
  • packages/vue-urql/src/useClientHandle.ts
    • useClientHandle(key?) now accepts an optional key (default DEFAULT_KEY), and uses useClient(key) internally so handles can target a specific client.
  • Tests: packages/vue-urql/src/useClient.test.ts — added test “provides client with custom key to current component instance” that provides two clients (default and custom key) and asserts both are resolvable via useClient() and useClient(customKey).
  • Docs: .changeset/some-bushes-smash.md describes the feature; docs/api/vue.md and docs/basics/vue.md may need follow-up to document the optional key and multi-client usage (not verified in this PR).

Resolves #3857

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 16, 2026

🦋 Changeset detected

Latest commit: 0525c19

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 Minor

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

@albertcito albertcito changed the title Feat: Optional injection key to allow multiple clients (Vue) fix(vue): Optional injection key to allow multiple clients Mar 16, 2026
@albertcito albertcito changed the title fix(vue): Optional injection key to allow multiple clients feat:(vue): Optional injection key to allow multiple clients Mar 17, 2026
@JoviDeCroock JoviDeCroock merged commit 773cae7 into urql-graphql:main Apr 1, 2026
12 checks passed
@github-actions github-actions bot mentioned this pull request Apr 1, 2026
@albertcito albertcito deleted the feat/vue-allow-many-clients-options-by-key branch April 1, 2026 19:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RFC: Allow multiple graphql schema in Nuxt

2 participants