Skip to main content
Version: 0.7.x

Module: runtime

ComposeDB runtime module, converting a runtime composite to an executable GraphQL schema.

Installation

npm install @composedb/runtime

Classes

Type Aliases

ComposeRuntimeParams

Ƭ ComposeRuntimeParams: GetSchemaParams & { cache?: DocumentCache | boolean ; ceramic: CeramicAPI | string ; context?: Context ; loader?: DocumentLoader }


Context

Ƭ Context: Object

Type declaration

NameTypeDescription
ceramicCeramicAPICeramic client instance used internally.
enableDocIndexing(id: string, shouldIndex: boolean, opts?: UpdateOpts) => Promise<void>Enable indexing for an existing document.
getViewerID() => string | nullID of the current viewer (authenticated DID), if set.
isAuthenticated() => booleanReturns whether the Ceramic client instance used internally is authenticated or not. When not authenticated, mutations will fail.
loadDoc<Content>(id: string | CommitID | StreamID, fresh?: boolean) => Promise<ModelInstanceDocument<Content> | null>Load a document by ID, using the cache if possible.
loaderDocumentLoaderDocument loader instance used internally.
queryCount(query: BaseQuery) => Promise<number>Query the index for the total number of documents matching the query parameters.
upsertSet<Content>(model: string, unique: string[], content: Content, options?: UpsertOptions) => Promise<ModelInstanceDocument<Content> | null>Create or update a document using the SET account relation with the given model, content and unique fields value.
upsertSingle<Content>(model: string, content: Content, options?: UpsertOptions) => Promise<ModelInstanceDocument<Content> | null>Create or update a document using the SINGLE account relation with the given model and content.

ContextParams

Ƭ ContextParams: Object

Type declaration

NameTypeDescription
cache?DocumentCache | booleanOptional cache for documents.
ceramicCeramicAPICeramic client instance.
fallbackViewerID?string | nullFallback viewer ID to use when the Ceramic instance is not authenticated.

GetSchemaParams

Ƭ GetSchemaParams: Object

Type declaration

NameTypeDescription
definition?RuntimeCompositeDefinitionRuntime composite definition, created using the Composite development tools.
readonly?booleanSet the schema to read-only, disabling mutations support.
schema?GraphQLSchemaGraphQL Schema to use, ignores the definition and readonly parameters if provided.

Functions

createContext

createContext(params): Context

Parameters

NameType
paramsContextParams

Returns

Context


createGraphQLSchema

createGraphQLSchema(params): GraphQLSchema

Create a GraphQL schema from a runtime composite definition

Parameters

NameType
paramsCreateSchemaParams

Returns

GraphQLSchema


getSchema

getSchema(params): GraphQLSchema

Use or create a GraphQL schema based on the provided parameters.

Parameters

NameType
paramsGetSchemaParams

Returns

GraphQLSchema


printGraphQLSchema

printGraphQLSchema(definition, readonly?): string

Create a GraphQL schema from a runtime composite definition and return its string representation.

Parameters

NameTypeDefault value
definitionRuntimeCompositeDefinitionundefined
readonlybooleanfalse

Returns

string