Refactor code structure and dependencies
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import { builder, prisma } from './graphql.builder';
|
||||
import type PrismaTypes from '@pothos/plugin-prisma/generated';
|
||||
|
||||
builder.prismaObject('User', {
|
||||
fields: (t) => ({
|
||||
@@ -114,10 +113,103 @@ builder.queryType({
|
||||
});
|
||||
},
|
||||
}),
|
||||
user: t.prismaField({
|
||||
type: 'User',
|
||||
args: {
|
||||
id: t.arg.string(),
|
||||
},
|
||||
resolve: (query, root, args, ctx, info) => {
|
||||
return prisma.user.findUnique({
|
||||
where: {
|
||||
id: args.id?.toString(),
|
||||
},
|
||||
});
|
||||
},
|
||||
}),
|
||||
orders: t.prismaField({
|
||||
type: ['Order'],
|
||||
resolve: (query, root, args, ctx, info) => {
|
||||
return prisma.order.findMany({
|
||||
...query,
|
||||
});
|
||||
},
|
||||
}),
|
||||
serviceFeedbacks: t.prismaField({
|
||||
type: ['ServiceFeedback'],
|
||||
resolve: (query, root, args, ctx, info) => {
|
||||
return prisma.serviceFeedback.findMany({
|
||||
...query,
|
||||
});
|
||||
},
|
||||
}),
|
||||
documents: t.prismaField({
|
||||
type: ['UploadedDocument'],
|
||||
resolve: (query, root, args, ctx, info) => {
|
||||
return prisma.uploadedDocument.findMany({
|
||||
...query,
|
||||
});
|
||||
},
|
||||
}),
|
||||
messages: t.prismaField({
|
||||
type: ['Message'],
|
||||
resolve: (query, root, args, ctx, info) => {
|
||||
return prisma.message.findMany({
|
||||
...query,
|
||||
});
|
||||
},
|
||||
}),
|
||||
services: t.prismaField({
|
||||
type: ['Service'],
|
||||
resolve: (query, root, args, ctx, info) => {
|
||||
return prisma.service.findMany({
|
||||
...query,
|
||||
});
|
||||
},
|
||||
}),
|
||||
centers: t.prismaField({
|
||||
type: ['Center'],
|
||||
resolve: (query, root, args, ctx, info) => {
|
||||
return prisma.center.findMany({
|
||||
...query,
|
||||
});
|
||||
},
|
||||
}),
|
||||
chatRooms: t.prismaField({
|
||||
type: ['ChatRoom'],
|
||||
resolve: (query, root, args, ctx, info) => {
|
||||
return prisma.chatRoom.findMany({
|
||||
...query,
|
||||
});
|
||||
},
|
||||
}),
|
||||
centerStaffs: t.prismaField({
|
||||
type: ['CenterStaff'],
|
||||
resolve: (query, root, args, ctx, info) => {
|
||||
return prisma.centerStaff.findMany({
|
||||
...query,
|
||||
});
|
||||
},
|
||||
}),
|
||||
workshopSubscriptions: t.prismaField({
|
||||
type: ['WorkshopSubscription'],
|
||||
resolve: (query, root, args, ctx, info) => {
|
||||
return prisma.workshopSubscription.findMany({
|
||||
...query,
|
||||
});
|
||||
},
|
||||
}),
|
||||
workshops: t.prismaField({
|
||||
type: ['Workshop'],
|
||||
resolve: (query, root, args, ctx, info) => {
|
||||
return prisma.workshop.findMany({
|
||||
...query,
|
||||
});
|
||||
},
|
||||
}),
|
||||
}),
|
||||
});
|
||||
|
||||
// // Mutation section
|
||||
// Mutation section
|
||||
// builder.mutationType({
|
||||
// fields: (t) => ({
|
||||
// createUser: t.prismaField({
|
||||
|
||||
Reference in New Issue
Block a user