fix: deprecation warnings

This commit is contained in:
2022-08-17 08:42:25 +02:00
parent 2813ccc11f
commit d735a93a35
5 changed files with 24 additions and 25 deletions
+11 -12
View File
@@ -1,8 +1,4 @@
import {
ApolloClient,
InMemoryCache,
createHttpLink
} from '@apollo/client/core'
import { ApolloClient, createHttpLink, InMemoryCache } from '@apollo/client/core'
import { setContext } from '@apollo/client/link/context'
import { useAuth } from './auth'
@@ -20,12 +16,15 @@ const getToken = (options) => {
}
const authLink = setContext((_, { headers }) => {
return getToken().then((token) => ({
headers: {
...headers,
authorization: token ? `Bearer ${token}` : ''
}
}))
return getToken()
.then((token) => ({
headers: {
...headers,
authorization: token ? `Bearer ${token}` : ''
}
})).catch(() => {
return {}
})
})
const link = authLink.concat(httpLink)
@@ -44,6 +43,6 @@ const instance = new ApolloClient({
}
})
export default function (_, inject) {
export default function(_, inject) {
inject('apollo', instance)
}