Content Composition
Since version 3.11
References
For more detailed information, check out:
Introduction
Content Composition is a powerful feature that allows you to create reusable building blocks for your content. It helps you:
- Build modular and maintainable content structures
- Implement type-safe GraphQL fragments
- Create flexible page layouts using composable components
This guide will walk you through implementing content composition in your Front-Commerce application.
Prerequisites
Before starting, make sure you:
- Have a Front-Commerce application set up
- Understand how to register an extension
- Understand file-based routing in Remix
- Know how to load data from the GraphQL schema
- Are familiar with GraphQL fragments
- Understand React components basics
Tutorial
Advanced Usage
Overriding Existing Compositions
You can override existing compositions by registering a new composition with the same name:
composition.register("Wysiwyg", [
{
name: "DefaultWysiwyg",
client: {
component: new URL("./components/DefaultWysiwyg.tsx", import.meta.url),
fragment: /* GraphQL */ `
fragment DefaultWysiwygFragment on DefaultWysiwyg {
childNodes
data {
dataId
}
customField // Add new fields
}
`,
},
},
]);
tip
When overriding compositions, the last registered extension takes precedence, but all compositions are merged together.