Defining GraphQL queries and generating code using Apollo

As we will soon see, the code generation feature of Apollo GraphQL is one of its big advantages. Thanks to this, we will be able to ensure that the queries we write on the client-side are valid. They will be checked against the server-side GraphQL schema. Also, TypeScript interfaces will be generated for the queries and their parameters, allowing us to write type-safe code while interacting with the backend GraphQL API.

We will make our code evolve one step at a time:

  1. First, we're going to prepare our GraphQL queries.
  2. Then, we will use the Apollo CLI to generate TypeScript code.
  1. After that, we will create an Apollo Client inside of the Home page.
  2. Finally, we will use the client ...

Get Learn TypeScript 3 by Building Web Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.