update many graphql field
This commit is contained in:
9
src/Category/category.module.ts
Normal file
9
src/Category/category.module.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import { Global, Module } from '@nestjs/common';
|
||||
import { CategorySchema } from './category.schema';
|
||||
|
||||
@Global()
|
||||
@Module({
|
||||
providers: [CategorySchema],
|
||||
exports: [CategorySchema],
|
||||
})
|
||||
export class CategoryModule {}
|
||||
59
src/Category/category.schema.ts
Normal file
59
src/Category/category.schema.ts
Normal file
@@ -0,0 +1,59 @@
|
||||
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';
|
||||
|
||||
@Injectable()
|
||||
export class CategorySchema extends PothosSchema {
|
||||
constructor(
|
||||
@Inject(SchemaBuilderToken) private readonly builder: Builder,
|
||||
private readonly prisma: PrismaService,
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
||||
@PothosRef()
|
||||
category() {
|
||||
return this.builder.prismaObject('Category', {
|
||||
fields: (t) => ({
|
||||
id: t.exposeID('id'),
|
||||
name: t.exposeString('name'),
|
||||
serviceAndCategory: t.relation('serviceAndCategory'),
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
@PothosRef()
|
||||
init(): void {
|
||||
this.builder.queryFields((t) => ({
|
||||
categories: t.prismaField({
|
||||
type: [this.category()],
|
||||
args: this.builder.generator.findManyArgs('Category'),
|
||||
resolve: async (query, root, args, ctx, info) => {
|
||||
return await this.prisma.category.findMany({
|
||||
...query,
|
||||
skip: args.skip ?? undefined,
|
||||
take: args.take ?? 10,
|
||||
orderBy: args.orderBy ?? undefined,
|
||||
where: args.filter ?? undefined,
|
||||
});
|
||||
},
|
||||
}),
|
||||
category: t.prismaField({
|
||||
type: this.category(),
|
||||
args: this.builder.generator.findUniqueArgs('Category'),
|
||||
resolve: async (query, root, args, ctx, info) => {
|
||||
return await this.prisma.category.findUnique({
|
||||
...query,
|
||||
where: args.where ?? undefined,
|
||||
});
|
||||
},
|
||||
}),
|
||||
}));
|
||||
}
|
||||
}
|
||||
9
src/Order/order.module.ts
Normal file
9
src/Order/order.module.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import { Global, Module } from '@nestjs/common';
|
||||
import { OrderSchema } from './order.schema';
|
||||
|
||||
@Global()
|
||||
@Module({
|
||||
providers: [OrderSchema],
|
||||
exports: [OrderSchema],
|
||||
})
|
||||
export class OrderModule {}
|
||||
70
src/Order/order.schema.ts
Normal file
70
src/Order/order.schema.ts
Normal file
@@ -0,0 +1,70 @@
|
||||
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 'src/Prisma/prisma.service';
|
||||
|
||||
@Injectable()
|
||||
export class OrderSchema extends PothosSchema {
|
||||
constructor(
|
||||
@Inject(SchemaBuilderToken) private readonly builder: Builder,
|
||||
private readonly prisma: PrismaService,
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
||||
// Types section
|
||||
@PothosRef()
|
||||
order() {
|
||||
return this.builder.prismaObject('Order', {
|
||||
fields: (t) => ({
|
||||
id: t.exposeID('id'),
|
||||
paymentId: t.exposeString('paymentId'),
|
||||
userId: t.exposeID('userId'),
|
||||
serviceId: t.exposeID('serviceId'),
|
||||
status: t.exposeString('status'),
|
||||
total: t.exposeInt('total'),
|
||||
createdAt: t.expose('createdAt', { type: 'DateTime' }),
|
||||
updatedAt: t.expose('updatedAt', { type: 'DateTime' }),
|
||||
user: t.relation('user'),
|
||||
payment: t.relation('payment'),
|
||||
service: t.relation('service'),
|
||||
refundTicket: t.relation('refundTicket'),
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
@PothosRef()
|
||||
init(): void {
|
||||
// query section
|
||||
this.builder.queryFields((t) => ({
|
||||
orders: t.prismaField({
|
||||
type: [this.order()],
|
||||
args: this.builder.generator.findManyArgs('Order'),
|
||||
resolve: async (query, root, args, ctx, info) => {
|
||||
return await this.prisma.order.findMany({
|
||||
...query,
|
||||
take: args.take ?? 10,
|
||||
skip: args.skip ?? 0,
|
||||
orderBy: args.orderBy ?? undefined,
|
||||
where: args.filter ?? undefined,
|
||||
});
|
||||
},
|
||||
}),
|
||||
order: t.prismaField({
|
||||
type: this.order(),
|
||||
args: this.builder.generator.findUniqueArgs('Order'),
|
||||
resolve: async (query, root, args, ctx, info) => {
|
||||
return await this.prisma.order.findUnique({
|
||||
...query,
|
||||
where: args.where,
|
||||
});
|
||||
},
|
||||
}),
|
||||
}));
|
||||
}
|
||||
}
|
||||
9
src/Payment/payment.module.ts
Normal file
9
src/Payment/payment.module.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import { Global, Module } from '@nestjs/common';
|
||||
import { PaymentSchema } from './payment.schema';
|
||||
|
||||
@Global()
|
||||
@Module({
|
||||
providers: [PaymentSchema],
|
||||
exports: [PaymentSchema],
|
||||
})
|
||||
export class PaymentModule {}
|
||||
65
src/Payment/payment.schema.ts
Normal file
65
src/Payment/payment.schema.ts
Normal file
@@ -0,0 +1,65 @@
|
||||
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 'src/Prisma/prisma.service';
|
||||
|
||||
@Injectable()
|
||||
export class PaymentSchema extends PothosSchema {
|
||||
constructor(
|
||||
@Inject(SchemaBuilderToken) private readonly builder: Builder,
|
||||
private readonly prisma: PrismaService,
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
||||
// Types section
|
||||
@PothosRef()
|
||||
payment() {
|
||||
return this.builder.prismaObject('Payment', {
|
||||
fields: (t) => ({
|
||||
id: t.exposeID('id'),
|
||||
amount: t.exposeFloat('amount'),
|
||||
status: t.exposeString('status'),
|
||||
createdAt: t.expose('createdAt', { type: 'DateTime' }),
|
||||
updatedAt: t.expose('updatedAt', { type: 'DateTime' }),
|
||||
order: t.relation('Order'),
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
// Queries section
|
||||
@Pothos()
|
||||
init(): void {
|
||||
this.builder.queryFields((t) => ({
|
||||
payment: t.prismaField({
|
||||
type: this.payment(),
|
||||
args: this.builder.generator.findUniqueArgs('Payment'),
|
||||
resolve: async (query, root, args, ctx, info) => {
|
||||
return await this.prisma.payment.findUnique({
|
||||
...query,
|
||||
where: args.where,
|
||||
});
|
||||
},
|
||||
}),
|
||||
payments: t.prismaField({
|
||||
type: [this.payment()],
|
||||
args: this.builder.generator.findManyArgs('Payment'),
|
||||
resolve: async (query, root, args, ctx, info) => {
|
||||
return await this.prisma.payment.findMany({
|
||||
...query,
|
||||
where: args.filter ?? undefined,
|
||||
orderBy: args.orderBy ?? undefined,
|
||||
cursor: args.cursor ?? undefined,
|
||||
take: args.take ?? 10,
|
||||
skip: args.skip ?? 0,
|
||||
});
|
||||
},
|
||||
}),
|
||||
}));
|
||||
}
|
||||
}
|
||||
9
src/RefundTicket/refundticket.module.ts
Normal file
9
src/RefundTicket/refundticket.module.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import { Global, Module } from '@nestjs/common';
|
||||
import { RefundTicketSchema } from './refundticket.schema';
|
||||
|
||||
@Global()
|
||||
@Module({
|
||||
providers: [RefundTicketSchema],
|
||||
exports: [RefundTicketSchema],
|
||||
})
|
||||
export class RefundTicketModule {}
|
||||
55
src/RefundTicket/refundticket.schema.ts
Normal file
55
src/RefundTicket/refundticket.schema.ts
Normal file
@@ -0,0 +1,55 @@
|
||||
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 'src/Prisma/prisma.service';
|
||||
|
||||
@Injectable()
|
||||
export class RefundTicketSchema extends PothosSchema {
|
||||
constructor(
|
||||
@Inject(SchemaBuilderToken) private readonly builder: Builder,
|
||||
private readonly prisma: PrismaService,
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
||||
// Types section
|
||||
@PothosRef()
|
||||
refundTicket() {
|
||||
return this.builder.prismaObject('RefundTicket', {
|
||||
fields: (t) => ({
|
||||
id: t.exposeID('id'),
|
||||
amount: t.exposeFloat('amount'),
|
||||
status: t.exposeString('status'),
|
||||
createdAt: t.expose('createdAt', { type: 'DateTime' }),
|
||||
updatedAt: t.expose('updatedAt', { type: 'DateTime' }),
|
||||
order: t.relation('order'),
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
// Queries section
|
||||
@Pothos()
|
||||
init(): void {
|
||||
this.builder.queryFields((t) => ({
|
||||
refundTickets: t.prismaField({
|
||||
type: [this.refundTicket()],
|
||||
args: this.builder.generator.findManyArgs('RefundTicket'),
|
||||
resolve: async (query, root, args, ctx, info) => {
|
||||
return await this.prisma.refundTicket.findMany({
|
||||
...query,
|
||||
where: args.filter ?? undefined,
|
||||
orderBy: args.orderBy ?? undefined,
|
||||
cursor: args.cursor ?? undefined,
|
||||
take: args.take ?? 10,
|
||||
skip: args.skip ?? 0,
|
||||
});
|
||||
},
|
||||
}),
|
||||
}));
|
||||
}
|
||||
}
|
||||
9
src/ServiceAndCategory/serviceandcategory.module.ts
Normal file
9
src/ServiceAndCategory/serviceandcategory.module.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import { Global, Module } from '@nestjs/common';
|
||||
import { ServiceAndCategorySchema } from './serviceandcategory.schema';
|
||||
|
||||
@Global()
|
||||
@Module({
|
||||
providers: [ServiceAndCategorySchema],
|
||||
exports: [ServiceAndCategorySchema],
|
||||
})
|
||||
export class ServiceAndCategoryModule {}
|
||||
31
src/ServiceAndCategory/serviceandcategory.schema.ts
Normal file
31
src/ServiceAndCategory/serviceandcategory.schema.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
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';
|
||||
|
||||
@Injectable()
|
||||
export class ServiceAndCategorySchema extends PothosSchema {
|
||||
constructor(
|
||||
@Inject(SchemaBuilderToken) private readonly builder: Builder,
|
||||
private readonly prisma: PrismaService,
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
||||
@PothosRef()
|
||||
serviceAndCategory() {
|
||||
return this.builder.prismaObject('ServiceAndCategory', {
|
||||
fields: (t) => ({
|
||||
serviceId: t.exposeID('serviceId'),
|
||||
categoryId: t.exposeID('categoryId'),
|
||||
service: t.relation('service'),
|
||||
category: t.relation('category'),
|
||||
}),
|
||||
});
|
||||
}
|
||||
}
|
||||
9
src/ServiceFeedback/servicefeedback.module.ts
Normal file
9
src/ServiceFeedback/servicefeedback.module.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import { Global, Module } from '@nestjs/common';
|
||||
import { ServiceFeedbackSchema } from './servicefeedback.schema';
|
||||
|
||||
@Global()
|
||||
@Module({
|
||||
providers: [ServiceFeedbackSchema],
|
||||
exports: [ServiceFeedbackSchema],
|
||||
})
|
||||
export class ServiceFeedbackModule {}
|
||||
55
src/ServiceFeedback/servicefeedback.schema.ts
Normal file
55
src/ServiceFeedback/servicefeedback.schema.ts
Normal file
@@ -0,0 +1,55 @@
|
||||
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';
|
||||
|
||||
@Injectable()
|
||||
export class ServiceFeedbackSchema extends PothosSchema {
|
||||
constructor(
|
||||
@Inject(SchemaBuilderToken) private readonly builder: Builder,
|
||||
private readonly prisma: PrismaService,
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
||||
@PothosRef()
|
||||
serviceFeedback() {
|
||||
return this.builder.prismaObject('ServiceFeedback', {
|
||||
fields: (t) => ({
|
||||
id: t.exposeID('id'),
|
||||
userId: t.exposeID('userId'),
|
||||
serviceId: t.exposeID('serviceId'),
|
||||
rating: t.exposeFloat('rating'),
|
||||
comments: t.exposeString('comments'),
|
||||
createdAt: t.expose('createdAt', { type: 'DateTime' }),
|
||||
updatedAt: t.expose('updatedAt', { type: 'DateTime' }),
|
||||
user: t.relation('user'),
|
||||
service: t.relation('service'),
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
@Pothos()
|
||||
init(): void {
|
||||
this.builder.queryFields((t) => ({
|
||||
serviceFeedbacks: t.prismaField({
|
||||
type: [this.serviceFeedback()],
|
||||
args: this.builder.generator.findManyArgs('ServiceFeedback'),
|
||||
resolve: async (query, root, args, ctx, info) => {
|
||||
return await this.prisma.serviceFeedback.findMany({
|
||||
...query,
|
||||
skip: args.skip ?? 0,
|
||||
take: args.take ?? 10,
|
||||
orderBy: args.orderBy ?? undefined,
|
||||
where: args.filter ?? undefined,
|
||||
});
|
||||
},
|
||||
}),
|
||||
}));
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { GraphqlModule } from './graphql/graphql.module';
|
||||
import { ClerkModule } from './clerk/clerk.module';
|
||||
import { RestfulModule } from './restful/restful.module';
|
||||
import { GraphqlModule } from './Graphql/graphql.module';
|
||||
import { ClerkModule } from './Clerk/clerk.module';
|
||||
import { RestfulModule } from './Restful/restful.module';
|
||||
|
||||
@Module({
|
||||
imports: [GraphqlModule, ClerkModule, RestfulModule],
|
||||
|
||||
@@ -5,8 +5,8 @@ import {
|
||||
PothosSchema,
|
||||
SchemaBuilderToken,
|
||||
} from '@smatch-corp/nestjs-pothos';
|
||||
import { Builder } from '../graphql/graphql.builder';
|
||||
import { PrismaService } from 'src/prisma/prisma.service';
|
||||
import { Builder } from '../Graphql/graphql.builder';
|
||||
import { PrismaService } from 'src/Prisma/prisma.service';
|
||||
|
||||
@Injectable()
|
||||
export class CenterSchema extends PothosSchema {
|
||||
|
||||
@@ -5,8 +5,8 @@ import {
|
||||
PothosSchema,
|
||||
SchemaBuilderToken,
|
||||
} from '@smatch-corp/nestjs-pothos';
|
||||
import { Builder } from '../graphql/graphql.builder';
|
||||
import { PrismaService } from 'src/prisma/prisma.service';
|
||||
import { Builder } from '../Graphql/graphql.builder';
|
||||
import { PrismaService } from 'src/Prisma/prisma.service';
|
||||
|
||||
@Injectable()
|
||||
export class CenterStaffSchema extends PothosSchema {
|
||||
|
||||
@@ -5,8 +5,8 @@ import {
|
||||
PothosSchema,
|
||||
SchemaBuilderToken,
|
||||
} from '@smatch-corp/nestjs-pothos';
|
||||
import { Builder } from '../graphql/graphql.builder';
|
||||
import { PrismaService } from 'src/prisma/prisma.service';
|
||||
import { Builder } from '../Graphql/graphql.builder';
|
||||
import { PrismaService } from 'src/Prisma/prisma.service';
|
||||
|
||||
@Injectable()
|
||||
export class ChatroomSchema extends PothosSchema {
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
export const cors = {
|
||||
import { CorsOptions } from '@nestjs/common/interfaces/external/cors-options.interface';
|
||||
|
||||
export const cors: CorsOptions = {
|
||||
origin: process.env.CORS_ORIGIN,
|
||||
methods: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'OPTIONS'],
|
||||
allowedHeaders: ['Content-Type', 'Authorization'],
|
||||
|
||||
@@ -4,20 +4,25 @@ import { GraphQLModule } from '@nestjs/graphql';
|
||||
import { PothosModule } from '@smatch-corp/nestjs-pothos';
|
||||
import { PothosApolloDriver } from '@smatch-corp/nestjs-pothos-apollo-driver';
|
||||
import { Builder } from './graphql.builder';
|
||||
import { PrismaService } from '../prisma/prisma.service';
|
||||
import { GraphQLValidationMiddleware } from 'src/middlewares/graphql.middleware';
|
||||
import { PrismaModule } from 'src/prisma/prisma.module';
|
||||
import { UserModule } from 'src/user/user.module';
|
||||
import { CenterModule } from 'src/center/center.module';
|
||||
import { ServiceModule } from 'src/service/service.module';
|
||||
import { ChatroomModule } from 'src/chatroom/chatroom.module';
|
||||
import { CenterStaffModule } from 'src/centerstaff/centerstaff.module';
|
||||
import { ResumeModule } from 'src/resume/resume.module';
|
||||
import { WorkshopModule } from 'src/workshop/workshop.module';
|
||||
import { WorkshopOrganizationModule } from 'src/workshoporganization/workshoporganization.module';
|
||||
import { WorkshopSubscriptionModule } from 'src/workshopsubscription/workshopsubscription.module';
|
||||
import { PrismaService } from '../Prisma/prisma.service';
|
||||
import { GraphQLValidationMiddleware } from '../middlewares/graphql.middleware';
|
||||
import { PrismaModule } from '../Prisma/prisma.module';
|
||||
import { UserModule } from '../User/user.module';
|
||||
import { CenterModule } from '../Center/center.module';
|
||||
import { ServiceModule } from '../Service/service.module';
|
||||
import { ChatroomModule } from '../ChatRoom/chatroom.module';
|
||||
import { CenterStaffModule } from '../CenterStaff/centerstaff.module';
|
||||
import { ResumeModule } from '../Resume/resume.module';
|
||||
import { WorkshopModule } from '../Workshop/workshop.module';
|
||||
import { WorkshopOrganizationModule } from '../WorkshopOrganization/workshoporganization.module';
|
||||
import { WorkshopSubscriptionModule } from '../WorkshopSubscription/workshopsubscription.module';
|
||||
import { PrismaCrudGenerator } from './graphql.generator';
|
||||
|
||||
import { OrderModule } from '../Order/order.module';
|
||||
import { PaymentModule } from '../Payment/payment.module';
|
||||
import { RefundTicketModule } from '../RefundTicket/refundticket.module';
|
||||
import { ServiceAndCategoryModule } from '../ServiceAndCategory/serviceandcategory.module';
|
||||
import { CategoryModule } from '../Category/category.module';
|
||||
import { ServiceFeedbackModule } from '../ServiceFeedback/servicefeedback.module';
|
||||
@Global()
|
||||
@Module({
|
||||
imports: [
|
||||
@@ -31,6 +36,12 @@ import { PrismaCrudGenerator } from './graphql.generator';
|
||||
WorkshopModule,
|
||||
WorkshopOrganizationModule,
|
||||
WorkshopSubscriptionModule,
|
||||
PaymentModule,
|
||||
OrderModule,
|
||||
RefundTicketModule,
|
||||
ServiceAndCategoryModule,
|
||||
CategoryModule,
|
||||
ServiceFeedbackModule,
|
||||
PothosModule.forRoot({
|
||||
builder: {
|
||||
inject: [PrismaService],
|
||||
|
||||
@@ -10,12 +10,12 @@ async function bootstrap() {
|
||||
const config = new DocumentBuilder()
|
||||
.setTitle('EPESS API')
|
||||
.setDescription('API documentation for EPESS application')
|
||||
.setVersion('1.0')
|
||||
.setVersion('0.0.1')
|
||||
.addBearerAuth()
|
||||
.build();
|
||||
|
||||
const document = SwaggerModule.createDocument(app, config);
|
||||
SwaggerModule.setup('api', app, document);
|
||||
SwaggerModule.setup(process.env.SWAGGER_PATH ?? 'v1', app, document);
|
||||
|
||||
document.paths['/graphql'] = {
|
||||
get: {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Injectable, NestMiddleware } from '@nestjs/common';
|
||||
import { PrismaService } from '../prisma/prisma.service';
|
||||
import { PrismaService } from '../Prisma/prisma.service';
|
||||
|
||||
@Injectable()
|
||||
export class PrismaContextMiddleware implements NestMiddleware {
|
||||
|
||||
@@ -5,8 +5,8 @@ import {
|
||||
PothosSchema,
|
||||
SchemaBuilderToken,
|
||||
} from '@smatch-corp/nestjs-pothos';
|
||||
import { Builder } from '../graphql/graphql.builder';
|
||||
import { PrismaService } from 'src/prisma/prisma.service';
|
||||
import { Builder } from '../Graphql/graphql.builder';
|
||||
import { PrismaService } from 'src/Prisma/prisma.service';
|
||||
|
||||
@Injectable()
|
||||
export class ResumeSchema extends PothosSchema {
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import { Global, Module } from '@nestjs/common';
|
||||
import { ServiceSchema } from './service.schema';
|
||||
import { PrismaCrudGenerator } from 'src/graphql/graphql.generator';
|
||||
|
||||
@Global()
|
||||
@Module({
|
||||
providers: [ServiceSchema, PrismaCrudGenerator],
|
||||
providers: [ServiceSchema],
|
||||
exports: [ServiceSchema],
|
||||
})
|
||||
export class ServiceModule {}
|
||||
|
||||
@@ -5,8 +5,8 @@ import {
|
||||
PothosSchema,
|
||||
SchemaBuilderToken,
|
||||
} from '@smatch-corp/nestjs-pothos';
|
||||
import { Builder } from '../graphql/graphql.builder';
|
||||
import { PrismaService } from 'src/prisma/prisma.service';
|
||||
import { Builder } from '../Graphql/graphql.builder';
|
||||
import { PrismaService } from 'src/Prisma/prisma.service';
|
||||
|
||||
@Injectable()
|
||||
export class ServiceSchema extends PothosSchema {
|
||||
@@ -49,8 +49,8 @@ export class ServiceSchema extends PothosSchema {
|
||||
...query,
|
||||
where: args.filter ?? undefined,
|
||||
orderBy: args.orderBy ?? undefined,
|
||||
skip: args.skip ?? undefined,
|
||||
take: args.take ?? undefined,
|
||||
skip: args.skip ?? 0,
|
||||
take: args.take ?? 10,
|
||||
});
|
||||
},
|
||||
}),
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import { Global, Module } from '@nestjs/common';
|
||||
import { UserSchema } from './user.schema';
|
||||
import { PrismaService } from 'src/prisma/prisma.service';
|
||||
@Global()
|
||||
@Module({
|
||||
providers: [PrismaService, UserSchema],
|
||||
providers: [UserSchema],
|
||||
exports: [UserSchema],
|
||||
})
|
||||
export class UserModule {}
|
||||
|
||||
@@ -5,8 +5,9 @@ import {
|
||||
PothosSchema,
|
||||
SchemaBuilderToken,
|
||||
} from '@smatch-corp/nestjs-pothos';
|
||||
import { Builder } from '../graphql/graphql.builder';
|
||||
import { PrismaService } from 'src/prisma/prisma.service';
|
||||
import { Builder } from '../Graphql/graphql.builder';
|
||||
import { PrismaService } from 'src/Prisma/prisma.service';
|
||||
import { clerkClient, } from '@clerk/clerk-sdk-node';
|
||||
|
||||
@Injectable()
|
||||
export class UserSchema extends PothosSchema {
|
||||
@@ -27,7 +28,7 @@ export class UserSchema extends PothosSchema {
|
||||
email: t.exposeString('email'),
|
||||
phoneNumber: t.exposeString('phoneNumber'),
|
||||
oauthToken: t.exposeString('oauthToken', { nullable: true }),
|
||||
// role: t.exposeString('role'),
|
||||
role: t.exposeString('role'),
|
||||
createdAt: t.expose('createdAt', { type: 'DateTime' }),
|
||||
updatedAt: t.expose('updatedAt', { type: 'DateTime' }),
|
||||
center: t.relation('center'),
|
||||
@@ -55,19 +56,28 @@ export class UserSchema extends PothosSchema {
|
||||
|
||||
user: t.prismaField({
|
||||
type: this.user(),
|
||||
args: {
|
||||
id: t.arg.id({
|
||||
description: 'The ID of the user to retrieve',
|
||||
}),
|
||||
},
|
||||
args: this.builder.generator.findUniqueArgs('User'),
|
||||
resolve: async (query, root, args, ctx, info) => {
|
||||
const { id } = args;
|
||||
if (!id) {
|
||||
throw new Error('User ID is required');
|
||||
}
|
||||
return await this.prisma.user.findUnique({ where: { id } });
|
||||
return await this.prisma.user.findUnique({
|
||||
...query,
|
||||
where: args.where,
|
||||
});
|
||||
},
|
||||
}),
|
||||
// userByToken: t.prismaField({
|
||||
// type: this.user(),
|
||||
// args: this.builder.args({
|
||||
// oauthToken: t.arg.string({ required: true }),
|
||||
// }),
|
||||
// resolve: async (query, root, args, ctx, info) => {
|
||||
// // check if the token is valid
|
||||
// const { user } = await clerkClient.verifyToken
|
||||
// return await this.prisma.user.findFirst({
|
||||
// ...query,
|
||||
// where: args.where,
|
||||
// });
|
||||
// },
|
||||
// }),
|
||||
}));
|
||||
|
||||
// Mutation section
|
||||
|
||||
@@ -5,8 +5,8 @@ import {
|
||||
PothosSchema,
|
||||
SchemaBuilderToken,
|
||||
} from '@smatch-corp/nestjs-pothos';
|
||||
import { Builder } from '../graphql/graphql.builder';
|
||||
import { PrismaService } from 'src/prisma/prisma.service';
|
||||
import { Builder } from '../Graphql/graphql.builder';
|
||||
import { PrismaService } from 'src/Prisma/prisma.service';
|
||||
|
||||
@Injectable()
|
||||
export class WorkshopSchema extends PothosSchema {
|
||||
|
||||
@@ -5,8 +5,8 @@ import {
|
||||
PothosSchema,
|
||||
SchemaBuilderToken,
|
||||
} from '@smatch-corp/nestjs-pothos';
|
||||
import { Builder } from '../graphql/graphql.builder';
|
||||
import { PrismaService } from 'src/prisma/prisma.service';
|
||||
import { Builder } from '../Graphql/graphql.builder';
|
||||
import { PrismaService } from 'src/Prisma/prisma.service';
|
||||
|
||||
@Injectable()
|
||||
export class WorkshopOrganizationSchema extends PothosSchema {
|
||||
|
||||
@@ -5,8 +5,8 @@ import {
|
||||
PothosSchema,
|
||||
SchemaBuilderToken,
|
||||
} from '@smatch-corp/nestjs-pothos';
|
||||
import { Builder } from '../graphql/graphql.builder';
|
||||
import { PrismaService } from 'src/prisma/prisma.service';
|
||||
import { Builder } from '../Graphql/graphql.builder';
|
||||
import { PrismaService } from '../Prisma/prisma.service';
|
||||
|
||||
@Injectable()
|
||||
export class WorkshopSubscriptionSchema extends PothosSchema {
|
||||
|
||||
Reference in New Issue
Block a user