Overview
To view this content, buy the book! 😃🙏
Or if you’ve already purchased.
Chapter 6: React
Chapter contents:
Background: single-page application, HTTP, Node, git, JSON, JavaScript, React
In this chapter, we’ll learn to use the @apollo/client
library through building the Guide web app—the code behind the https://graphql.guide site, where we can sign in, read the book, and write reviews. We’ll go through setup, simple queries, complex queries, auth, and mutations for creating, updating, and deleting. Then we’ll cover advanced topics like infinite scrolling, local state, SSR, working offline, and performance. Here’s what it will look like:
We’ll be using Apollo’s hooks API. For an older version of this chapter that uses Apollo’s render prop and higher-order component APIs or the Apollo Client 2.* cache API, see version r5
of the Guide:
We recommend Apollo for its flexibility, ease of use, documentation, and ecosystem. The main alternative is Relay, which is more opinionated—it requires fragments colocated with components, specific ways of working with errors, and a certain format for the server schema, including
Node
s, universally uniqueid
s, connections for pagination, and mutation structure. It also requires use of the Relay compiler. For more info on these differences, check out this Twitter thread and this post.