1import type * as neptunegraph from "@distilled.cloud/aws/neptune-graph";
2import type * as Effect from "effect/Effect";
3import * as Binding from "../../Binding.ts";
4import type { Graph } from "./Graph.ts";
5
6export interface ExecuteQueryRequest extends Omit<
7 neptunegraph.ExecuteQueryInput,
8 "graphIdentifier"
9> {}
10
11/**
12 * Runtime binding for `neptune-graph:ExecuteQuery` — run an openCypher query
13 * against a Neptune Analytics {@link Graph}.
14 *
15 * Bind this operation to a `Graph` inside a function runtime to get a
16 * callable that automatically injects the graph identifier and grants the
17 * data-plane query actions (`ReadDataViaQuery`, `WriteDataViaQuery`,
18 * `DeleteDataViaQuery`) on the graph.
19 *
20 * The response `payload` is a streaming body — collect it to parse the JSON
21 * result document.
22 * ### Querying a Graph
23 * **Example:** Run an openCypher query
24 * ```typescript
25 * const executeQuery = yield* AWS.NeptuneGraph.ExecuteQuery(graph);
26 *
27 * const response = yield* executeQuery({
28 * queryString: "MATCH (n) RETURN count(n) AS nodes",
29 * language: "OPEN_CYPHER",
30 * });
31 * const body = yield* Stream.mkString(
32 * Stream.decodeText(response.payload),
33 * );
34 * const { results } = JSON.parse(body);
35 * ```
36 *
37 * **Example:** Write data with parameters
38 * ```typescript
39 * yield* executeQuery({
40 * queryString: "CREATE (n:Person {name: $name})",
41 * language: "OPEN_CYPHER",
42 * parameters: { name: "Ada" },
43 * });
44 * ```
45 *
46 * @binding
47 */
48export interface ExecuteQuery extends Binding.Service<
49 ExecuteQuery,
50 "AWS.NeptuneGraph.ExecuteQuery",
51 <G extends Graph>(
52 graph: G,
53 ) => Effect.Effect<
54 (
55 request: ExecuteQueryRequest,
56 ) => Effect.Effect<
57 neptunegraph.ExecuteQueryOutput,
58 neptunegraph.ExecuteQueryError
59 >
60 >
61> {}
62export const ExecuteQuery = Binding.Service<ExecuteQuery>(
63 "AWS.NeptuneGraph.ExecuteQuery",
64);