Hygraph
Docs

#Content modeling walkthrough

This walkthrough takes you through the full content modeling process using a bookshop website as an example. Starting with research and stakeholder interviews, you will build a domain model with your team and then translate it into a working Hygraph schema. Following this method produces a schema that is structured, scalable, and straightforward for both editors and developers to work with.

#Prerequisites

#Step 1: Research and discovery

Content modeling starts with research, not with the schema editor.

For this example, imagine you have been asked to build a content model for a chain of bookshops. Start with desk research to understand how bookshop websites typically structure their content. This would include book details, genres, authors, reviews, and so on.

Once you have a basic understanding, interview key stakeholders:

  • Content creators to understand how they enter book details, manage inventory, and create content day-to-day.
  • Sales team to learn what information supports the purchasing decision and how customers interact with the site.
  • Developers to understand technical requirements, preferred stack, and how content needs to be structured for performance.
  • Marketing team to identify what drives engagement and what promotional content needs to be supported.

After your research and interviews, compile a list of terms that will form the foundation of your content model:

  • Books
  • Authors
  • Genres
  • Reviews
  • Price
  • ISBN
  • Availability
  • Promotions

#Map the relationships

With your terms defined, think through how these concepts relate to each other:

  • Each Book is written by one or more Authors.
  • Each Book belongs to one or more Genres.
  • Each Book may have multiple Reviews.
  • Each Book has a single ISBN.
  • Each Genre may be associated with multiple Books and Authors.
  • Each Book has a Price.

Next, separate object domains (things that will become models) from attributes (values that describe an object). Price, ISBN, and Availability are attributes of Book, not models in their own right.

#Step 2: Build the domain model

Bring your cross-functional team together to build a domain model, which is a high-level picture of the entire business, its key objects, and the relationships between them.

The domain model is broader than what you will put into Hygraph. It covers the full scope of the business, including operational areas that are not directly relevant to the website.

Here is a domain model for the bookshop:

Object domainAttributes
BooksTitle, ISBN, price, availability, summary, cover image
AuthorsName, biography, photo
GenresName, description
ReviewsUser name, rating, review text
PromotionsDiscount name, description, amount, active period
Store locationsShop name, address, contact details, operating hours
Employee managementEmployee name, role, shift schedule, contact information
SuppliersSupplier name, contact information, order history, contracts

Here are the key relationships:

ObjectsRelationship
Books and AuthorsA book is written by one or more authors. An author can write multiple books.
Books and GenresA book belongs to one or more genres. A genre can contain multiple books.
Books and ReviewsA book can have multiple reviews. A user can review multiple books.
Books and PromotionsA book can be associated with one or more active promotions. A promotion can apply to multiple books.
Books and SuppliersA supplier provides one or more books. A book may be sourced from multiple suppliers.
Store locations and BooksA store location stocks multiple books. A book may be available in multiple locations.
Suppliers and Store locationsA supplier provides stock to one or more locations. A store location receives stock from multiple suppliers.
Promotions and Store locationsA promotion may apply to specific locations. A store location may have multiple active promotions.

#Step 3: Build the schema

With a domain model in hand, identify which parts belong in Hygraph. In Hygraph, object domains become models and attributes become fields.

Here is the high-level schema:

  • Book model: Title, ISBN, Price, Summary, Availability, Book cover, Genres (reference), Author (reference), Promotion (component field)
  • Author model: Name, Biography, Photo, Books (reference), Genres (reference)
  • Genre model: Name, Description, Books (reverse reference), Authors (reverse reference)

The sections below define each model in detail.

#Book model

The Book model is the primary content type on the bookshop website.

FieldTypeDescription
titleSingle line textThe book's title
isbnSingle line textA unique identifier for the book
priceFloatThe book's price
summaryRich textA description of the book
availabilityBooleanWhether the book is currently in stock
bookCoverAsset pickerThe book's cover image
genresReference (two-way)Links to one or more Genre entries
authorReference (two-way)Links to one or more Author entries
promotionBasic componentAdds a promotion component to the entry

#Promotion component

The promotion component is a reusable group of fields attached to the Book model. Because it is a component, the same definition can be reused on other models without duplicating the field setup.

FieldTypeDescription
nameSingle line textThe promotion's name
discountEnumerationA predefined list of discount values
descriptionRich textA description of the promotion
imageAsset pickerAn image associated with the promotion

#Author model

The Author model stores information about book authors.

FieldTypeDescription
nameSingle line textThe author's full name
biographyRich textA biographical description
photoAsset pickerA profile image
booksReference (two-way)Links to one or more Book entries
genresReference (two-way)Links to one or more Genre entries

#Genre model

The Genre model stores genre definitions and connects to both books and authors through reference fields.

FieldTypeDescription
nameSingle line textThe genre name. For example, Fiction or Non-Fiction
descriptionRich textAdditional information about the genre
booksReference (reverse)Reverse field of the genres reference on Book
authorsReference (reverse)Reverse field of the genres reference on Author

#What's next

You now have a schema that reflects a structured, scalable approach to content modeling. Editors can create entries efficiently, and developers can query the Content API with confidence because the relationships are explicit and field types are predictable.

ResourceDescription
Getting Started tutorialBuild a project from scratch, from schema design to frontend implementation.
Hygraph recipesExplore common schema patterns and field configurations.
Implementation guidesStep-by-step guides for connecting your Hygraph project to a frontend.
Integration guidesFind out how third-party apps integrate with Hygraph to extend your project.