import { schema } from 'nexus' import { AccountStatementWhereInput, AccountStatementOrderByInput, } from 'nexus-plugin-prisma/client' export const AccountStatement = schema.objectType({ name: 'AccountStatement', definition(t) { t.model.id() t.model.createdAt() t.model.updatedAt() t.model.transactionDate() t.model.transactionNumber() t.model.amount() t.model.accountNumber() t.model.chequeNumber() t.model.receiptNumber() t.model.description() t.model.isDtCt() t.model.isEndOfYear() t.model.condoManagerId() t.model.property() }, }) export const AccountStatementQueries = schema.extendType({ type: 'Query', definition(t) { t.crud.accountStatement() t.crud.accountStatements({ filtering: true, ordering: true }) t.field('accountStatements', { type: 'AccountStatement', list: true, args: { where: schema.arg({ type: 'AccountStatementWhereInput' }), orderBy: schema.arg({ type: 'AccountStatementOrderByInput', list: true }), first: schema.arg({ type: 'Int' }), last: schema.arg({ type: 'Int' }), skip: schema.arg({ type: 'Int' }), }, resolve: async ( parent, { where, orderBy, first, last, skip, }: { where?: AccountStatementWhereInput orderBy?: AccountStatementOrderByInput[] first?: number last?: number skip?: number }, ctx: NexusContext ) => { if (first && last) { throw new Error("Can't provide both first and last parameters at the same time") } return ctx.prisma.accountStatement.findMany({ where, skip, ...(orderBy?.length > 0 && { orderBy: orderBy[0] }), ...((first || last) && { take: first || -last, }), }) }, }) }, }) export const AccountStatementMutation = schema.extendType({ type: 'Mutation', definition: (t) => { t.crud.deleteOneAccountStatement({ alias: 'deleteAccountStatement' }) t.crud.updateOneAccountStatement({ alias: 'updateAccountStatement' }) t.crud.createOneAccountStatement({ alias: 'createAccountStatement' }) }, })