Hygraph is a headless CMS similar to ButterCMS which also provides GraphQL API to manage and distribute your content across multiple platforms. If you don’t know what GraphQL is, you can check it out here. The integration of GraphQL in a headless CMS makes it much more easier to access and deliver content.
Let’s find out how you can make use of Hygraph with GraphQL.
#1. Getting Started With Hygraph
The first thing that you need to is register on Hygraph.
Once registered, the first thing that you need to do is create a model.
Once model is created, you need to add the fields that you will be using for your content.
Note that based on the name you provide for each field an API Id also gets created.
Once you have created the model, you will need to add some content for each of the fields like below.
You can also check out the built-in GraphiQL API Explorer to see how it looks.
#2. API Setting
The next thing that you need to do is configure the API settings. Depending upon on how you want to access the data you can set the configuration. I configured it to be able to only read data and for content that is published.
You will also get a unique endpoint for your project which you can use.
#3. Testing The Endpoints Of Hygraph
If you want to test the endpoint via a GraphQL IDE, you can download GraphQL Playground. It’s available for Mac, Windows and Linux.
#4. Permanent Authentication Tokens
Once you have verified that your endpoint works, you can also create a PAT. Once you create a PAT, you can then use the token to make GraphQL API calls.
You can test the token either via curl or Javascript using the token. You can find out more here.
Conclusion
Integrating a headless CMS with GraphQL not only makes it easier to manage and distribute content but also speeds up the development process for developers. GraphQL is a flexible and versatile query language which makes it easy to retrieve data.
Have already used Hygraph or GraphQL ? You can share your views with us in the comment section below.