fix: fix table columns update (#1435)

Closes #1434
This commit is contained in:
Thaïs 2023-09-05 09:50:53 +02:00 committed by GitHub
parent 421066c4b8
commit d866c0e3bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -15,12 +15,17 @@ import { relationAbilityChecker } from 'src/ability/ability.util';
import { ViewFieldWhereInput } from 'src/core/@generated/view-field/view-field-where.input';
import { PrismaService } from 'src/database/prisma.service';
import { assert } from 'src/utils/assert';
import { ViewFieldWhereUniqueInput } from 'src/core/@generated/view-field/view-field-where-unique.input';
class ViewFieldArgs {
where?: ViewFieldWhereInput;
[key: string]: any;
}
const isViewFieldWhereUniqueInput = (
input: ViewFieldWhereInput | ViewFieldWhereUniqueInput,
): input is ViewFieldWhereUniqueInput => 'viewId_key' in input;
@Injectable()
export class ReadViewFieldAbilityHandler implements IAbilityHandler {
handle(ability: AppAbility) {
@ -59,7 +64,10 @@ export class UpdateViewFieldAbilityHandler implements IAbilityHandler {
const gqlContext = GqlExecutionContext.create(context);
const args = gqlContext.getArgs<ViewFieldArgs>();
const viewField = await this.prismaService.client.viewField.findFirst({
where: args.where,
where:
args.where && isViewFieldWhereUniqueInput(args.where)
? args.where.viewId_key
: args.where,
});
assert(viewField, '', NotFoundException);