Briggs
05/17/2022, 9:42 PMconst result = await prisma.user.create({
data: {
email: '<mailto:abc@123.com|abc@123.com>',
firstName: 'abc',
lastName: 'xyz',
type: UserType.OWNER,
},
context: blah,
});
context could be of any type so we could then pick that up in the middleware
export async function PubSubMiddleWare(
params: Prisma.MiddlewareParams,
next: (params: Prisma.MiddlewareParams) => Promise<any>
) {
const { action, model, args } = params;
const { context } = args;
pubsub
.publish(`${params.model}_changed`, {
mutation: action,
model,
node: result,
context
})
}Richard Ward
05/17/2022, 9:46 PMBriggs
05/17/2022, 9:46 PMNurul
05/25/2022, 11:54 AM