chore: refactor a lot, add codegen and upgrade vue

This commit is contained in:
2022-08-03 18:40:05 +02:00
parent 0e1ce42af2
commit e24b65c85b
42 changed files with 3854 additions and 1073 deletions
+10 -10
View File
@@ -1,7 +1,9 @@
import { ApolloClient, InMemoryCache, createHttpLink } from '@apollo/client/core'
import {
ApolloClient,
InMemoryCache,
createHttpLink
} from '@apollo/client/core'
import { setContext } from '@apollo/client/link/context'
import { provide } from '@vue/composition-api'
import { DefaultApolloClient } from '@vue/apollo-composable'
import { useAuth } from './auth'
const apiUrl = process.env.graphqlApi || '/query'
@@ -12,12 +14,12 @@ const httpLink = createHttpLink({
uri: apiUrl
})
const getToken = async (options) => {
const getToken = (options) => {
const { getTokenSilently } = useAuth()
return getTokenSilently.value(options)
return getTokenSilently(options)
}
const authLink = setContext(async (_, { headers }) => {
const authLink = setContext((_, { headers }) => {
return getToken().then((token) => ({
headers: {
...headers,
@@ -42,8 +44,6 @@ const instance = new ApolloClient({
}
})
export default function ({ app }) {
app.setup = () => {
provide(DefaultApolloClient, instance)
}
export default function (_, inject) {
inject('apollo', instance)
}