Class: ComposeClient
client.ComposeClient
The ComposeClient class provides APIs to execute queries on a GraphQL schema generated from a
RuntimeCompositeDefinition
. It allows applications to interact with documents using known
models on a Ceramic node.
It is exported by the client
module.
import { ComposeClient } from '@composedb/client'
Constructors
constructor
• new ComposeClient(params
)
Parameters
Name | Type |
---|---|
params | ComposeClientParams |
Accessors
context
• get
context(): Context
Context instance used internally.
Returns
did
• get
did(): undefined
| DID
DID instance used internally by the Ceramic client instance.
Returns
undefined
| DID
id
• get
id(): null
| string
ID of the DID attached to the Ceramic client instance used internally. If null
, the
Ceramic instance is not authenticated and mutations will fail.
Returns
null
| string
resources
• get
resources(): string
[]
CACAO resources URLs for the models the client interacts with.
Returns
string
[]
Methods
execute
▸ execute(document
, variableValues?
): Promise
<ExecutionResult
<ObjMap
<unknown
>, ObjMap
<unknown
>>>
Execute a GraphQL query from a DocumentNode and optional variables.
Parameters
Name | Type |
---|---|
document | DocumentNode |
variableValues? | Record <string , unknown > |
Returns
Promise
<ExecutionResult
<ObjMap
<unknown
>, ObjMap
<unknown
>>>
executeQuery
▸ executeQuery(source
, variableValues?
): Promise
<ExecutionResult
<ObjMap
<unknown
>, ObjMap
<unknown
>>>
Execute a GraphQL query from its source and optional variables.
Parameters
Name | Type |
---|---|
source | string | Source |
variableValues? | Record <string , unknown > |
Returns
Promise
<ExecutionResult
<ObjMap
<unknown
>, ObjMap
<unknown
>>>
setDID
▸ setDID(did
): void
Attach the given DID instance to the Ceramic client instance used internally. An authenticated DID instance is necessary to perform GraphQL mutations.
Parameters
Name | Type |
---|---|
did | DID |
Returns
void