Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shallow routing support #47

Closed
FINDarkside opened this issue Feb 21, 2022 · 3 comments
Closed

Shallow routing support #47

FINDarkside opened this issue Feb 21, 2022 · 3 comments

Comments

@FINDarkside
Copy link
Contributor

FINDarkside commented Feb 21, 2022

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.

@rrdelaney
Copy link
Contributor

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?

@FINDarkside
Copy link
Contributor Author

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.

@FINDarkside
Copy link
Contributor Author

FINDarkside commented Aug 16, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants