import { schema } from 'nexus' // import * as Slack from '../../utils/slack' // import * as logger from '../../utils/logger' // import GeneralUtils from '../../utils/general' export const Option = schema.objectType({ name: 'Option', definition(t) { t.model.id() t.model.createdAt() t.model.updatedAt() t.model.title() t.model.titleFr() t.model.description() t.model.descriptionFr() t.model.price() t.model.durationMS() t.model.recurring() t.model.recurringType() t.model.isRecurring() t.model.position() t.model.isDeleted() t.model.imageId() t.model.timeRequiredAfterOptionMS() t.model.minimumQuantity() t.model.maximumQuantity() t.model.inventory() t.model.image() t.model.service() t.model.serviceProject() t.model.lineItems() t.model.addons() t.model.categories() }, }) export const OptionMutation = schema.extendType({ type: 'Mutation', definition: (t) => { t.crud.deleteOneOption({ alias: 'deleteOption' }) t.crud.updateOneOption({ alias: 'updateOption' }) t.crud.createOneOption({ alias: 'createOption' }) }, }) export const OptionQuery = schema.extendType({ type: 'Query', definition(t) { t.crud.option() t.crud.options({ filtering: true, ordering: true }) t.list.field('undeletedOptions', { type: 'Option', args: { serviceId: schema.stringArg(), }, resolve: (_, { serviceId }, ctx: NexusContext) => { return ctx.prisma.option.findMany({ where: { isDeleted: null, serviceId: { equals: serviceId } }, }) }, }) t.list.field('optionsForProject', { type: 'Option', args: { serviceProjectId: schema.stringArg(), }, resolve: (_, { serviceProjectId }, ctx: NexusContext) => { return ctx.prisma.option.findMany({ where: { isDeleted: null, serviceProjectId: { equals: serviceProjectId } }, }) }, }) }, })