-
-
Notifications
You must be signed in to change notification settings - Fork 54
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
feature request: support calling prepareReactRender client-side #168
Comments
I don't think we should be using getInitialProps, it is there in apollo from legacy, from before getServerSideProps and getStaticProps existed.
Exactly, it's not mean to be client-side, but maybe the strange behavior you saw is from the bad decision I made when I created "prepareRender" of overwriting the cache instead of simply merging it. It's important to also note that executing that code client-side you are shipping ton of code to the browser that doesn't actually need it at all. The only good think about using getInitialProps is being able to keep the routing logic without those hacky tips I added in the docs, and maybe it could be good for those specific use-cases, but we also have to remember that gqless-react is not meant to be Next.js exclusive at all, and the current design is framework-agnostic. |
If you want make some ready-to-use code around the existing code (after #169 is merged), for specific Next.js getInitialProps use, you are very welcome, and we could add it in a specific Next.js page in the docs. PS: In client side navigation gqless should work as normal, you shouldn't need to do any preparation through getInitialProps |
Using Next.js's
getInitalProps
can offer us some advantages over usinggetServerSideProps
:cacheSnapshot
doesn't need to be deserialized for the final server-side render.But it looks like the
prepareReactRender
function is not meant to be called client-side? I noticed some strange behavior when callingprepareReactRender
client-side in mygetInitialProps
.In my demo, if you go to the films page, open the network tab in chrome devtools, and then navigate to the planets page, you will see that once the "planets" query request completes, the page navigation happens, and the previous page's query ("films") is requested again. I think this has to do with the fact that
prepareReactRender
clears the client's cache before doing it's thing (behavior identified #165), but I'm not 100%. I know thatuseHydrateCache
has nothing to do with it because I can remove that call and the described behavior (of client-side navigation) remains.The text was updated successfully, but these errors were encountered: