I’m trying to integrate apollo3-cache-persist in my Next.js project, so I’ve followed official tutorial from here:
I have a setup like so:
2 pages. /auth and /index, both uses getServerSideProps and query to determine if use if authenticated. Index redirect to auth if user is null and auth redirect to user if not.
I also have a mutation that authenticate user on /auth page and then goes to an /index page in onComplete event via router.push method. After that use will appear in SSR of index and should update clients cache.
Everything works fine but, useEffect, in which we should add cached SSR data to client cache, is executed after useApollo returns client, so on the page I see outdated result (where user is still null).
I wasn’t searching through Apollo-client source code precisely, but I guess this one is caused by not triggering broadcasting in cache.restore() function.
So, I would like to know is this a planned behaviour or not. And if so, how should I update client cache with SSR data, so it will update the queries?