The v25 release of Dgraph introduces new features and brings the full code base under the Apache-2.0 license, reducing barriers for teams of all sizes to choose Dgraph for AI-ready knowledge graphs.

Availability

As we prepare for the general availability, we’re making a set of preview releases available for use on Hypermode and locally. The fastest way to get started is to sign up for a free Hypermode account.

The run locally, use the Docker image dgraph/standalone:v25.0.0-preview4.

docker run --rm -it -p 8080:8080 -p 9080:9080 dgraph/standalone:v25.0.0-preview4

Features

The following new features are currently available in the preview release:

  • Namespaces – logically isolate environments for multi-customer apps
  • v2 APIs – write less code with simplified client creation and DQL execution
  • Model Context Protocol (MCP) Server – stay in flow by making your Dgraph schema and queries available to your AI coding assistants

Additionally, the following former enterprise features are available in the preview release with no license key required:

Upcoming preview releases include a simplified import command and native user authentication and authorization (formerly Access Control Lists).

The APIs in the preview release are subject to minor changes before general availability. Please share feedback via Discord or GitHub.

Namespaces

Namespaces allow you to create logically separated environments for your data, enabling multi-customer apps without the overhead of managing a database per customer.

The default namespace is created when the cluster is provisioned. It is named root.

Namespace APIs are part of the v2 APIs. The v2 APIs are available in the dgo/v250 package today. Other SDKs are being updated currently.

Creating a new namespace

To create a namespace, use the CreateNamespace function.

err := client.CreateNamespace(context.TODO(), "finance-graph")
// handle error

You can now pass this name to SetSchema, RunDQL or similar functions.

Dropping a namespace

To drop a namespace, use the DropNamespace function.

err := client.DropNamespace(context.TODO(), "finance-graph")
// handle error

Rename a namespace

To rename a namespace, use the RenameNamespace function.

err := client.RenameNamespace(context.TODO(), "finance-graph", "new-finance-graph")
// handle error

List all namespaces

To list all namespaces, use the ListNamespaces function.

namespaces, err := client.ListNamespaces(context.TODO())
// handle error
fmt.Printf("%+v\n", namespaces)

v2 APIs

Version 25 introduces support for v2 APIs, including simpler client creation and DQL execution. The v2 APIs are available in the dgo/v250 package today. Other clients are being updated currently.

Open a connection

The dgo package supports connecting to a Dgraph cluster using connection strings. Dgraph connection strings take the form dgraph://host:port?arguments with support for the following arguments:

ArgumentValueDescription
bearertoken<token>an access token
sslmodedisable
require
verify-ca
TLS option, the default is disable. If verify-ca is set, the TLS certificate configured in the Dgraph cluster must be from a valid certificate authority.

To create a client, use the Open function with a connection string.

// open a connection to a non-TLS cluster
client, err := dgo.Open("dgraph://localhost:9080")
// handle error
defer client.Close()
// use the clients

Advanced client creation

For more control, you can create a client using the NewClient function.

client, err := dgo.NewClient("localhost:9080",
  // add insecure transport credentials
  dgo.WithGrpcOption(grpc.WithTransportCredentials(insecure.NewCredentials())),
)
// handle error
defer client.Close()
// use the client

You can connect to multiple alphas using NewRoundRobinClient.

client, err := dgo.NewRoundRobinClient([]string{"localhost:9181", "localhost:9182", "localhost:9183"},
  // add insecure transport credentials
  dgo.WithGrpcOption(grpc.WithTransportCredentials(insecure.NewCredentials())),
)
// handle error
defer client.Close()
// use the client

Connect to Hypermode Graph

You can use either Open or NewClient to connect to a Hypermode Graph. Hypermode automatically handles load balancing in multi-node clusters.

Using Open with a connection string:

client, err := dgo.Open("dgraph://<graph-workspace>.hypermode.host?sslmode=verify-ca&bearertoken=<bearer-token>")
// handle error
defer client.Close()

Using NewClient:

client, err := dgo.NewClient("<graph-workspace>.hypermode.host:443",
  dgo.WithBearerToken("<bearer-token>"),
  dgo.WithSystemCertPool(),
)
// handle error
defer client.Close()

Set schema

To set the schema, use the SetSchema function.

sch := `
  name: string @index(exact) .
  email: string @index(exact) @unique .
  age: int .
`
err := client.SetSchema(context.TODO(), dgo.RootNamespace, sch)
// handle error

Run a mutation

To run a mutation, use the RunDQL function.

mutationDQL := `{
  set {
    _:alice <name> "Alice" .
    _:alice <email> "alice@example.com" .
    _:alice <age> "29" .
  }
}`
resp, err := client.RunDQL(context.TODO(), dgo.RootNamespace, mutationDQL)
// handle error
// print map of blank UIDs
fmt.Printf("%+v\n", resp.BlankUids)

