diff --git a/define-hosts.mdx b/define-hosts.mdx
index 8b37c3dd..496def6c 100644
--- a/define-hosts.mdx
+++ b/define-hosts.mdx
@@ -18,6 +18,7 @@ If not provided, the default type is `http`. The following table lists the avail
| :----------- | :------------------------------------- | :-------------------------- |
| `http` | Connect to an HTTP or HTTPS web server | `http`, `graphql`, `models` |
| `postgresql` | Connect to a PostgreSQL database | `postgresql` |
+| `dgraph` | Connect to a Dgraph database | `dgraph` |
We'll update this table as we add more host types.
@@ -187,3 +188,34 @@ For example, if using Neon, refer to the [Neon documentation](https://neon.tech/
+
+## Dgraph Host
+
+This host type supports connecting to Dgraph databases.
+You can use the [Dgraph APIs](/sdk/dgraph) in the Functions SDK to interact with the database.
+
+**Example:**
+
+```json hypermode.json
+{
+ "hosts": {
+ "my-dgraph": {
+ "type": "dgraph",
+ "grpcTarget": "frozen-mango.grpc.eu-central-1.aws.cloud.dgraph.io:443",
+ "key": "{{DGRAPH_API_KEY}}"
+ }
+ }
+}
+```
+
+
+ Always set to `"dgraph"` for this host type.
+
+
+
+ The gRPC target for the Dgraph database.
+
+
+
+ The API key for the Dgraph database.
+
diff --git a/mint.json b/mint.json
index 552ebc43..a5a7d231 100644
--- a/mint.json
+++ b/mint.json
@@ -82,7 +82,8 @@
"sdk/graphql",
"sdk/http",
"sdk/models",
- "sdk/postgresql"
+ "sdk/postgresql",
+ "sdk/dgraph"
]
}
]
diff --git a/sdk/dgraph.mdx b/sdk/dgraph.mdx
new file mode 100644
index 00000000..e5c1ae0d
--- /dev/null
+++ b/sdk/dgraph.mdx
@@ -0,0 +1,250 @@
+---
+title: Dgraph
+description: "Execute queries and mutations against a Dgraph database."
+---
+
+{/* */}
+
+Hypermode's Dgraph APIs allow you to run queries and mutations against a Dgraph database, as well as alter
+the schema if necessary.
+After [defining a host](../define-hosts) for your Dgraph gRPC endpoint in your project's manifest,
+you can use the following APIs to interact with the database.
+
+## Example project
+
+For your reference, a complete example using the Dgraph APIs is available on GitHub in the
+`hypermodeAI/functions-as` repository, at [/examples/dgraph](https://github.com/hypermodeAI/functions-as/tree/main/examples/dgraph).
+
+## Import from the SDK
+
+To begin, import the `dgraph` namespace from the SDK:
+
+
+
+```ts AssemblyScript
+import { dgraph } from "@hypermode/functions-as";
+```
+
+
+
+## Dgraph APIs
+
+The APIs in the `dgraph` namespace are below.
+
+
+ We're constantly introducing new APIs through ongoing development with build
+ partners. [Let's chat](mailto:help@hypermode.com) about what would make the
+ Functions SDK even more powerful for your next use case!
+
+
+### Functions
+
+#### execute
+
+Execute a Dgraph query or mutation using a Dgraph Request object.
+
+
+
+```ts AssemblyScript
+function execute(hostName: string, request: Request): Response;
+```
+
+
+
+
+ Name of the host, as [defined in the manifest](../define-hosts).
+
+
+
+ A Dgraph [`Request`](#request) object, describing the query or mutation to
+ execute.
+
+
+#### alterSchema
+
+Alter the schema of a Dgraph database.
+
+
+
+```ts AssemblyScript
+function alterSchema(hostName: string, schema: string): string;
+```
+
+
+
+
+ Name of the host, as [defined in the manifest](../define-hosts).
+
+
+
+ The schema to apply to the Dgraph database.
+
+
+#### dropAttr
+
+Drop an attribute from a Dgraph schema.
+
+
+
+```ts AssemblyScript
+function dropAttr(hostName: string, attr: string): string;
+```
+
+
+
+
+ Name of the host, as [defined in the manifest](../define-hosts).
+
+
+
+ The attribute to drop from the Dgraph schema.
+
+
+#### dropAll
+
+Drop all data from a Dgraph database.
+
+
+
+```ts AssemblyScript
+function dropAll(hostName: string): string;
+```
+
+
+
+
+ Name of the host, as [defined in the manifest](../define-hosts).
+
+
+### Objects
+
+#### Request
+
+A Dgraph request object, used to execute queries and mutations.
+
+
+
+```ts AssemblyScript
+class Request {
+ constructor(Query: Query | null = null, Mutations: Mutation[] | null = null);
+ query: Query = new Query();
+ mutations: Mutation[] = [];
+}
+```
+
+
+
+
+
+Creates a new `Request` object with the given `query` and `mutations`.
+
+The [`query`](#query) and [`mutations`](#mutation) fields are optional and default to `null`.
+
+
+
+
+ A Dgraph [`query`](#query) object.
+
+
+
+ An array of Dgraph [`mutation`](#mutation) objects.
+
+
+#### Query
+
+A Dgraph query object, used to execute queries.
+
+
+
+```ts AssemblyScript
+class Query {
+ constructor(query: string = "", variables: Variables = new Variables());
+ query: string = "";
+ variables: Map = new Map();
+}
+```
+
+
+
+
+ Creates a new `Query` object with the given `query` and `variables`. `query`
+ is a Dgraph Query Language (DQL) query string, and `variables` is a
+ [`Variables`](#variables) object.
+
+
+
+ The DQL query to execute.
+
+
+
+ A map of query variables.
+
+
+#### Variables
+
+A Variables object used to set query variables in a Dgraph query.
+
+
+
+```ts AssemblyScript
+class Variables {
+ public set(name: string, value: T): void;
+ public toMap(): Map;
+}
+```
+
+
+
+
+ Sets a query variable with the given `name` and `value`. `name` is of type
+ `string`, and `value` can be of any type.
+
+
+
+ Returns a map of all query variables set in the `Variables` object.
+
+
+#### Mutation
+
+A Dgraph mutation object, used to execute mutations.
+
+
+
+```ts AssemblyScript
+class Mutation {
+ constructor(
+ public setJson: string = "",
+ public delJson: string = "",
+ public setNquads: string = "",
+ public delNquads: string = "",
+ public condition: string = "",
+ )
+}
+```
+
+
+
+
+ Creates a new `Mutation` object with the given `setJson`, `delJson`,
+ `setNquads`, `delNquads`, and `condition` fields.
+
+
+
+ A JSON string representing the data to set in the mutation.
+
+
+
+ A JSON string representing the data to delete in the mutation.
+
+
+
+ A string representing the data to set in the mutation in NQuads format.
+
+
+
+ A string representing the data to delete in the mutation in NQuads format.
+
+
+
+ A string representing the condition query for the mutation.
+
diff --git a/sdk/functions-sdk.mdx b/sdk/functions-sdk.mdx
index c9bdccb7..deeccf6f 100644
--- a/sdk/functions-sdk.mdx
+++ b/sdk/functions-sdk.mdx
@@ -52,6 +52,9 @@ The following APIs are available in the Functions SDK:
Execute queries against a PostgreSQL database.
+
+ Execute queries and mutations against a Dgraph database.
+
## Installation
diff --git a/styles/config/vocabularies/general/accept.txt b/styles/config/vocabularies/general/accept.txt
index 70b7f50e..344604f7 100644
--- a/styles/config/vocabularies/general/accept.txt
+++ b/styles/config/vocabularies/general/accept.txt
@@ -31,3 +31,9 @@ UUID
nnClassify
serverless
getVector
+gRPC
+[Dd]graph
+alterSchema
+dropAll
+NQuads
+dropAttr