Our first job is to install Apollo into our project.
- 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
- We'll also install some TypeScript types as well for graphql:
npm install @types/graphql --save-dev
- 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.