bubble-icon
Skip to main content

Hygraph

Hygraph is integrated as a Content Management System. It is used to store all static content and provides a user-friendly interface for managing it.

The magento-graphcms example offers a number of components to render this content in different ways, for example in the form of a page-wide hero banner, a list of USPs or grid of text columns.

This guide covers how to configure Hygraph and how to build rich content pages by adding Hygraph content to pages.

Configuration

To connect your GraphCommerce app to your Hygraph project, you'll need a Hygraph project with the required schema. Clone the demo Hygraph project ↗ as your starting point. Update the variable in the /graphcommerce.config.js file:

hygraphEndpoint: ''
Hygraph API URL. Once logged in, copy it from Project Settings > Api Access > Content API

Adding content to pages

GraphCommerce uses Next.js file-based routing ↗, built on the concept of pages. When a file is added to the /pages directory, it's automatically available as a route. Magento category routes are handled by the /pages/[...url].tsx page.

To add Hygraph content to, for example, a category page, create a Page entry in Hygraph and match the value of the URL field with the route of the page you wish to add content to.

For example, the content of the 'men' Page entry in Hygraph:

Page entry in Hygraph

Is used to add aRowProduct (variant:Grid) and a RowProduct (variant:Backstory component to: http://localhost:3000/men

Content of the RowProduct component

Content of the RowProduct (variant:Backstory component)

Front-end render of the component

Next steps