RevereCRE/relay-nextjs

Shallow routing support

FINDarkside opened this issue · 3 comments

This has been discussed in #41 but I think I will need shallow routing even though you said it's not supported. Not really asking you to make it, I'm willing to make a PR if you think it's ok idea and I can come up with some acceptable solution. Right now I'm thinking of just making option for always rendering suspense (even server side), since React 18 supports server-side suspense. Not sure if that would solve all the issues with shallow routing.

The usecase is following:
We have infinite feed in our page and want to be able to return to the same position when user visits other page. Obvious solution to this is storing the necessary info in the url, but we can't really do that properly without shallow routing. If we just put the starting cursor + count and let relay fetch the whole query again, it'll mean that we will constantly refetch all of the content in the feed that has already been loaded instead of just the next x items.

Yea I should rephrase how we support shallow routing: it's totally supported for in-page navigation such as changing query params, but unsupported for navigating to a new page that is using relay-nextjs. Does setting the store to only use the cache work for your use-case?

Hey I think I ran into some issues with queries being released too early or something and assumed it was because of the conversation I linked to in the opener. I'll look more into this in the coming weeks.

Does setting the store to only use the cache work for your use-case?

No, we want to load the next x items in the feed and not load the ones that are already loaded. But we are indeed only doing shallow routing to do in-page navigation so I guess it should work. I'll need to re-check.

Ok finally tested this out again and everything works just fine. Not sure what the issue was last time, probably not related to relay-nextjs so I'll close this.