jaydenseric / graphql-react

A GraphQL client for React using modern context and hooks APIs that is lightweight (< 4 kB) but powerful; the first Relay and Apollo alternative with server side rendering.
https://npm.im/graphql-react
MIT License
717 stars 22 forks source link

SSR on PHPv8js #20

Closed helloguille closed 5 years ago

helloguille commented 5 years ago

Your library is the one I have been looking for months! I just cannot afford big bundle sizes in my web app!

Is there any way to run this as a normal sync function?

let str = ssr(graphql, page);

This is to make SSR easier with php-v8js

jaydenseric commented 5 years ago

This is to make SSR easier with php-v8js

Interesting usage :)

Is there any way to run this as a normal sync function?

No; the whole point is to recursively wait for all the queries to resolve to finally render the page in it's completely loaded state.

https://github.com/jaydenseric/graphql-react/blob/next/src/server/ssr.mjs#L86

If you want to do a sync render without loading any of the queries, you can use ReactDOMServer.renderToStaticMarkup or ReactDOMServer.renderToString directly without using the graphql-react ssr() function.

helloguille commented 5 years ago

Thanks for your answer. I will try the strategies you have kindly described.

jaydenseric commented 5 years ago

And keep in mind that I have a big update coming to everything in the next branch 🚢