GraphQL: getting started

Lesson 09 · 11 min

The client: fetch, cache, and updates

A GraphQL request is an ordinary POST. The rest is client-library convenience.

The simplest client is fetch: a POST to /graphql with JSON { query, variables }. The response often has status 200 even with errors, so check both res.ok and the errors field. Libraries like Apollo Client or urql add a cache: they normalize responses by __typename + id, so a book updated by a mutation changes at once in every list on the page.

Sign in to continue

The rest of this lesson opens after sign up

The first lesson of every course is open without an account. To read on, solve the practice and use Ask, create a free account or log in.