First of all, I want to tell you I created the tool graphql-zeus it is GraphQL client on top of the fetch function. What it means? Basically, you point Zeus to the GraphQL schema and it generates libraries for you.
Sounds fun? It is even more fun because you don't have to know gql the query language of GraphQL because Zeus provides you with its own GraphQL query like autocompleted syntax.
Create a project folder:
mkdir zeus-tutorial
cd zeus-tutorial
Let's start then. First, you will have to init a new npm package:
npm init
click enter enter enter etc.
Install dev dependencies.
npm i -D @babel/core @babel/node @babel/preset-env
Now it is high time to generate some code from GraphQL. Go ahead install graphql-zeus.
install graphql-zeus
npm i -g graphql-zeus
Generate files from pokemon schema
zeus https://graphql-pokemon.now.sh/ ./src
Hurray! You should have definition files generated in ./src folder.
Now go and open some editor of choice - I prefer VSCode but it is up to you. I can guarantee it works with VSCode though.
Open package directory with editor. Open src/index.js
In the first part of the series, we will write simple query loading first ten pokemon names and images and display it in the terminal.