-
Notifications
You must be signed in to change notification settings - Fork 1
feat(core): add useApolloClients composable for managing multiple Apollo clients
#37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
e9f944a
1fb5a53
35c7421
72da2d6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -94,14 +94,14 @@ const { error, loading, result } = useQuery(GET_POSTS) | |||||
|
|
||||||
| ## 🧠 Composables Overview | ||||||
|
|
||||||
| | Composable | Description | | ||||||
| |-------------|--------------| | ||||||
| | `useQuery` | Reactive GraphQL query | | ||||||
| | `useLazyQuery` | Run query on demand | | ||||||
| | `useMutation` | Execute GraphQL mutations | | ||||||
| | `useSubscription` | Subscribe to GraphQL streams | | ||||||
| | `useApolloClient` | Access current Apollo client | | ||||||
| | `provideApolloClients` / `useApolloClients` | Manage multiple clients | | ||||||
| | Composable | Description | | ||||||
| |--------------------|------------------------------------------------| | ||||||
| | `useQuery` | Reactive GraphQL query | | ||||||
| | `useMutation` | Execute GraphQL mutations | | ||||||
| | `useSubscription` | Subscribe to GraphQL streams | | ||||||
| | `useFragment` | Retrieve and manage normalized cache fragments | | ||||||
| | `useApolloClient` | Access current Apollo client | | ||||||
| | `useApolloClients` | Access Apollo clients | | ||||||
|
||||||
| | `useApolloClients` | Access Apollo clients | | |
| | `useApolloClients` | Access all Apollo clients | |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| import { inject } from 'vue' | ||
|
|
||
| import { APOLLO_CLIENTS_KEY } from '../constants/apollo' | ||
|
|
||
| /** | ||
| * Get all Apollo client instances | ||
| * | ||
| * @returns Object containing all registered Apollo clients | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * // Get all clients | ||
| * const clients = useApolloClients() | ||
| * | ||
| * // Access specific client | ||
| * const defaultClient = clients.default | ||
| * const analyticsClient = clients.analytics | ||
| * | ||
| * // Iterate over all clients | ||
| * Object.entries(clients).forEach(([id, client]) => { | ||
| * console.log(`Client ${id}:`, client) | ||
| * }) | ||
| * ``` | ||
| */ | ||
| export function useApolloClients() { | ||
|
||
| const apolloClients = inject(APOLLO_CLIENTS_KEY) | ||
|
|
||
| if (!apolloClients) { | ||
| throw new Error( | ||
| '[useApolloClients] Apollo clients registry not found. Did you forget to install ApolloPlugin?' | ||
| ) | ||
| } | ||
|
|
||
| return apolloClients | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The table removed
useLazyQuerywhich was present in the original version. If this composable still exists in the codebase, it should remain in the documentation table.