How Contember API works?

Contember API is a standalone server, which provides an extensive GraphQL API for your data - we call it the Content API. Contember API also provides, what we call a Tenant API which handles authentication and authorization so you can control who and how can access your data.

contember diagram

First you have to tell Contember API, how your data model looks like. So you start defining your project schema. For the most simple blog, imagine it could look something like this ...

// Post.ts
import { SchemaDefinition as def } from '@contember/schema-definition'
export class Post {
title = def.stringColumn().notNull()
publishedAt = def.dateTimeColumn()
content = def.stringColumn().notNull()
}

We use TypeScript for schema definition.

Contember API then creates a table in a PostgreSQL database, where it stores all the data. To save a post using GraphQL API mutation do ...

mutation {
createPost(
data: {
title: "Hello world",
content: "first article stored in Contember!",
publishedAt: "2019-12-11T16:35:06"
}
) {
ok
}
}

To fetch it later:

query {
listPost(filter: {publishedAt: {isNull: false}}) {
title
publishedAt
}
}

Of course, Contember API also works with complex structures and you can define any kind of relations between entities. Please find out more in a chapter defining schema or get started with Contember to install a local instance.