Closed samuelcastro closed 3 years ago
Thanks! It's still in progress, it works fine in staging/production but is currently disabled in dev. I've spoken with the author who's making bugfixes and improvements, and I hope the developer experience will become better soon.
Although, I'm pretty sure it can be optimized thanks to the new way the getServerSideProps function is returned. See https://github.com/UnlyEd/next-right-now/discussions/348
I haven't taken time to look into it but if you wish to look into it a PR is much welcome :)
AFAIU, if apollo is loaded in the browser without the cache, then it'll need to re-fetch during the React reconciliation phase. I believe the cache is what's make the data available from the backend to the frontend, but I might be wrong, or it might be possible to do it another way. I'm not so experienced with the Apollo's internals so I preferred to duplicate code rather than create a bug/regression.
But, as you stated, since the data are statically available, it makes sense there would be a way to write the code only once.
We could add the static data into the cache: https://www.apollographql.com/docs/react/caching/cache-interaction/#writequery or https://www.apollographql.com/docs/react/caching/cache-interaction/#using-cachemodify
I'm not using Apollo in production anymore (besides the NRN demo), I'm not so confident about recommending something like that without prior experience.
If you end up playing with it and come up with a recommendation/PR, then I might consider spending more time on it!
I'll take a look and run some tests, but yeah, it's seems both simple and shouldn't have any downside indeed!
Thanks, I've merged your PR! 🎉
First of all, good job using
next-plugin-preval
I really liked it. But I noticed some duplication in thegetCoreStaticProps
and I saw you left a comment related. My questions is why don't you just do this: https://github.com/UnlyEd/next-right-now/pull/349