I ran yarn rw dev api and got this message returned
api | GraphQL server crashed
api |
api |
api | Error Info
api |
api | {}
api |
api | Error Stack
api |
api | Error: Unknown type “PaymentStatus”.
api |
api | Unknown type “PaymentStatus”.
now I have an enum PaymentStatus added in my schema.prisma file generated and migrated it i also added it with a default value in my file for the graph that resolves mutation but for some reason the graph cant querry it please help me
import type { QueryResolvers, MutationResolvers } from ‘types/graphql’
import { db } from ‘src/lib/db’
export const invoices: QueryResolvers[‘invoices’] = () => {
return db.invoice.findMany()
}
export const invoice: QueryResolvers[‘invoice’] = ({ id }) => {
return db.invoice.findUnique({
where: { id },
})
}
export const createInvoice: MutationResolvers[‘createInvoice’] = async ({
input,
}) => {
try {
// Log input data to see what’s being received
console.log(‘Received input:’, input)
// Create the invoice with the status set to 'Unpaid'
const result = await db.invoice.create({
data: {
...input,
status: 'Unpaid', // Set the payment status to "unpaid"
},
})
// Log the result or other relevant data
console.log('Created invoice:', result)
return result
} catch (error) {
// Log any errors that occur
console.error(‘Error creating invoice:’, error)
throw error
}
}
export const updateInvoice: MutationResolvers[‘updateInvoice’] = ({
id,
input,
}) => {
return db.invoice.update({
data: {
…input,
status: ‘Paid’, // Set the payment status to a valid value
},
where: { id },
})
}
export const deleteInvoice: MutationResolvers[‘deleteInvoice’] = ({ id }) => {
return db.invoice.delete({
where: { id },
})
}