Skip to main content
Version: 0.2.x

Creating Composites

Composites are the abstraction ComposeDB tools and client use to represent and manipulate data models used by applications.

In order to create new composites, especially to create new models that do not already exist on the Ceramic network, a high-level schema can be used as an abstraction for the composite structure.

Composite schema

The recommended way to create composites including new models is to use a schema file based on GraphQL, described in the dedicated documentation page.

Converting a schema to a composite

After a schema file has been created, it must be converted to a composite to be usable by the other tools and client.

Make sure you have the composedb packages installed, before running the code below.

In order to create a Composite using the API, you also need to have an authenticated DID instance. You can use the did-session package from js-did to achieve this: DIDSession.DID Documentation

import { CeramicClient } from '@ceramicnetwork/http-client'
import { createComposite, writeEncodedComposite } from '@composedb/devtools-node'

// Replace by the URL of the Ceramic node you want to deploy the models to
const ceramic = new CeramicClient('http://localhost:7007')

ceramic.setDID(<Authenticated DID instance>)

// Replace by the path to the source schema file
const composite = await createComposite(ceramic, 'source-schema.graphql')

// Replace by the path to the encoded composite file
await writeEncodedComposite(composite, 'my-composite.json')

More details: createComposite, writeEncodedComposite