Closed georg-malahov closed 6 months ago
The latest updates on your projects. Learn more about Vercel for Git ↗︎
Hey @georg-malahov , thanks for the contribution.
Sadly, I don't think we can merge these changes. Firstly, as you've said, we are not ready for SWR 2 yet, as it would break our prepass
logic. Also, this highly increases the complexity of the builtin fetcher. I think if someone wants to have all these features themselves it's fine to only let them achieve it only through code components.
@IcaroG No, it doesn't break current prepass
logic. As prepass
make sense only for queries, not mutations, queries still use existing useMutablePlasmicQueryData
, so nothing breaks. The only thing is that there would be two different versions on SWR used for queries and mutations. The prepass
isn't broken. How would it increase the complexity of the builtin fetcher, as builtin fetcher wasn't changed?
@georg-malahov thanks for your PR! From what I understand, you'd like to make data fetches from the client / browser (without going through the Plasmic proxy), but the only way to do so is via the "HTTP REST API Fetcher" code component (the one in @plasmicpkgs/plasmic-query
), and that fetcher does not support a lot of things you'd like from swr
(revalidation, mutation, etc).
Our preference here, though, is to continue evolving our data integrations framework, by adding support for client-only data sources in the near future. We think it's a better experience for working with data than the bespoke fetcher components.
@chungwu Thanks for your answer! Yes, you are right, I wanted to extend the possibilities of the "HTTP REST API Fetcher" without breaking the current functionality. And I managed to replace and migrate from the current component to the updated one quite seamlessly.
Could you share a link to what is on the roadmap for evolving the data integrations framework, and especially regarding the client-only data sources?
I also initially tried using integrations, but I faced difficulty in understanding how to update the endpoints from development to production, or how to switch the entire pre-configured integrations when transitioning between environments. Is this a known limitation? Do you have any suggestions on how to manage this?
Could you share a link to what is on the roadmap for evolving the data integrations framework, and especially regarding the client-only data sources?
We don't have one handy... I imagine this is something we'll get better at as we start doing more work in the open!
I also initially tried using integrations, but I faced difficulty in understanding how to update the endpoints from development to production, or how to switch the entire pre-configured integrations when transitioning between environments. Is this a known limitation? Do you have any suggestions on how to manage this?
You're right! This is definitely a current limitation without a good workaround 😓
Motivation:
Current backend integrations sometimes have unpredictable load times, generally much longer than fetching directly from the endpoint server without going through Plasmic servers. As a workaround, we can use a browser fetch API. However, it has several problems, making it difficult to use in many cases.
Problems with Browser Fetch API:
Suggested Solutions:
Known Caveats:
The SWR Library from the 2nd major version mainly disallows using suspense on the server side, breaking the current Plasmic SSR prepass mechanism. See this GitHub issue for more details.
Therefore, we continue using the existing useMutablePlasmicQueryData for fetching data, which is still based on the prior SWR version and supports react-ssr-prepass. For manual mutation requests, the 2nd version of SWR is used.
All this makes it harder to provide and use the correct SWR configuration, leading to potential inconsistencies with caching, especially when using custom cache providers, suspense, fallback, and fallbackData properties.