Doron Roberts-Kedes
08/14/2022, 11:37 PMAladin
08/14/2022, 11:50 PMmiddleware
is not necessary in here as adding such data can be done without middleware.
However, if middleware is required, here's a quick simple example: When you get the request, set a global instance that records the session data and the ID of the record about to be created (pass ID manually). The middleware can then use that instance and compare the ID to get the session data then remove that entry from the global instance.
Another example is to reset prisma on each request and define the middleware during the request (which will have access to the session data), not a great solution, but it keeps it clean.
Too bad Prisma won't allow deleting middleware, another good way to do this imo is to define the middleware at the beginning of the request, then removing it at the end of it. Maybe we should raise a ticket for this feature.Doron Roberts-Kedes
08/14/2022, 11:56 PMDoron Roberts-Kedes
08/14/2022, 11:57 PMAladin
08/15/2022, 12:22 AMpostId
• Add sessionMiddlewareData.add(postId, { ...stuff here })
• In the middleware, when creating a Post or updating it, you can call sessionMiddlewareData.get(params.args.data.id)
to get the data you recorded earlier and clean it upDoron Roberts-Kedes
08/15/2022, 2:50 PM