In this tutorial, we will develop a simple coin price list using GraphQL API of Upstash. You can call the application
See the code.
We want to give a use case where you can use the GraphQL API without any backend code. The use case is publicly available read only data for web applications where you need low latency. The data is updated frequently by another backend application, you want your users to see the last updated data. Examples: Leaderboards, news list, blog list, product list, top N items in the homepages.
1 Project Setup:#
Create a Next application:
Install Apollo GraphQL client:
npm i @apollo/client
2 Database Setup#
If you do not have one, create a database following this guide. Connect your database via Redis CLI and run:
In the Upstash console, copy the read only access key in your API configuration page (GraphQL Explorer > Configure API). In the
_app.js create the Apollo client and replace the your access key as below:
You need to use Read Only Access Key, because the key will be accessible publicly.
index.js as below:
Run your application locally:
npm run dev
Go to http://localhost:3000/ 🎉