data
Dgraph CLI for AI Agents
Use the Dgraph CLI from KosmoKrator to call Dgraph tools headlessly, return JSON, inspect schemas, and automate workflows from coding agents, scripts, and CI.Dgraph CLI Setup
Dgraph can be configured headlessly with `kosmokrator integrations:configure dgraph`.
# Install KosmoKrator first if it is not available on PATH.
curl -fsSL https://raw.githubusercontent.com/OpenCompanyApp/kosmokrator/main/install.sh | bash
# Configure and verify this integration.
kosmokrator integrations:configure dgraph --set bearer_token="$DGRAPH_BEARER_TOKEN" --enable --read allow --write ask --json
kosmokrator integrations:doctor dgraph --json
kosmokrator integrations:status --json Credentials
Authentication type: API token api_token. Configure credentials once, then reuse the same stored profile from scripts, coding CLIs, Lua, and MCP.
| Key | Env var | Type | Required | Label |
|---|---|---|---|---|
bearer_token | DGRAPH_BEARER_TOKEN | Secret secret | yes | Bearer Token |
base_url | DGRAPH_BASE_URL | Text string | no | GraphQL Endpoint URL |
Command Patterns
The generic command is stable across every integration. The provider shortcut is shorter for humans.
kosmo integrations:call dgraph.dgraph_list_schema '{}' --json kosmo integrations:dgraph dgraph_list_schema '{}' --json Discovery
These commands return structured output for coding agents that need to inspect capabilities before choosing a function.
kosmo integrations:docs dgraph --json
kosmo integrations:docs dgraph.dgraph_list_schema --json
kosmo integrations:schema dgraph.dgraph_list_schema --json
kosmo integrations:search "Dgraph" --json
kosmo integrations:list --json Automation Contexts
The same configured command surface works in these environments. The command does not change unless the host wrapper, credentials, or permissions change.
CLI Functions
Every function below can be called headlessly. Commands are highlighted, copyable, and scroll horizontally when payloads are long.
dgraph.dgraph_list_schema
List the full GraphQL schema from Dgraph. Returns all types, their fields, and field types. Useful for understanding the overall data model.
read - Parameters
- none
kosmo integrations:call dgraph.dgraph_list_schema '{}' --json kosmo integrations:dgraph dgraph_list_schema '{}' --json dgraph.dgraph_get_schema
Get the GraphQL schema for a specific type in Dgraph. Returns the type definition including all fields and their types. Provide the type name to inspect.
read - Parameters
- type_name
kosmo integrations:call dgraph.dgraph_get_schema '{"type_name":"example_type_name"}' --json kosmo integrations:dgraph dgraph_get_schema '{"type_name":"example_type_name"}' --json dgraph.dgraph_list_types
List all types defined in the Dgraph GraphQL schema. Returns type names for all user-defined and system types available in the database.
read - Parameters
- none
kosmo integrations:call dgraph.dgraph_list_types '{}' --json kosmo integrations:dgraph dgraph_list_types '{}' --json dgraph.dgraph_list_indexes
List all indexes defined in the Dgraph schema. Returns types with their fields and directives, allowing you to identify indexed fields and their index types (hash, exact, term, fulltext, trigram, etc.).
read - Parameters
- none
kosmo integrations:call dgraph.dgraph_list_indexes '{}' --json kosmo integrations:dgraph dgraph_list_indexes '{}' --json dgraph.dgraph_get_node
Get a specific node from Dgraph by providing its type and ID. Returns the node data including all populated fields. Use the type name as defined in your GraphQL schema.
read - Parameters
- type, id
kosmo integrations:call dgraph.dgraph_get_node '{"type":"example_type","id":"example_id"}' --json kosmo integrations:dgraph dgraph_get_node '{"type":"example_type","id":"example_id"}' --json dgraph.dgraph_mutate
Execute a GraphQL mutation to add or update data in Dgraph. Provide the full GraphQL mutation string and optional variables. Supports all mutation operations including add, update, and upsert.
write - Parameters
- mutation, variables
kosmo integrations:call dgraph.dgraph_mutate '{"mutation":"example_mutation","variables":"example_variables"}' --json kosmo integrations:dgraph dgraph_mutate '{"mutation":"example_mutation","variables":"example_variables"}' --json dgraph.dgraph_drop_mutation
Execute a GraphQL drop/delete mutation to remove data from Dgraph. Provide the full GraphQL mutation string for deleting nodes and optional variables. Use with caution as this permanently removes data.
write - Parameters
- mutation, variables
kosmo integrations:call dgraph.dgraph_drop_mutation '{"mutation":"example_mutation","variables":"example_variables"}' --json kosmo integrations:dgraph dgraph_drop_mutation '{"mutation":"example_mutation","variables":"example_variables"}' --json dgraph.dgraph_query
Execute a custom GraphQL query against Dgraph. Provide the full GraphQL query string and optional variables. Supports all query operations including filtering, pagination, sorting, and nested traversals.
action - Parameters
- query, variables
kosmo integrations:call dgraph.dgraph_query '{"query":"example_query","variables":"example_variables"}' --json kosmo integrations:dgraph dgraph_query '{"query":"example_query","variables":"example_variables"}' --json dgraph.dgraph_get_current_user
Get the current authenticated Dgraph user identity. Verifies the configured bearer token and returns the associated user information including ID, name, and email.
read - Parameters
- none
kosmo integrations:call dgraph.dgraph_get_current_user '{}' --json kosmo integrations:dgraph dgraph_get_current_user '{}' --json Function Schemas
Use these parameter tables when building CLI payloads without calling integrations:schema first.
dgraph.dgraph_list_schema 0 parameters
kosmo integrations:schema dgraph.dgraph_list_schema --json | Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
dgraph.dgraph_get_schema 1 parameters
kosmo integrations:schema dgraph.dgraph_get_schema --json | Parameter | Type | Required | Description |
|---|---|---|---|
type_name | string | yes | The GraphQL type name to retrieve the schema for. |
dgraph.dgraph_list_types 0 parameters
kosmo integrations:schema dgraph.dgraph_list_types --json | Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
dgraph.dgraph_list_indexes 0 parameters
kosmo integrations:schema dgraph.dgraph_list_indexes --json | Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
dgraph.dgraph_get_node 2 parameters
kosmo integrations:schema dgraph.dgraph_get_node --json | Parameter | Type | Required | Description |
|---|---|---|---|
type | string | yes | The GraphQL type of the node (e.g., "User", "Post"). |
id | string | yes | The unique ID of the node to retrieve. |
dgraph.dgraph_mutate 2 parameters
kosmo integrations:schema dgraph.dgraph_mutate --json | Parameter | Type | Required | Description |
|---|---|---|---|
mutation | string | yes | The GraphQL mutation string to execute. |
variables | object | no | Optional variables object for the mutation. |
dgraph.dgraph_drop_mutation 2 parameters
kosmo integrations:schema dgraph.dgraph_drop_mutation --json | Parameter | Type | Required | Description |
|---|---|---|---|
mutation | string | yes | The GraphQL drop/delete mutation string to execute. |
variables | object | no | Optional variables object for the mutation. |
dgraph.dgraph_query 2 parameters
kosmo integrations:schema dgraph.dgraph_query --json | Parameter | Type | Required | Description |
|---|---|---|---|
query | string | yes | The GraphQL query string to execute. |
variables | object | no | Optional variables object for the query. |
dgraph.dgraph_get_current_user 0 parameters
kosmo integrations:schema dgraph.dgraph_get_current_user --json | Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
Permissions
Headless calls still follow the integration read/write permission policy. Configure read/write defaults with
integrations:configure. Add --force only for trusted automation that should bypass that policy.