data
Dgraph CLI for Shell Scripts
Use the Dgraph CLI for shell scripts with headless JSON commands, schema discovery, credentials, and permission controls.
9 functions 6 read 2 write API token auth
Dgraph CLI for Shell Scripts
Call integration functions from shell scripts with stable JSON input and output.
Use shell scripts for small local automations that need one or more integration calls. The Dgraph CLI uses the same integration registry as the TUI, Lua runtime, and MCP gateway, but returns predictable command output for automation.
Command Shape
# Dgraph CLI for Shell Scripts
kosmokrator integrations:configure dgraph --set bearer_token="$DGRAPH_BEARER_TOKEN" --enable --read allow --write ask --json
kosmo integrations:call dgraph.dgraph_list_schema '{}' --json Discovery Before Execution
Agents and scripts can inspect Dgraph docs and schemas 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 Useful Dgraph CLI Functions
| Function | Type | Parameters | Description |
|---|---|---|---|
dgraph.dgraph_list_schema | Read | none | List the full GraphQL schema from Dgraph. Returns all types, their fields, and field types. Useful for understanding the overall data model. |
dgraph.dgraph_get_schema | Read | type_name | 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. |
dgraph.dgraph_list_types | Read | none | List all types defined in the Dgraph GraphQL schema. Returns type names for all user-defined and system types available in the database. |
dgraph.dgraph_list_indexes | Read | none | 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.). |
dgraph.dgraph_get_node | Read | type, id | 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. |
dgraph.dgraph_mutate | Write | mutation, variables | 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. |
dgraph.dgraph_drop_mutation | Write | mutation, variables | 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. |
dgraph.dgraph_query | action | query, variables | 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. |
dgraph.dgraph_get_current_user | Read | none | Get the current authenticated Dgraph user identity. Verifies the configured bearer token and returns the associated user information including ID, name, and email. |
Automation Notes
- Use
--jsonfor machine-readable output. - Keep credentials out of argv by using environment variables or stored KosmoKrator configuration.
- Configure read/write policy before unattended runs; use
--forceonly for trusted automation. - Use the MCP gateway instead when the agent needs dynamic tool discovery inside a conversation.