Skip to content
Snippets Groups Projects
Commit 3bd0dfbe authored by Adam Parák's avatar Adam Parák 💬 Committed by Marek Veselý
Browse files

fix authlink error, hopefully it wont break anything

parent 61459b00
No related branches found
No related tags found
No related merge requests found
import { ApolloLink } from '@apollo/client' import { ApolloLink } from '@apollo/client'
import { onError } from '@apollo/client/link/error'
const debounced = (fn: (msg: string) => void, delay: number) => { const debounced = (fn: (msg: string) => void, delay: number) => {
let timeout: NodeJS.Timeout let timeout: NodeJS.Timeout
...@@ -13,15 +14,14 @@ const debounced = (fn: (msg: string) => void, delay: number) => { ...@@ -13,15 +14,14 @@ const debounced = (fn: (msg: string) => void, delay: number) => {
const authLink = (onFailedAuth: (msg: string) => void) => const authLink = (onFailedAuth: (msg: string) => void) =>
import.meta.env.VITE_NOAUTH === 'true' import.meta.env.VITE_NOAUTH === 'true'
? new ApolloLink((operation, forward) => forward(operation)) ? new ApolloLink((operation, forward) => forward(operation))
: new ApolloLink((operation, forward) => : onError(({graphQLErrors}) => {
forward(operation).map(data => { if (graphQLErrors) {
data.errors?.forEach(error => { graphQLErrors.forEach(error => {
if (error.message === 'Authentication failed') { if (error.message === 'Authentication failed') {
debounced(onFailedAuth, 1000)('Authentication failed') debounced(onFailedAuth, 1000)('Authentication failed')
} }
})
return data
}) })
) }
})
export default authLink export default authLink
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment