Skip to content

@vue/apollo-composable / useApolloClient

Function: useApolloClient() ​

useApolloClient(clientId?): Result

Composable to access ApolloClient instances.

Must be provided using DefaultApolloClient or ApolloClients. Alternatively, can be used inside a provideApolloClient or provideApolloClients context.

Parameters ​

clientId? ​

string

Client ID to resolve. Defaults to the default client.

Returns ​

Result

Object with client property.

Example ​

ts
// Get the default client
const { client } = useApolloClient()

// Get a named client
const { client } = useApolloClient('analytics')

Released under the MIT License.