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 CategorySchema extends PothosSchema {
@PothosRef()
category() {
return this.builder.prismaObject('Category', {
description: 'A category of services.',
fields: (t) => ({
id: t.exposeID('id'),
name: t.exposeString('name'),
@@ -31,6 +32,7 @@ export class CategorySchema extends PothosSchema {
@PothosRef()
subCategory() {
return this.builder.prismaObject('SubCategory', {
description: 'A subcategory of services.',
fields: (t) => ({
id: t.exposeID('id'),
name: t.exposeString('name'),
@@ -45,6 +47,8 @@ export class CategorySchema extends PothosSchema {
init(): void {
this.builder.queryFields((t) => ({
categories: t.prismaField({
description:
'Retrieve a list of categories with optional filtering, ordering, and pagination.',
type: [this.category()],
args: this.builder.generator.findManyArgs('Category'),
resolve: async (query, root, args) => {
@@ -58,6 +62,7 @@ export class CategorySchema extends PothosSchema {
},
}),
category: t.prismaField({
description: 'Retrieve a single category by its unique identifier.',
type: this.category(),
args: this.builder.generator.findUniqueArgs('Category'),
resolve: async (query, root, args) => {
@@ -68,6 +73,8 @@ export class CategorySchema extends PothosSchema {
},
}),
subCategories: t.prismaField({
description:
'Retrieve a list of subcategories with optional filtering, ordering, and pagination.',
type: [this.subCategory()],
args: this.builder.generator.findManyArgs('SubCategory'),
resolve: async (query, root, args) => {
@@ -85,6 +92,7 @@ export class CategorySchema extends PothosSchema {
// mutation
this.builder.mutationFields((t) => ({
createCategory: t.prismaField({
description: 'Create a new category.',
type: this.category(),
args: {
input: t.arg({
@@ -99,6 +107,7 @@ export class CategorySchema extends PothosSchema {
},
}),
createManyCategories: t.prismaField({
description: 'Create multiple new categories.',
type: [this.category()],
args: {
data: t.arg({
@@ -115,6 +124,7 @@ export class CategorySchema extends PothosSchema {
}),
createSubCategory: t.prismaField({
description: 'Create a new subcategory.',
type: this.subCategory(),
args: {
input: t.arg({