Transactions & DB caching in Prisma

I am running into an issue, where writes to the DB are not showing up after a navigate call. But do show up on a manual refresh.

I have the following getCurrentUser code - see getCurrentUser method

If the user does not have a team, I am directing them to a pickTeam page. On this team page, after onCompleted of the mutation, I am navigation to a page. After the redirect to the page, the currentUser method returns an empty team, even though it was just created by Prisma.

Ive tried doing delays with await new Promise(r => setTimeout(r, 1000)); but it does not help.

The currentUser.currentTeam returns null after navigate, but returns an object after a browser refresh.

Why is this happening? is this caching on prisma? or RW caching the currentUser data?

My current workaround is to do a window.location.reload()

It may be caching in Apollo client.

I think the cache is updated based on the fields you select for return in your mutation. In your case, the createTeamWithName mutation selects only the id and name of the new Team, but have you tried to select the related owner/user? If you can, I think it might update the currentUser as cached with the newly picked/created team record.