menu
Channels
Team

Next.js support and only access to via hooks

March 24, 2020 at 12:00am

Next.js support and only access to via hooks

March 24, 2020 at 12:00am (Edited 10 months ago)
Hi, I was tinkering inside the project to investigate how could I help with the "Next.js / server side rendering" support, a partial solution I could get was using https://github.com/FormidableLabs/react-ssr-prepass, and it kinda worked, but React gives a huge warning because the server side version of the page is completely different that the client side one, and if I try to use Suspense it simply doesn't render anything because react-server/dom doesn't support it yet. So the most simple solution was to simply make a wrapper that waits until all the code that will be executed is on the client side, which is basically kill all the server-side rendering functionality,
Then I checked the source code to use Next.js getInitialProps as a starting point to see if it could work, and then I realize that all the interactions with gqless itself are via hooks and context, which you basically can't use in pure async functions like getInitialProps, because it's outside the react render process, so I need a basic guide to how can I interact with gqless without the hooks "useAccessors" and "useFragments" if it's possible.
Thanks, and I really like this project, that's why I want to help.
This is the repository that I'm using to test this functionality btw https://github.com/PabloSzx/Next.js-TypeGraphQL-gqless

March 24, 2020 at 6:48pm
I've had some progress, i comented in its issue https://github.com/samdenty/gqless/issues/44#issuecomment-603369312
  • reply
  • like