From 58ddbb53f2017e4c36e144effa5a7db6abfcd7ab Mon Sep 17 00:00:00 2001
From: Jai Radhakrishnan <55522316+jairad26@users.noreply.github.com>
Date: Sun, 29 Sep 2024 10:22:02 -0700
Subject: [PATCH 1/8] add dgraph docs
---
define-hosts.mdx | 32 +++
mint.json | 3 +-
sdk/dgraph.mdx | 250 ++++++++++++++++++
sdk/functions-sdk.mdx | 3 +
styles/config/vocabularies/general/accept.txt | 3 +
5 files changed, 290 insertions(+), 1 deletion(-)
create mode 100644 sdk/dgraph.mdx
diff --git a/define-hosts.mdx b/define-hosts.mdx
index 8b37c3dd..9176dd2a 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..528fa0f9
--- /dev/null
+++ b/sdk/dgraph.mdx
@@ -0,0 +1,250 @@
+---
+title: DGraph
+description: "Execcute 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 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, which is used in
+ conditional mutations.
+
diff --git a/sdk/functions-sdk.mdx b/sdk/functions-sdk.mdx
index c9bdccb7..4416cd6c 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..1a2015e9 100644
--- a/styles/config/vocabularies/general/accept.txt
+++ b/styles/config/vocabularies/general/accept.txt
@@ -31,3 +31,6 @@ UUID
nnClassify
serverless
getVector
+gRPC
+DGraph
+dgraph
From f3ed5916425349cc5ad6b6f8aadb5145e538c1c8 Mon Sep 17 00:00:00 2001
From: Jai Radhakrishnan <55522316+jairad26@users.noreply.github.com>
Date: Sun, 29 Sep 2024 10:24:46 -0700
Subject: [PATCH 2/8] revs
---
sdk/dgraph.mdx | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/sdk/dgraph.mdx b/sdk/dgraph.mdx
index 528fa0f9..f2aca4d2 100644
--- a/sdk/dgraph.mdx
+++ b/sdk/dgraph.mdx
@@ -168,7 +168,8 @@ class Query {
Creates a new `Query` object with the given `query` and `variables`. `query`
- is a DQL query string, and `variables` is a [`Variables`](#variables) object.
+ is a DGraph Query Language (DQL) query string, and `variables` is a
+ [`Variables`](#variables) object.
@@ -245,6 +246,5 @@ class Mutation {
- A string representing the condition query for the mutation, which is used in
- conditional mutations.
+ A string representing the condition query for the mutation.
From d562b7df743d6c241ae6c6d8a8c5282575b686c5 Mon Sep 17 00:00:00 2001
From: Jai Radhakrishnan <55522316+jairad26@users.noreply.github.com>
Date: Sun, 29 Sep 2024 10:27:32 -0700
Subject: [PATCH 3/8] update vocab
---
styles/config/vocabularies/general/accept.txt | 3 +++
1 file changed, 3 insertions(+)
diff --git a/styles/config/vocabularies/general/accept.txt b/styles/config/vocabularies/general/accept.txt
index 1a2015e9..769d91f6 100644
--- a/styles/config/vocabularies/general/accept.txt
+++ b/styles/config/vocabularies/general/accept.txt
@@ -34,3 +34,6 @@ getVector
gRPC
DGraph
dgraph
+alterSchema
+dropAll
+NQuads
From 01f652b029dedf9bb30a1c738ea7d5be96975bf7 Mon Sep 17 00:00:00 2001
From: Jai Radhakrishnan <55522316+jairad26@users.noreply.github.com>
Date: Sun, 29 Sep 2024 10:27:57 -0700
Subject: [PATCH 4/8] update vocab
---
styles/config/vocabularies/general/accept.txt | 1 +
1 file changed, 1 insertion(+)
diff --git a/styles/config/vocabularies/general/accept.txt b/styles/config/vocabularies/general/accept.txt
index 769d91f6..6ada9d48 100644
--- a/styles/config/vocabularies/general/accept.txt
+++ b/styles/config/vocabularies/general/accept.txt
@@ -37,3 +37,4 @@ dgraph
alterSchema
dropAll
NQuads
+dropAttr
From 94f52c7b721d534eb30ed30248266ae34d0ce6e9 Mon Sep 17 00:00:00 2001
From: Jai Radhakrishnan <55522316+jairad26@users.noreply.github.com>
Date: Sun, 29 Sep 2024 11:01:58 -0700
Subject: [PATCH 5/8] .
---
define-hosts.mdx | 12 +++---
sdk/dgraph.mdx | 40 +++++++++----------
sdk/functions-sdk.mdx | 4 +-
styles/config/vocabularies/general/accept.txt | 2 +-
4 files changed, 29 insertions(+), 29 deletions(-)
diff --git a/define-hosts.mdx b/define-hosts.mdx
index 9176dd2a..496def6c 100644
--- a/define-hosts.mdx
+++ b/define-hosts.mdx
@@ -18,7 +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` |
+| `dgraph` | Connect to a Dgraph database | `dgraph` |
We'll update this table as we add more host types.
@@ -189,10 +189,10 @@ For example, if using Neon, refer to the [Neon documentation](https://neon.tech/
-## DGraph Host
+## 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.
+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:**
@@ -213,9 +213,9 @@ You can use the [DGraph APIs](/sdk/dgraph) in the Functions SDK to interact with
- The gRPC target for the DGraph database.
+ The gRPC target for the Dgraph database.
- The API key for the DGraph database.
+ The API key for the Dgraph database.
diff --git a/sdk/dgraph.mdx b/sdk/dgraph.mdx
index f2aca4d2..ecfe1fe1 100644
--- a/sdk/dgraph.mdx
+++ b/sdk/dgraph.mdx
@@ -1,18 +1,18 @@
---
-title: DGraph
-description: "Execcute queries and mutations against a DGraph database."
+title: Dgraph
+description: "Execcute 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
+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,
+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
+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
@@ -27,7 +27,7 @@ import { dgraph } from "@hypermode/functions-as";
-## DGraph APIs
+## Dgraph APIs
The APIs in the `dgraph` namespace are below.
@@ -41,7 +41,7 @@ The APIs in the `dgraph` namespace are below.
#### execute
-Execute a DGraph query or mutation using a DGraph Request object.
+Execute a Dgraph query or mutation using a Dgraph Request object.
@@ -56,13 +56,13 @@ function execute(hostName: string, request: Request): Response;
- A DGraph [`Request`](#request) object, describing the query or mutation to
+ A Dgraph [`Request`](#request) object, describing the query or mutation to
execute.
#### alterSchema
-Alter the schema of a DGraph database.
+Alter the schema of a Dgraph database.
@@ -77,12 +77,12 @@ function alterSchema(hostName: string, schema: string): string;
- The schema to apply to the DGraph database.
+ The schema to apply to the Dgraph database.
#### dropAttr
-Drop an attribute from a DGraph schema.
+Drop an attribute from a Dgraph schema.
@@ -97,12 +97,12 @@ function dropAttr(hostName: string, attr: string): string;
- The attribute to drop from the DGraph schema.
+ The attribute to drop from the Dgraph schema.
#### dropAll
-Drop all data from a DGraph database.
+Drop all data from a Dgraph database.
@@ -120,7 +120,7 @@ function dropAll(hostName: string): string;
#### Request
-A DGraph request object, used to execute queries and mutations.
+A Dgraph request object, used to execute queries and mutations.
@@ -143,16 +143,16 @@ The [`query`](#query) and [`mutations`](#mutation) fields are optional and defau
- A DGraph [`query`](#query) object.
+ A Dgraph [`query`](#query) object.
- An array of DGraph [`mutation`](#mutation) objects.
+ An array of Dgraph [`mutation`](#mutation) objects.
#### Query
-A DGraph query object, used to execute queries.
+A Dgraph query object, used to execute queries.
@@ -168,7 +168,7 @@ class Query {
Creates a new `Query` object with the given `query` and `variables`. `query`
- is a DGraph Query Language (DQL) query string, and `variables` is a
+ is a Dgraph Query Language (DQL) query string, and `variables` is a
[`Variables`](#variables) object.
@@ -182,7 +182,7 @@ class Query {
#### Variables
-A Variables object used to set query variables in a DGraph query.
+A Variables object used to set query variables in a Dgraph query.
@@ -206,7 +206,7 @@ class Variables {
#### Mutation
-A DGraph mutation object, used to execute mutations.
+A Dgraph mutation object, used to execute mutations.
diff --git a/sdk/functions-sdk.mdx b/sdk/functions-sdk.mdx
index 4416cd6c..deeccf6f 100644
--- a/sdk/functions-sdk.mdx
+++ b/sdk/functions-sdk.mdx
@@ -52,8 +52,8 @@ The following APIs are available in the Functions SDK:
Execute queries against a PostgreSQL database.
-
- Execute queries and mutations against a DGraph database.
+
+ Execute queries and mutations against a Dgraph database.
diff --git a/styles/config/vocabularies/general/accept.txt b/styles/config/vocabularies/general/accept.txt
index 6ada9d48..db824e77 100644
--- a/styles/config/vocabularies/general/accept.txt
+++ b/styles/config/vocabularies/general/accept.txt
@@ -32,7 +32,7 @@ nnClassify
serverless
getVector
gRPC
-DGraph
+Dgraph
dgraph
alterSchema
dropAll
From 2e9bf4730352825e7db4c2720273adf34748be6d Mon Sep 17 00:00:00 2001
From: Jai Radhakrishnan <55522316+jairad26@users.noreply.github.com>
Date: Sun, 29 Sep 2024 15:08:59 -0700
Subject: [PATCH 6/8] .
---
.vale.ini | 1 +
sdk/dgraph.mdx | 2 +-
styles/Google/CustomTerms.yml | 4 ++++
3 files changed, 6 insertions(+), 1 deletion(-)
create mode 100644 styles/Google/CustomTerms.yml
diff --git a/.vale.ini b/.vale.ini
index 971fcda0..f61f05ff 100644
--- a/.vale.ini
+++ b/.vale.ini
@@ -14,3 +14,4 @@ BasedOnStyles = Vale, Google
Google.Exclamation = OFF
Google.Parens = OFF
Google.We = OFF
+BasedOnStyles = CustomTerms
diff --git a/sdk/dgraph.mdx b/sdk/dgraph.mdx
index ecfe1fe1..e5c1ae0d 100644
--- a/sdk/dgraph.mdx
+++ b/sdk/dgraph.mdx
@@ -1,6 +1,6 @@
---
title: Dgraph
-description: "Execcute queries and mutations against a Dgraph database."
+description: "Execute queries and mutations against a Dgraph database."
---
{/* */}
diff --git a/styles/Google/CustomTerms.yml b/styles/Google/CustomTerms.yml
new file mode 100644
index 00000000..5441423b
--- /dev/null
+++ b/styles/Google/CustomTerms.yml
@@ -0,0 +1,4 @@
+extends: terms
+message: 'Consider using "{{ .Match }}" instead of "{{ .Match }}"'
+ignore:
+ - Dgraph
From 0edb2e5fb160dabe39470db77b3872aef8b8923c Mon Sep 17 00:00:00 2001
From: Jai Radhakrishnan <55522316+jairad26@users.noreply.github.com>
Date: Sun, 29 Sep 2024 15:10:32 -0700
Subject: [PATCH 7/8] fix
---
.vale.ini | 1 -
1 file changed, 1 deletion(-)
diff --git a/.vale.ini b/.vale.ini
index f61f05ff..971fcda0 100644
--- a/.vale.ini
+++ b/.vale.ini
@@ -14,4 +14,3 @@ BasedOnStyles = Vale, Google
Google.Exclamation = OFF
Google.Parens = OFF
Google.We = OFF
-BasedOnStyles = CustomTerms
From 3c7ffbdac75b49060ed77738e8e9d5a52e4efe07 Mon Sep 17 00:00:00 2001
From: Jai Radhakrishnan <55522316+jairad26@users.noreply.github.com>
Date: Sun, 29 Sep 2024 15:14:54 -0700
Subject: [PATCH 8/8] fix
---
styles/Google/CustomTerms.yml | 4 ----
styles/config/vocabularies/general/accept.txt | 3 +--
2 files changed, 1 insertion(+), 6 deletions(-)
delete mode 100644 styles/Google/CustomTerms.yml
diff --git a/styles/Google/CustomTerms.yml b/styles/Google/CustomTerms.yml
deleted file mode 100644
index 5441423b..00000000
--- a/styles/Google/CustomTerms.yml
+++ /dev/null
@@ -1,4 +0,0 @@
-extends: terms
-message: 'Consider using "{{ .Match }}" instead of "{{ .Match }}"'
-ignore:
- - Dgraph
diff --git a/styles/config/vocabularies/general/accept.txt b/styles/config/vocabularies/general/accept.txt
index db824e77..344604f7 100644
--- a/styles/config/vocabularies/general/accept.txt
+++ b/styles/config/vocabularies/general/accept.txt
@@ -32,8 +32,7 @@ nnClassify
serverless
getVector
gRPC
-Dgraph
-dgraph
+[Dd]graph
alterSchema
dropAll
NQuads