- Build Assets, Contents, Schemas on GRAPHCMS.
- Get GraphQL endpoint and token, set permissions for all requests.
- Build GQL queries.
- Run them on the playground.
- Start frontend app with React & Next App.
- Install required packages like
graphql-request
. - Access the data from GraphQl API and build the app.
- Test the app on a running Server.
Let's dive into the steps:
First, you need to create your GraphCMS Account then create Assets, Schemas and Contents and their relationships.
Once you are done with Schema and relation building, build GQL queries for data fetching and mutation.
query {
videos {
createdAt,
id,
title,
description,
seen,
slug,
tags,
thumbnail {
url
},
mp4 {
url
}
}
}
query{
videos(where: { id:"ckwyfg18o096k0c05j5bw1bl5"}){
createdAt,
id,
title,
description,
slug,
tags,
thubnail{
url
},
mp4{
url
}
}
}
query {
account(where: { id: "ckwyfc4t4096b0c184nqkh2zq"}) {
username
avatar {
url
}
}
}
For more reference you can have a look into the image below.
After the assets are loaded, add a .env file in root folder with the following:
GRAPH_CMS_TOKEN={your_token}
ENDPOINT={your_endpoint}
npm i
npm run dev
Open http://localhost:3000 with your browser to see the result.
You can start editing the page by modifying pages/index.js
. The page auto-updates as you edit the file.
Enjoy Coding!