Add type-graphql dependency and extend GraphQL schema with new types and fields
This commit is contained in:
@@ -29,4 +29,4 @@ export const builder = new SchemaBuilder<{
|
||||
},
|
||||
});
|
||||
|
||||
builder.addScalarType('DateTime', DateTimeResolver, {});
|
||||
builder.addScalarType('DateTime', DateTimeResolver, {});
|
||||
@@ -61,10 +61,74 @@ builder.prismaObject('Message', {
|
||||
builder.prismaObject('Service', {
|
||||
fields: (t) => ({
|
||||
id: t.exposeID('id'),
|
||||
name: t.exposeString('name'),
|
||||
description: t.exposeString('description'),
|
||||
centerId: t.exposeID('centerId'),
|
||||
price: t.expose('price', {
|
||||
type: 'Float',
|
||||
}),
|
||||
rating: t.expose('rating', {
|
||||
type: 'Float',
|
||||
}),
|
||||
createdAt: t.expose('createdAt', {
|
||||
type: 'DateTime',
|
||||
nullable: true,
|
||||
}),
|
||||
updatedAt: t.expose('updatedAt', {
|
||||
type: 'DateTime',
|
||||
nullable: true,
|
||||
}),
|
||||
managedBy: t.relation('managedBy'),
|
||||
feedbacks: t.relation('feedbacks'),
|
||||
order: t.relation('order'),
|
||||
workshop: t.relation('workshop'),
|
||||
milestone: t.relation('milestone'),
|
||||
schedule: t.relation('schedule'),
|
||||
serviceAndCategory: t.relation('serviceAndCategory'),
|
||||
workshopOrganization: t.relation('workshopOrganization'),
|
||||
user: t.relation('user'),
|
||||
userId: t.exposeID('userId'),
|
||||
}),
|
||||
});
|
||||
|
||||
builder.prismaObject('Milestone', {
|
||||
fields: (t) => ({
|
||||
id: t.exposeID('id'),
|
||||
serviceId: t.exposeID('serviceId'),
|
||||
}),
|
||||
});
|
||||
|
||||
builder.prismaObject('Schedule', {
|
||||
fields: (t) => ({
|
||||
id: t.exposeID('id'),
|
||||
serviceId: t.exposeID('serviceId'),
|
||||
}),
|
||||
});
|
||||
|
||||
builder.prismaObject('ServiceAndCategory', {
|
||||
fields: (t) => ({
|
||||
serviceId: t.exposeID('serviceId'),
|
||||
categoryId: t.exposeID('categoryId'),
|
||||
service: t.relation('service'),
|
||||
category: t.relation('category'),
|
||||
}),
|
||||
});
|
||||
|
||||
builder.prismaObject('WorkshopOrganization', {
|
||||
fields: (t) => ({
|
||||
serviceId: t.exposeID('serviceId'),
|
||||
workshopId: t.exposeID('workshopId'),
|
||||
service: t.relation('service'),
|
||||
workshop: t.relation('workshop'),
|
||||
}),
|
||||
});
|
||||
|
||||
builder.prismaObject('Category', {
|
||||
fields: (t) => ({
|
||||
id: t.exposeID('id'),
|
||||
}),
|
||||
});
|
||||
|
||||
builder.prismaObject('Center', {
|
||||
fields: (t) => ({
|
||||
id: t.exposeID('id'),
|
||||
@@ -166,6 +230,19 @@ builder.queryType({
|
||||
});
|
||||
},
|
||||
}),
|
||||
service: t.prismaField({
|
||||
type: 'Service',
|
||||
args: {
|
||||
id: t.arg.string(),
|
||||
},
|
||||
resolve: (query, root, args, ctx, info) => {
|
||||
return prisma.service.findUnique({
|
||||
where: {
|
||||
id: args.id?.toString(),
|
||||
},
|
||||
});
|
||||
},
|
||||
}),
|
||||
centers: t.prismaField({
|
||||
type: ['Center'],
|
||||
resolve: (query, root, args, ctx, info) => {
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user