fix: deprecation warnings
This commit is contained in:
+11
-12
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user