me keep
This commit is contained in:
@@ -55,5 +55,38 @@ export class CategorySchema extends PothosSchema {
|
||||
},
|
||||
}),
|
||||
}));
|
||||
|
||||
// mutation
|
||||
this.builder.mutationFields((t) => ({
|
||||
createCategory: t.prismaField({
|
||||
type: this.category(),
|
||||
args: {
|
||||
input: t.arg({
|
||||
type: this.builder.generator.getCreateInput('Category'),
|
||||
required: true,
|
||||
}),
|
||||
},
|
||||
resolve: async (query, root, args, ctx, info) => {
|
||||
return await this.prisma.category.create({
|
||||
data: args.input,
|
||||
});
|
||||
},
|
||||
}),
|
||||
createManyCategories: t.prismaField({
|
||||
type: [this.category()],
|
||||
args: {
|
||||
data: t.arg({
|
||||
type: [this.builder.generator.getCreateManyInput('Category')],
|
||||
required: true,
|
||||
}),
|
||||
},
|
||||
resolve: async (query, root, args, ctx, info) => {
|
||||
return await this.prisma.category.createManyAndReturn({
|
||||
data: args.data,
|
||||
skipDuplicates: true,
|
||||
});
|
||||
},
|
||||
}),
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ import * as Prisma from '@prisma/client';
|
||||
import { SchemaBuilderToken } from '@smatch-corp/nestjs-pothos';
|
||||
|
||||
//
|
||||
const filterOps = ['equals', 'in', 'notIn', 'not', 'is', 'isNot'] as const;
|
||||
const filterOps = ['equals', 'in', 'notIn', 'not', 'is'] as const;
|
||||
const sortableFilterProps = ['lt', 'lte', 'gt', 'gte'] as const;
|
||||
const stringFilterOps = [
|
||||
...filterOps,
|
||||
@@ -31,7 +31,7 @@ const scalarListOps = [
|
||||
'isEmpty',
|
||||
'equals',
|
||||
] as const;
|
||||
const JsonFilterOps = ['equals', 'in', 'notIn', 'not', 'is', 'isNot'] as const;
|
||||
const JsonFilterOps = ['equals', 'in', 'notIn', 'not', 'is'] as const;
|
||||
const EnumFilterOps = ['equals', 'not'] as const;
|
||||
|
||||
@Injectable()
|
||||
@@ -564,6 +564,13 @@ export class PrismaCrudGenerator<Types extends SchemaTypes> {
|
||||
if (sortableTypes.includes(type as never)) {
|
||||
ops.push(...sortableFilterProps);
|
||||
}
|
||||
if (type === 'Json') {
|
||||
ops.push(...JsonFilterOps);
|
||||
}
|
||||
// type enum
|
||||
if (type === 'Enum') {
|
||||
ops.push(...EnumFilterOps);
|
||||
}
|
||||
|
||||
return this.builder.prismaFilter(type, {
|
||||
ops,
|
||||
|
||||
Reference in New Issue
Block a user