uppdate workshop mutation
This commit is contained in:
@@ -42,4 +42,74 @@ export class WorkshopSchema extends PothosSchema {
|
|||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Pothos()
|
||||||
|
init(): void {
|
||||||
|
this.builder.queryFields((t) => ({
|
||||||
|
workshop: t.prismaField({
|
||||||
|
type: this.workshop(),
|
||||||
|
args: this.builder.generator.findUniqueArgs('Workshop'),
|
||||||
|
resolve: async (query, root, args, ctx, info) => {
|
||||||
|
return await this.prisma.workshop.findUnique({
|
||||||
|
...query,
|
||||||
|
where: args.where,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
|
||||||
|
workshops: t.prismaField({
|
||||||
|
type: [this.workshop()],
|
||||||
|
args: this.builder.generator.findManyArgs('Workshop'),
|
||||||
|
resolve: async (query, root, args, ctx, info) => {
|
||||||
|
return await this.prisma.workshop.findMany({
|
||||||
|
...query,
|
||||||
|
skip: args.skip ?? 0,
|
||||||
|
take: args.take ?? 10,
|
||||||
|
orderBy: args.orderBy ?? undefined,
|
||||||
|
where: args.filter ?? undefined,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
}));
|
||||||
|
|
||||||
|
// Mutations section
|
||||||
|
this.builder.mutationFields((t) => ({
|
||||||
|
createWorkshop: t.prismaField({
|
||||||
|
type: this.workshop(),
|
||||||
|
args: {
|
||||||
|
input: t.arg({
|
||||||
|
type: this.builder.generator.getCreateInput('Workshop'),
|
||||||
|
required: true,
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
resolve: async (query, root, args, ctx, info) => {
|
||||||
|
return await this.prisma.workshop.create({
|
||||||
|
...query,
|
||||||
|
data: args.input,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
|
||||||
|
updateWorkshop: t.prismaField({
|
||||||
|
type: this.workshop(),
|
||||||
|
args: {
|
||||||
|
input: t.arg({
|
||||||
|
type: this.builder.generator.getUpdateInput('Workshop'),
|
||||||
|
required: true,
|
||||||
|
}),
|
||||||
|
where: t.arg({
|
||||||
|
type: this.builder.generator.getWhereUnique('Workshop'),
|
||||||
|
required: true,
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
resolve: async (query, root, args, ctx, info) => {
|
||||||
|
return await this.prisma.workshop.update({
|
||||||
|
...query,
|
||||||
|
where: args.where,
|
||||||
|
data: args.input,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
}));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user