Installing Apollo client

Our first job is to install Apollo into our project.

  1. To add Apollo client to our project, let's install the following packages via npm:
npm install apollo-boost react-apollo graphql
  • apollo-boost contains everything we need to set up our Apollo client
  • react-apollo contains React components we are going to use to interact with the GraphQL server
  • graphql is a core package that we'll use to parse GraphQL queries
  1. We'll also install some TypeScript types as well for graphql:
npm install @types/graphql --save-dev
  1. We need to make sure TypeScript includes the es2015 and esNext libraries when it compiles our code. So, let's add the following lib field to tsconfig.json:
{
"compilerOptions": {
"target": "es5",
"lib": ["es2015", "dom", "esnext"],
...
},
...
}

We now have everything in place to start interacting with the GitHub GraphQL server with Apollo.

..................Content has been hidden....................

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