From dbd1e6fe2cad04a4625486b07c7b242a7f52fac2 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Fri, 18 Jun 2021 18:42:54 +0200 Subject: [PATCH] Don't show 401 graphQL errors Signed-off-by: Thomas Citharel --- js/src/vue-apollo.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/js/src/vue-apollo.ts b/js/src/vue-apollo.ts index b1dd2e8de..6ae0ee0a6 100644 --- a/js/src/vue-apollo.ts +++ b/js/src/vue-apollo.ts @@ -26,6 +26,7 @@ import { typePolicies, refreshAccessToken, } from "./apollo/utils"; +import { GraphQLError } from "graphql"; // Install the vue plugin Vue.use(VueApollo); @@ -120,10 +121,14 @@ const errorLink = onError( } if (graphQLErrors) { - graphQLErrors.map(({ message, locations, path }) => - console.log( - `[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}` - ) + graphQLErrors.map( + (graphQLError: GraphQLError & { status_code?: number }) => { + if (graphQLError?.status_code !== 401) { + console.log( + `[GraphQL error]: Message: ${graphQLError.message}, Location: ${graphQLError.locations}, Path: ${graphQLError.path}` + ); + } + } ); }