Optimize metadata queries (#7013)
In this PR: 1. Refactor guards to avoid duplicated queries: WorkspaceAuthGuard and UserAuthGuard only check for existence of workspace and user in the request without querying the database
This commit is contained in:
committed by
Charles Bochet
parent
cf8b1161cc
commit
523df5398a
@ -15,7 +15,7 @@ export class BeforeCreateOneObject<T extends CreateObjectInput>
|
||||
instance: CreateOneInputType<T>,
|
||||
context: any,
|
||||
): Promise<CreateOneInputType<T>> {
|
||||
const workspaceId = context?.req?.user?.workspace?.id;
|
||||
const workspaceId = context?.req?.workspace?.id;
|
||||
|
||||
if (!workspaceId) {
|
||||
throw new UnauthorizedException();
|
||||
|
||||
@ -19,7 +19,7 @@ export class BeforeDeleteOneObject implements BeforeDeleteOneHook {
|
||||
instance: DeleteOneInputType,
|
||||
context: any,
|
||||
): Promise<DeleteOneInputType> {
|
||||
const workspaceId = context?.req?.user?.workspace?.id;
|
||||
const workspaceId = context?.req?.workspace?.id;
|
||||
|
||||
if (!workspaceId) {
|
||||
throw new UnauthorizedException();
|
||||
|
||||
Reference in New Issue
Block a user