Contentful logo

Contentful Community

How to reference only part of another model in a model?

Hi, I have a page model that has a bunch of fields and also a reference to another product model. But in the product model that are a lot of other fields that I don’t need when calling the page model.

Say I only need the following in the page model:

page: {
   product: {
     title, description, banner media
   }
}

While the product model has a lot of more fields other than the 3 fields above. Is there a way to use the API to achieve this? Or should I design a separate simplified product model to be referenced in the page model?

Hi @wongbradenyinlok, the idea to create a simplified product is probably the best way. I assume the ‘full product’ will then include the simplified product and the extra data.

However, you could try to use the GraphQL API: GraphQL Content API | Contentful that are designed to query only the data needed.