Interacting with GraphQL APIs

GraphQL is an open source web API language for reading and writing data that is maintained by Facebook. It allows the client to specify exactly what data is returned and request multiple data areas in a single request. This efficiency and flexibility makes it a compelling alternative to a REST API. GraphQL also supports both reading and writing data.

In this chapter, we'll start by experimenting with some GraphQL queries against GitHub to get familiar with the syntax by using the GitHub GraphQL API explorer. We'll explore how we both read and write GraphQL data and how to specify exactly the way we want the data in the response returned to us.

We'll then consume the GitHub GraphQL server in a React and TypeScript application to build a little app that searches for a GitHub repository and returns some information about it. We'll use our knowledge from the last chapter on axios to interact with the GitHub GraphQL server to start off with. We'll then switch to using Apollo, which is a client library that makes interacting with GraphQL servers a breeze.

We'll cover the following topics in this chapter:

  • GraphQL query and mutation syntax
  • Using axios as a GraphQL client
  • Using Apollo GraphQL client
  • Working with cached data in Apollo
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.223.172.252