mirror of
https://github.com/twentyhq/twenty.git
synced 2025-01-03 01:34:08 +03:00
parent
421066c4b8
commit
d866c0e3bc
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user