Root Objects

At the root of the schema, you'll find the core objects that power TakeShape projects.

shapes

A Shape is a schema object for structuring and storing data from one or more sources, including the TakeShape data store and connected services.

All shapes exist inside the root-level schema object shapes. Each shape is defined by an object key, an id field, and a name field.

The additional field title is used for presenting the shape in UIs.

Shapes contain an inner schema that configures their properties. Like the rest of the schema, this is designed to be a flattened object. Instead of deeply nested and potentially repeated objects, complex structures are achieved through linking with the @refargs and @relationship annotations.

Shape schemas also have a number of underscore prefixed properties that are automatically managed by TakeShape, such as _created and _updated to record the dates shape items are created and edited.

Shapes can also be extended by use of the allOf keyword. This is most useful when working with remote shapes where you can't modify the original shape, but want to add specific properties. See the example below.

Guides

services

By connecting new Services to your project schema, you can add shapes, queries, and mutations from 3rd party sources to your API in TakeShape. This allows you to mesh together exactly the API you need to interact with all of the services your app or business depends upon.

Services use an encrypted configuration to keep auth tokens secret. For this reason, services can only be added to a schema through the web client or through the Admin API.

Guides

Adding GraphQL services, shapes, and queries

Adding REST services, shapes, and queries

queries & mutations

Queries and Mutations in your schema map directly to queries and mutations in your project's GraphQL API. In the schema you can define behaviors for these queries and mutations that span one or more services.

Though they describe different functionality, query and mutation objects both have the same set of properties:

Guides

Working with Queries & Mutations

forms

Forms ****define a visual interface for editing Shapes.

workflows

Workflows describe the status of a shape item. Every schema starts with a default workflow with two steps, Disabled and Enabled.

Each step can be configured to have a custom name, title, and color. Steps have a live value to indicate whether items in the state should be returned in list queries.

Developer plans are limited to the default workflow. Professional projects can add new workflows and specify them on a per-shape basis. Learn more about professional plans

locales

Locales are an array of IETF language tags your project supports for internationalization. By default, projects have a single en locale which is also the default locale.

Developer projects are limited to 2 locales. Professional projects can have up to 5 locales. Learn more about professional plans

Metadata Properties

Also at the root of the schema are a number of properties that are mainly used by the web client and API. As a schema author, you should almost never need to edit these fields.

version

This is the revision number of your schema. Every time your project schema is updated, this value should be incremented. The version is used to identify versions in your schema's history.

projectId

The ID of the TakeShape project this schema belongs to.

defaultLocale

The locale that should be preferred when creating new Shape items. This must be an entry in the **locales** array.

author

The ID of the TakeShape user who created the schema.

created

The date the schema was created

updated

The date the schema was last updated

schemaVersion

The version of the schema format your project is using. We increase the version as we make breaking changes to the schema format. The current version is 3.

apiVersion

The version of the TakeShape API your project is using. We increase the version as we make breaking changes to the API endpoints.The current version is 2.

Resolvers

A resolver is a function that executes when a query or mutation is called, or a shape field is accessed. A resolver is required on queries & mutations, and may be used in a shape property.

export interface BasicResolver {
  name: string;
  service: string;
  argsMapping?: DirectiveMap | DirectiveConfig[];
  resultsMapping?: DirectiveMap | DirectiveConfig[];
  options?: {
    model?: string;
    [k: string]: any;
  };
}

Argument and results mappings are defined using directives, which are a composable pipelines of function. Each directive is a two-element array, which combines an operation like "get" or "set" with a configuration.

Resolver types

TakeShape provides a library of built-in resolvers when you're writing your own queries and mutations.

GraphQL resolvers

When writing queries and mutations that use a GraphQL service, you'll have access to two resolvers that execute queries and mutations on the connected service.

graphql:query
graphql:mutation

Options:

REST resolvers

When writing queries and mutations that use a REST service, you'll have access to resolvers that execute many of the standard HTTP request methods on the connected service.

rest:get
rest:head
rest:post
rest:put
rest:patch
rest:delete

Options:

TakeShape Resolvers

There are also TakeShape-specific resolvers that allow you to execute common CRUD actions on model-annotated shapes.

takeshape:get
takeshape:list
takeshape:create
takeshape:update
takeshape:delete
takeshape:duplicate

Options:

Resolver composition

A resolver can compose multiple resolvers in a pipeline of resolution steps.

Each resolver in the compose array is executed serially and referable by its id property.

id property

On any resolver step you can provide an id property which gives you a stable, easy-to-use identifier for use in your expressions and directives.

currentQuery context

The context of a query is available for use in directives and expressions. The context is comprised of:

Core Concepts