Unrequired cacheing in NestJS microservice when running graphQL mutation

25 views Asked by At

I am working on a NestJS microservice that uses Prisma for GraphQL implementation that uses PostgreSQL as the DB. I have written a mutation in my service that is used for toggling - It creates a record in the table if a record with the specified user_id does not exist. If it exists already, it is deleted.

The problem I am facing here is that even though the operations are happening on the table in DB, as required, the data that is being returned is the data from the previous create operation. ie, For example, if I run the mutation with the user_id 'D1' for the first time, it gets created, and the data with the user_id 'D1' is returned. Now, I run the mutation with the uer_id 'E1'. But, this time, even though the record with the user_id 'E1' gets created in DB, the data returned is still the data for the user_id 'D1'.

I'm not sure why this is happening. Please help me figure this out.

0

There are 0 answers