Company
Date Published
Author
Lewis Chung
Word count
1813
Language
English
Hacker News points
None

Summary

Server-side rendering (SSR) in React with GraphQL enables faster load times by pre-rendering HTML on the server instead of waiting for client initialization. This is achieved through two phases: an asynchronous phase that fetches data and a synchronous phase to render markup. React Apollo, a package for managing GraphQL in React applications, achieves this through its tree walk algorithm, which crawls the component tree to find queries and resolves them before rendering the UI. The package also offers batching to reduce the number of HTTP calls to the API server. For incremental migration from existing SSR applications that use other data fetching styles, React Apollo can be used by abstracting data loading into higher-order components or using its `asyncAction` feature to adapt Flux data. This allows developers to leverage GraphQL without rewriting their entire application.