Run a query

To run a query, use the same RunDQL function.

queryDQL := `{
  alice(func: eq(name, "Alice")) {
    name
    email
    age
  }
}`
resp, err := client.RunDQL(context.TODO(), dgo.RootNamespace, queryDQL)
// handle error
fmt.Printf("%s\n", resp.QueryResult)

Run a query with variables

To run a query with variables, using RunDQLWithVars.

queryDQL = `query Alice($name: string) {
  alice(func: eq(name, $name)) {
    name
    email
    age
  }
}`
vars := map[string]string{"$name": "Alice"}
resp, err := client.RunDQLWithVars(context.TODO(), dgo.RootNamespace, queryDQL, vars)
// handle error
fmt.Printf("%s\n", resp.QueryResult)

Run a best effort query

To run a BestEffort query, use the same RunDQL function with TxnOption.

queryDQL := `{
  alice(func: eq(name, "Alice")) {
    name
    email
    age
  }
}`
resp, err := client.RunDQL(context.TODO(), dgo.RootNamespace, queryDQL, dgo.WithBestEffort())
// handle error
fmt.Printf("%s\n", resp.QueryResult)

Run a read-only query

To run a ReadOnly query, use the same RunDQL function with TxnOption.

queryDQL := `{
  alice(func: eq(name, "Alice")) {
    name
    email
    age
  }
}`
resp, err := client.RunDQL(context.TODO(), dgo.RootNamespace, queryDQL, dgo.WithReadOnly())
// handle error
fmt.Printf("%s\n", resp.QueryResult)

Run a query with RDF response

To get the query response in RDF format instead of JSON format, use the following TxnOption.

import (
  "github.com/dgraph-io/dgo/v250"
  "github.com/dgraph-io/dgo/v250/protos/api_v2"
)

queryDQL := `{
  alice(func: eq(name, "Alice")) {
    name
    email
    age
  }
}`
resp, err = client.RunDQL(context.TODO(), dgo.RootNamespace, queryDQL, dgo.WithResponseFormat(api_v2.RespFormat_RDF))
// handle error
fmt.Printf("%s\n", resp.QueryResult)

Run an upsert

The RunDQL function also allows you to run upserts as well.

upsertQuery := `upsert {
  query {
    user as var(func: eq(email, "alice@example.com"))
  }
  mutation {
    set {
      uid(user) <age> "30" .
      uid(user) <name> "Alice Sayum" .
    }
  }
}`
resp, err := client.RunDQL(context.TODO(), dgo.RootNamespace, upsertQuery)
// handle error
fmt.Printf("%s\n", resp.QueryResult)
fmt.Printf("%+v\n", resp.BlankUids)

A conditional upsert can be run using the @if directive.

upsertQuery := `upsert {
  query {
    user as var(func: eq(email, "alice@example.com"))
  }
  mutation @if(eq(len(user), 1)) {
    set {
      uid(user) <age> "30" .
      uid(user) <name> "Alice Sayum" .
    }
  }
}`
resp, err := client.RunDQL(context.TODO(), dgo.RootNamespace, upsertQuery)
// handle error
fmt.Printf("%s\n", resp.QueryResult)

Drop all data

In order to drop all data in the cluster and start fresh, use the DropAllNamespaces function.

err := client.DropAllNamespaces(context.TODO())
// handle error

Model Context Protocol (MCP) Server

The Model Context Protocol (MCP) is a standard for making tools, data, and prompts available to AI models. It can be especially useful in bringing context on your stack into coding assistants.

Version 25 of Dgraph introduces two MCP servers with common tools for AI coding assistants:

  • mcp – a server that provides tools and data from your Dgraph cluster
  • mcp-ro – a server that provides tools and data from your Dgraph cluster in read-only mode

Configuration

To add the MCP server to your coding assistant, add the following to your configuration file:

When using Hypermode Graphs, the MCP configuration is available on the graph details screen in the console.

{
  "mcpServers": {
    "hypermode-graph": {
      "command": "npx",
      "args": [
        "mcp-remote",
        "https://<graph-workspace>.hypermode.host/mcp/sse",
        "--header",
        "Authorization: Bearer <bearer-token>"
      ]
    }
  }
}

We’re continuing to refine the resources available on the MCP servers. Please share feedback via Discord or GitHub.

Tools

The MCP servers provide the following tools:

  • Get-Schema – fetch the schema of your cluster
  • Run-Query – run a query on your cluster
  • Run-Mutation – run a mutation on your cluster
  • Alter-Schema – modify the schema of your cluster
  • Get-Common-Queries – provides reference queries to aide in query syntax

Prompt

For clients that support prompts over the MCP protocol, a prompt is available to provide an introduction to the agent.

The full text of the prompt is available in the Dgraph repo.