refactor source code
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { CategorySchema } from './category.schema';
|
||||
import { Module } from '@nestjs/common'
|
||||
import { CategorySchema } from './category.schema'
|
||||
|
||||
@Module({
|
||||
providers: [CategorySchema],
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { Inject, Injectable } from '@nestjs/common'
|
||||
import {
|
||||
Pothos,
|
||||
PothosRef,
|
||||
PothosSchema,
|
||||
SchemaBuilderToken,
|
||||
} from '@smatch-corp/nestjs-pothos';
|
||||
import { Builder } from '../Graphql/graphql.builder';
|
||||
import { PrismaService } from '../Prisma/prisma.service';
|
||||
} from '@smatch-corp/nestjs-pothos'
|
||||
import { Builder } from '../Graphql/graphql.builder'
|
||||
import { PrismaService } from '../Prisma/prisma.service'
|
||||
|
||||
@Injectable()
|
||||
export class CategorySchema extends PothosSchema {
|
||||
@@ -14,7 +14,7 @@ export class CategorySchema extends PothosSchema {
|
||||
@Inject(SchemaBuilderToken) private readonly builder: Builder,
|
||||
private readonly prisma: PrismaService,
|
||||
) {
|
||||
super();
|
||||
super()
|
||||
}
|
||||
|
||||
@PothosRef()
|
||||
@@ -32,7 +32,7 @@ export class CategorySchema extends PothosSchema {
|
||||
description: 'The subcategory of the category.',
|
||||
}),
|
||||
}),
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
@PothosRef()
|
||||
@@ -58,7 +58,7 @@ export class CategorySchema extends PothosSchema {
|
||||
'The service and category that the subcategory belongs to.',
|
||||
}),
|
||||
}),
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
@Pothos()
|
||||
@@ -76,7 +76,7 @@ export class CategorySchema extends PothosSchema {
|
||||
take: args.take ?? undefined,
|
||||
orderBy: args.orderBy ?? undefined,
|
||||
where: args.filter ?? undefined,
|
||||
});
|
||||
})
|
||||
},
|
||||
}),
|
||||
category: t.prismaField({
|
||||
@@ -87,7 +87,7 @@ export class CategorySchema extends PothosSchema {
|
||||
return await this.prisma.category.findUnique({
|
||||
...query,
|
||||
where: args.where ?? undefined,
|
||||
});
|
||||
})
|
||||
},
|
||||
}),
|
||||
subCategories: t.prismaField({
|
||||
@@ -102,10 +102,10 @@ export class CategorySchema extends PothosSchema {
|
||||
orderBy: args.orderBy ?? undefined,
|
||||
skip: args.skip ?? undefined,
|
||||
take: args.take ?? undefined,
|
||||
});
|
||||
})
|
||||
},
|
||||
}),
|
||||
}));
|
||||
}))
|
||||
|
||||
// mutation
|
||||
this.builder.mutationFields((t) => ({
|
||||
@@ -121,7 +121,7 @@ export class CategorySchema extends PothosSchema {
|
||||
resolve: async (query, root, args) => {
|
||||
return await this.prisma.category.create({
|
||||
data: args.input,
|
||||
});
|
||||
})
|
||||
},
|
||||
}),
|
||||
createManyCategories: t.prismaField({
|
||||
@@ -137,7 +137,7 @@ export class CategorySchema extends PothosSchema {
|
||||
return await this.prisma.category.createManyAndReturn({
|
||||
data: args.data,
|
||||
skipDuplicates: true,
|
||||
});
|
||||
})
|
||||
},
|
||||
}),
|
||||
|
||||
@@ -153,9 +153,9 @@ export class CategorySchema extends PothosSchema {
|
||||
resolve: async (query, root, args) => {
|
||||
return await this.prisma.subCategory.create({
|
||||
data: args.input,
|
||||
});
|
||||
})
|
||||
},
|
||||
}),
|
||||
}));
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user