push code push code

This commit is contained in:
2024-10-17 15:02:25 +07:00
parent 053fb38273
commit 59923b02cb
18 changed files with 106 additions and 0 deletions

View File

@@ -20,6 +20,7 @@ export class CenterSchema extends PothosSchema {
@PothosRef()
center() {
return this.builder.prismaObject('Center', {
description: 'A center in the system.',
fields: (t) => ({
id: t.exposeID('id'),
centerOwnerId: t.exposeID('centerOwnerId'),
@@ -45,6 +46,8 @@ export class CenterSchema extends PothosSchema {
init(): void {
this.builder.queryFields((t) => ({
centers: t.prismaField({
description:
'Retrieve a list of centers with optional filtering, ordering, and pagination.',
type: [this.center()],
args: this.builder.generator.findManyArgs('Center'),
resolve: async (query, root, args, ctx, info) => {
@@ -59,6 +62,7 @@ export class CenterSchema extends PothosSchema {
}),
center: t.prismaField({
type: this.center(),
description: 'Retrieve a single center by its unique identifier.',
args: this.builder.generator.findUniqueArgs('Center'),
resolve: async (query, root, args, ctx, info) => {
return await this.prisma.center.findUnique({
@@ -70,6 +74,7 @@ export class CenterSchema extends PothosSchema {
// get current center of centerstaff by providing userId
centerByCenterStaff: t.prismaField({
type: this.center(),
description: 'Retrieve a single center by its unique identifier.',
args: {
userId: t.arg({ type: 'String', required: true }),
},
@@ -90,6 +95,7 @@ export class CenterSchema extends PothosSchema {
// mutation section
this.builder.mutationFields((t) => ({
createCenter: t.prismaField({
description: 'Create a new center.',
type: this.center(),
args: {
input: t.arg({
@@ -106,6 +112,7 @@ export class CenterSchema extends PothosSchema {
}),
updateCenter: t.prismaField({
type: this.center(),
description: 'Update an existing center.',
args: {
input: t.arg({
type: this.builder.generator.getUpdateInput('Center'),
@@ -126,6 +133,7 @@ export class CenterSchema extends PothosSchema {
}),
deleteCenter: t.prismaField({
type: this.center(),
description: 'Delete an existing center.',
args: {
where: t.arg({
type: this.builder.generator.getWhereUnique('Center'),