This is not an in depth tutorial, if you want to follow a step by step guide, have a look at the official doc
The goal of this exercise was for me to investigate/discover how hard/easy it would be to start using GraphQL.
Lets create an Apollo Server with NodeJS so we can play with GraphQL. The server will distribute data retrieved from the nintendo eshop (cause why not
Create the project
Add the dependencies
npm install apollo-server-express express
Create the base code
Copy/paste the following into an
node index.js and you’ll have access to GraphQL Playground at
Lets define our types now. So we need to add a type to our
And we need to change our Query to return a list of games:
For this to work we obviously need to do a http request in order to get all titles.
That’s when we need to define a
datasource (doc here).
npm install apollo-datasource-rest
Now go back to the main file to specify it in the ApolloServer constructor:
And now you can get the list of games:
If you want more GraphQL example, look at the SpaceX tutorial which uses a REST API and a SqlLite DB.