import { schema } from 'nexus' export const OptionCategory = schema.objectType({ name: 'OptionCategory', definition(t) { t.model.id() t.model.createdAt() t.model.updatedAt() t.model.title() t.model.titleFr() t.model.isDeleted() t.model.service() t.model.options() }, }) export const OptionCategoryMutation = schema.extendType({ type: 'Mutation', definition: (t) => { t.crud.deleteOneOptionCategory({ alias: 'deleteOptionCategory' }) t.crud.updateOneOptionCategory({ alias: 'updateOptionCategory' }) t.crud.createOneOptionCategory({ alias: 'createOptionCategory' }) t.field('createOptionCategory', { type: 'OptionCategory', args: { data: schema.arg({ type: 'OptionCategoryCreateInput' }), }, resolve: async (parent, { data }, ctx: NexusContext) => { if (!data?.service?.connect) { throw new Error('Option category needs to be connected to a service') } return ctx.prisma.optionCategory.create({ data }) }, }) }, }) export const OptionCategoryQuery = schema.extendType({ type: 'Query', definition(t) { t.crud.optionCategory() t.crud.optionCategories({ filtering: true, ordering: true }) }, })