diff --git a/dgraph/overview.mdx b/dgraph/overview.mdx index 001f137b..3f378f40 100644 --- a/dgraph/overview.mdx +++ b/dgraph/overview.mdx @@ -38,13 +38,8 @@ real-time use cases. > Read about what use cases are the best fit for graph databases - - Explore the new query planner, faster writes, improved caching, and expanded - data capabilities + + Try out the new MCP server, namespaces, v2 APIs, and more diff --git a/dgraph/sdks/go.mdx b/dgraph/sdks/go.mdx index 378ce63a..c2195638 100644 --- a/dgraph/sdks/go.mdx +++ b/dgraph/sdks/go.mdx @@ -7,7 +7,7 @@ import DgraphWIP from "/snippets/dgraph-wip.mdx" -[![GoDoc](https://godoc.org/github.com/dgraph-io/dgo?status.svg)](https://godoc.org/github.com/dgraph-io/dgo) +[![GoDoc](https://pkg.go.dev/badge/github.com/dgraph-io/dgo/v240)](https://pkg.go.dev/github.com/dgraph-io/dgo/v240) The Go client communicates with the server on the gRPC port (default value 9080). @@ -23,8 +23,21 @@ go get -u -v github.com/dgraph-io/dgo/v210 The full [GoDoc](https://godoc.org/github.com/dgraph-io/dgo) contains documentation for the client API along with examples showing how to use it. -More details on the supported versions can be found at -[this link](https://github.com/hypermodeinc/dgo#supported-versions). +## Supported versions + +Depending on the version of Dgraph that you are connecting to, you should use a +compatible version of this client and their corresponding import paths. + +| Dgraph version | dgo version | dgo import path | +| -------------- | ----------- | ------------------------------- | +| dgraph 23.X.Y | dgo 230.X.Y | `github.com/dgraph-io/dgo/v230` | +| dgraph 24.X.Y | dgo 240.X.Y | `github.com/dgraph-io/dgo/v240` | +| dgraph 25.X.Y | dgo 250.X.Y | `github.com/dgraph-io/dgo/v250` | + + + Use the new v2 APIs with Dgraph v25. See the [v2 + APIs](/dgraph/v25-preview#v2-apis) + ## Create the client @@ -66,7 +79,6 @@ func newClient() *dgo.Dgraph { api.NewDgraphClient(d), ) } - ``` ### Multi-tenancy diff --git a/dgraph/v25-preview.mdx b/dgraph/v25-preview.mdx new file mode 100644 index 00000000..d786a2f4 --- /dev/null +++ b/dgraph/v25-preview.mdx @@ -0,0 +1,431 @@ +--- +title: v25 Preview +description: +--- + +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](https://hypermode.com/login). + +The run locally, use the Docker image `dgraph/standalone:v25.0.0-preview3`. + +```bash +docker run --rm -it -p 8080:8080 -p 9080:9080 dgraph/standalone:v25.0.0-preview3 +``` + +## Features + +The following new features are currently available in the preview release: + +- [Namespaces](#namespaces) – logically isolate environments for multi-customer + apps +- [v2 APIs](#v2-apis) – write less code with simplified client creation and DQL + execution +- [Model Context Protocol (MCP) Server](#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: + +- **Backups** (formerly [Binary Backups](/dgraph/enterprise/binary-backups) – + _non-S3 support has been dropped due to the deprecation of MinIO Gateway and + is planned for a future release_) +- **Query Logs** (formerly [Audit Logs](/dgraph/enterprise/audit-logs)) +- **Database Encryption** (formerly + [Encryption at Rest](/dgraph/enterprise/encryption-at-rest)) +- [Learner Nodes](/dgraph/enterprise/learner-nodes) +- [Change Data Capture](/dgraph/enterprise/change-data-capture) + +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](https://discord.hypermode.com) or + [GitHub](https://github.com/hypermodeinc/dgraph). + + +## 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](#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. + +```go +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. + +```go +err := client.DropNamespace(context.TODO(), "finance-graph") +// handle error +``` + +### Rename a namespace + +To rename a namespace, use the `RenameNamespace` function. + +```go +err := client.RenameNamespace(context.TODO(), "finance-graph", "new-finance-graph") +// handle error +``` + +### List all namespaces + +To list all namespaces, use the `ListNamespaces` function. + +```go +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. + +[![GoDoc](https://pkg.go.dev/badge/github.com/dgraph-io/dgo/v250)](https://pkg.go.dev/github.com/dgraph-io/dgo/v250) + +### 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: + +| Argument | Value | Description | +| ------------- | ------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `bearertoken` | \ | an access token | +| `sslmode` | `disable`
`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. + +```go +// 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. + +```go +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`. + +```go +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: + +```go +client, err := dgo.Open("dgraph://.hypermode.host?sslmode=verify-ca&bearertoken=") +// handle error +defer client.Close() +``` + +Using `NewClient`: + +```go +client, err := dgo.NewClient(".hypermode.host:443", + dgo.WithBearerToken(""), + dgo.WithSystemCertPool(), +) +// handle error +defer client.Close() +``` + +### Set schema + +To set the schema, use the `SetSchema` function. + +```go +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. + +```go +mutationDQL := `{ + set { + _:alice "Alice" . + _:alice "alice@example.com" . + _:alice "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. + +```go +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`. + +```go +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`. + +```go +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`. + +```go +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`. + +```go +queryDQL := `{ + alice(func: eq(name, "Alice")) { + name + email + age + } +}` +resp, err = client.RunDQL(context.TODO(), dgo.RootNamespace, queryDQL, dgo.WithResponseFormat(api_v25.RespFormat_RDF)) +// handle error +fmt.Printf("%s\n", resp.QueryResult) +``` + +### Run an upsert + +The `RunDQL` function also allows you to run upserts as well. + +```go +upsertQuery := `upsert { + query { + user as var(func: eq(email, "alice@example.com")) + } + mutation { + set { + uid(user) "30" . + uid(user) "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. + +```go +upsertQuery := `upsert { + query { + user as var(func: eq(email, "alice@example.com")) + } + mutation @if(eq(len(user), 1)) { + set { + uid(user) "30" . + uid(user) "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. + +```go +err := client.DropAllNamespaces(context.TODO()) +// handle error +``` + +## Model Context Protocol (MCP) Server + +The [Model Context Protocol](https://modelcontextprotocol.io/introduction) (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. + + + +```json Hypermode +{ + "mcpServers": { + "hypermode-graph": { + "command": "npx", + "args": [ + "mcp-remote", + "https://.hypermode.host/mcp/sse", + "--header", + "Authorization: Bearer " + ] + } + } +} +``` + +```json local +{ + "mcpServers": { + "dgraph": { + "command": "npx", + "args": ["mcp-remote", "https://localhost:9080/mcp/sse"] + } + } +} +``` + + + + + We're continuing to refine the resources available on the MCP servers. Please + share feedback via [Discord](https://discord.hypermode.com) or + [GitHub](https://github.com/hypermodeinc/dgraph). + + +### 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](https://github.com/hypermodeinc/dgraph/blob/8a774a03ac2558ad027bd86ead8b0059d3bfa3f5/dgraph/cmd/mcp/prompt.txt). diff --git a/docs.json b/docs.json index d16e968d..62fa7493 100644 --- a/docs.json +++ b/docs.json @@ -9,7 +9,7 @@ }, "favicon": "favicon.png", "banner": { - "content": "🚀 Model Router is here! One API, one bill, multiple models. [Learn more →](https://hypermode.com/blog/introducing-model-router)" + "content": "🎉 Dgraph v25 Preview is out with namespaces, MCP, and more! [Learn more →](/dgraph/v25-preview)" }, "navigation": { "global": { @@ -156,7 +156,8 @@ "dgraph/overview", "dgraph/why-dgraph", "dgraph/quickstart", - "dgraph/guides" + "dgraph/guides", + "dgraph/v25-preview" ] }, { diff --git a/graphs/manage-graph.mdx b/graphs/manage-graph.mdx index 047c3dab..dfece8a2 100644 --- a/graphs/manage-graph.mdx +++ b/graphs/manage-graph.mdx @@ -16,10 +16,10 @@ Graphs on Hypermode are available in the following regions: | :----- | :-------------------- | | `iad1` | Washington, D.C., USA | | `pdx1` | Portland, Oregon, USA | +| `fra1` | Frankfurt, Germany | Additional regions are planned to be available in the near future: -- Frankfurt, Germany - Dublin, Ireland - Singapore diff --git a/graphs/overview.mdx b/graphs/overview.mdx index c080f3bb..86ac86d4 100644 --- a/graphs/overview.mdx +++ b/graphs/overview.mdx @@ -15,6 +15,9 @@ for building and deploying knowledge graphs. This service combines the power of Dgraph's distributed graph database with Hypermode's AI development platform, offering a seamless experience for developers and organizations of all sizes. +New Graphs deployed on Hypermode as of May 21, 2025, are powered by +[Dgraph v25](/dgraph/v25-preview). + ## Key features In addition to the [features provided by Dgraph](/dgraph/why-dgraph), Graphs on