Files
speckle-server/packages/dui3/plugins/apollo.ts
T
Kristaps Fabians Geikins 2eb5f51af3 feat: dui3 package (#1585)
2023-05-19 16:57:28 +03:00

35 lines
992 B
TypeScript

import { ApolloClient } from '@apollo/client/core'
import { ApolloClients } from '@vue/apollo-composable'
import { resolveClientConfig } from '~/lib/core/configs/apollo'
export default defineNuxtPlugin((nuxtApp) => {
/**
* TODO: You can use `window` here to get credentials for all of the clients
* we need from the parent connectors. The following is just an example
*/
const apolloClients = {
latest: new ApolloClient(
// Imagine endpoint & token is resolved from window or something
resolveClientConfig({
httpEndpoint: 'https://latest.speckle.systems/graphql',
authToken: () => null
})
),
xyz: new ApolloClient(
// Imagine endpoint & token is resolved from window or something
resolveClientConfig({
httpEndpoint: 'https://speckle.xyz/graphql',
authToken: () => null
})
)
}
nuxtApp.vueApp.provide(ApolloClients, apolloClients)
return {
provide: {
apolloClients
}
}
})