Skip to content

Commit

Permalink
fix(useApolloClient): add id arg to resolveClient
Browse files Browse the repository at this point in the history
  • Loading branch information
Akryum committed Oct 15, 2020
1 parent 22baef5 commit 72d7402
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions packages/vue-apollo-composable/src/useApolloClient.ts
Expand Up @@ -4,14 +4,14 @@ import ApolloClient from 'apollo-client'
export const DefaultApolloClient = Symbol('default-apollo-client')
export const ApolloClients = Symbol('apollo-clients')

type ClientId = string
type ClientDict<T> = Record<ClientId, ApolloClient<T>>

export interface UseApolloClientReturn<TCacheShape> {
resolveClient: (clientId?: string) => ApolloClient<TCacheShape>
resolveClient: (clientId?: ClientId) => ApolloClient<TCacheShape>
readonly client: ApolloClient<TCacheShape>
}

type ClientId = string
type ClientDict<T> = Record<ClientId, ApolloClient<T>>

function resolveDefaultClient<T>(providedApolloClients: ClientDict<T>, providedApolloClient: ApolloClient<T>): ApolloClient<T> {
const resolvedClient = providedApolloClients ?
providedApolloClients.default
Expand All @@ -37,8 +37,8 @@ export function useApolloClient<TCacheShape = any>(clientId?: ClientId): UseApol
const providedApolloClients: ClientDict<TCacheShape> = inject(ApolloClients, null)
const providedApolloClient: ApolloClient<TCacheShape> = inject(DefaultApolloClient, null)

function resolveClient() {
if (clientId) {
function resolveClient(id: ClientId = clientId) {
if (id) {
return resolveClientWithId(providedApolloClients, clientId)
}
return resolveDefaultClient(providedApolloClients, providedApolloClient)
Expand Down

0 comments on commit 72d7402

Please sign in to comment.