Two minor fixes on be (#168)

This commit is contained in:
Charles Bochet
2023-05-31 18:33:26 +02:00
committed by GitHub
parent 723ea462e8
commit e3402cc753
6 changed files with 185 additions and 140 deletions

View File

@ -0,0 +1,37 @@
import { Field } from '@nestjs/graphql';
import { InputType } from '@nestjs/graphql';
import { UserCreateWithoutCommentsInput } from './user-create-without-comments.input';
import { Type } from 'class-transformer';
import { UserCreateOrConnectWithoutCommentsInput } from './user-create-or-connect-without-comments.input';
import { UserUpsertWithoutCommentsInput } from './user-upsert-without-comments.input';
import { UserWhereUniqueInput } from './user-where-unique.input';
import { UserUpdateWithoutCommentsInput } from './user-update-without-comments.input';
@InputType()
export class UserUpdateOneWithoutCommentsNestedInput {
@Field(() => UserCreateWithoutCommentsInput, { nullable: true })
@Type(() => UserCreateWithoutCommentsInput)
create?: UserCreateWithoutCommentsInput;
@Field(() => UserCreateOrConnectWithoutCommentsInput, { nullable: true })
@Type(() => UserCreateOrConnectWithoutCommentsInput)
connectOrCreate?: UserCreateOrConnectWithoutCommentsInput;
@Field(() => UserUpsertWithoutCommentsInput, { nullable: true })
@Type(() => UserUpsertWithoutCommentsInput)
upsert?: UserUpsertWithoutCommentsInput;
@Field(() => Boolean, { nullable: true })
disconnect?: boolean;
@Field(() => Boolean, { nullable: true })
delete?: boolean;
@Field(() => UserWhereUniqueInput, { nullable: true })
@Type(() => UserWhereUniqueInput)
connect?: UserWhereUniqueInput;
@Field(() => UserUpdateWithoutCommentsInput, { nullable: true })
@Type(() => UserUpdateWithoutCommentsInput)
update?: UserUpdateWithoutCommentsInput;
}

View File

@ -12,6 +12,7 @@ import { DeleteManyCompanyArgs } from '../@generated/company/delete-many-company
import { Workspace } from '@prisma/client';
import { ArgsService } from './services/args.service';
import { CheckWorkspaceOwnership } from 'src/auth/guards/check-workspace-ownership.guard';
import { Prisma } from '@prisma/client';
@UseGuards(JwtAuthGuard, CheckWorkspaceOwnership)
@Resolver(() => Company)
@ -43,9 +44,10 @@ export class CompanyResolver {
if (!args.data.accountOwner?.connect?.id) {
args.data.accountOwner = { disconnect: true };
}
return this.prismaService.company.update({
...args,
});
} satisfies UpdateOneCompanyArgs as Prisma.CompanyUpdateArgs);
}
@Mutation(() => AffectedRows, {

View File

@ -52,7 +52,7 @@ export class CreateOneCommentThreadGuard implements CanActivate {
where: { id: target.commentableId },
});
if (targetEntity.workspaceId !== workspaceId) {
if (!targetEntity || targetEntity.workspaceId !== workspaceId) {
throw new HttpException(
{ reason: 'CommentThreadTarget not found' },
HttpStatus.NOT_FOUND,

View File

@ -12,6 +12,7 @@ import { Workspace } from '../@generated/workspace/workspace.model';
import { AuthWorkspace } from './decorators/auth-workspace.decorator';
import { ArgsService } from './services/args.service';
import { CheckWorkspaceOwnership } from 'src/auth/guards/check-workspace-ownership.guard';
import { Prisma } from '@prisma/client';
@UseGuards(JwtAuthGuard, CheckWorkspaceOwnership)
@Resolver(() => Person)
@ -50,7 +51,7 @@ export class PersonResolver {
return this.prismaService.person.update({
...args,
});
} satisfies UpdateOnePersonArgs as Prisma.PersonUpdateArgs);
}
@Mutation(() => AffectedRows, {