10 Using GraphQL APIs with Apollo client

 

This chapter covers

  • Using Apollo Client in plain JavaScript and React
  • Understanding Apollo’s links and cache
  • Using Apollo’s hook functions for queries and mutations
  • Managing local app state with Apollo
  • Implementing and using GraphQL subscriptions over WebSockets

Shortly after GraphQL implementations started getting attention on GitHub, another class of GraphQL libraries began to attract notice as well: client libraries.

GraphQL client libraries are designed to manage communications between frontend applications and backend GraphQL services. A client library abstracts the tasks of asking a GraphQL service for data, instructing it to do mutations, and making its data responses available to the view layer of a frontend application.

Just as a GraphQL service can be thought of as an agent that does all the communication with your databases, a GraphQL client can be thought of as an agent that does all the communication with your GraphQL services.

Many GraphQL client libraries also have server components to enrich the server experience and support common frontend application requirements like caching, paginating through lists, and using real-time data.

10.1 Using Apollo Client with JavaScript

 

10.1.1 Making a query request

 
 
 

10.1.2 Making a mutation request

 
 
 
 

10.2 Using Apollo Client with React

 
 
 
 

10.2.1 Using the query and mutate methods directly

 
 
 

10.2.2 Including authentication headers

 

10.2.3 Using Apollo hook functions

 
 

10.2.4 Using the automatic cache

 
 
 

10.2.5 Manually updating the cache

 
 
 

10.2.6 Performing operations conditionally

 

10.3 Managing local app state

 

10.4 Implementing and using GraphQL subscriptions

 
 

10.4.1 Polling and refetching

 
 
 
 

10.4.2 Implementing subscriptions

 
 
 

10.4.3 Apollo Server

 
 
 

10.4.4 Using subscriptions in UIs

 
 

Summary

 
 

Wrapping up

 
 
sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage