Fix token not being refreshed (#1975)
* Fix token not being refreshed * Fix token not being refreshed * v2 * Fix
This commit is contained in:
@ -5,13 +5,13 @@ module.exports = {
|
|||||||
client: {
|
client: {
|
||||||
overlay: {
|
overlay: {
|
||||||
runtimeErrors: (error) => {
|
runtimeErrors: (error) => {
|
||||||
if (error.message === "ResizeObserver loop limit exceeded") {
|
switch (error.message) {
|
||||||
return false;
|
case "ResizeObserver loop limit exceeded":
|
||||||
|
case "Unauthenticated":
|
||||||
|
return false;
|
||||||
|
default:
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
if (error.message === "Unauthorized") {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@ -71,7 +71,7 @@ export class ApolloFactory<TCacheShape> implements ApolloManager<TCacheShape> {
|
|||||||
|
|
||||||
const retryLink = new RetryLink({
|
const retryLink = new RetryLink({
|
||||||
delay: {
|
delay: {
|
||||||
initial: 100,
|
initial: 3000,
|
||||||
},
|
},
|
||||||
attempts: {
|
attempts: {
|
||||||
max: 2,
|
max: 2,
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { Module } from '@nestjs/common';
|
import { Module } from '@nestjs/common';
|
||||||
import { GraphQLModule } from '@nestjs/graphql';
|
import { GraphQLModule } from '@nestjs/graphql';
|
||||||
import { ConfigModule } from '@nestjs/config';
|
import { ConfigModule } from '@nestjs/config';
|
||||||
import { ModuleRef } from '@nestjs/core';
|
import { APP_FILTER, ModuleRef } from '@nestjs/core';
|
||||||
|
|
||||||
import { YogaDriver, YogaDriverConfig } from '@graphql-yoga/nestjs';
|
import { YogaDriver, YogaDriverConfig } from '@graphql-yoga/nestjs';
|
||||||
import GraphQLJSON from 'graphql-type-json';
|
import GraphQLJSON from 'graphql-type-json';
|
||||||
@ -23,6 +23,7 @@ import {
|
|||||||
JwtPayload,
|
JwtPayload,
|
||||||
} from './core/auth/strategies/jwt.auth.strategy';
|
} from './core/auth/strategies/jwt.auth.strategy';
|
||||||
import { TenantService } from './tenant/tenant.service';
|
import { TenantService } from './tenant/tenant.service';
|
||||||
|
import { ExceptionFilter } from './filters/exception.filter';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
@ -107,7 +108,13 @@ import { TenantService } from './tenant/tenant.service';
|
|||||||
CoreModule,
|
CoreModule,
|
||||||
TenantModule,
|
TenantModule,
|
||||||
],
|
],
|
||||||
providers: [AppService],
|
providers: [
|
||||||
|
AppService,
|
||||||
|
{
|
||||||
|
provide: APP_FILTER,
|
||||||
|
useClass: ExceptionFilter,
|
||||||
|
},
|
||||||
|
],
|
||||||
})
|
})
|
||||||
export class AppModule {
|
export class AppModule {
|
||||||
static moduleRef: ModuleRef;
|
static moduleRef: ModuleRef;
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { Catch, HttpException } from '@nestjs/common';
|
import { Catch, UnauthorizedException } from '@nestjs/common';
|
||||||
import { GqlExceptionFilter } from '@nestjs/graphql';
|
import { GqlExceptionFilter } from '@nestjs/graphql';
|
||||||
|
|
||||||
import { Prisma } from '@prisma/client';
|
import { Prisma } from '@prisma/client';
|
||||||
@ -6,7 +6,7 @@ import { GraphQLError } from 'graphql';
|
|||||||
|
|
||||||
@Catch()
|
@Catch()
|
||||||
export class ExceptionFilter implements GqlExceptionFilter {
|
export class ExceptionFilter implements GqlExceptionFilter {
|
||||||
catch(exception: HttpException) {
|
catch(exception: Error) {
|
||||||
if (exception instanceof Prisma.PrismaClientValidationError) {
|
if (exception instanceof Prisma.PrismaClientValidationError) {
|
||||||
throw new GraphQLError('Invalid request', {
|
throw new GraphQLError('Invalid request', {
|
||||||
extensions: {
|
extensions: {
|
||||||
@ -14,6 +14,14 @@ export class ExceptionFilter implements GqlExceptionFilter {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if (exception instanceof UnauthorizedException) {
|
||||||
|
throw new GraphQLError('Unauthorized', {
|
||||||
|
extensions: {
|
||||||
|
code: 'UNAUTHENTICATED',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return exception;
|
return exception;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user