@dgql/client
v1.1.0-alpha.4
Published
Translation engine and client for the DGQL Language
Downloads
2
Maintainers
Readme
@dgql/client
Translation engine and client for the DGQL Language.
Getting Started
$ npm install @dgql/client
Quick Start
const { Client } = require("@dgql/client");
const neo4j = require("neo4j-driver");
const driver = neo4j.driver(
"bolt://localhost:7687",
neo4j.auth.basic("neo4j", "password")
);
const client = new Client({ driver });
async function main() {
const query = `
{
MATCH {
user @node(label: User) {
WHERE {
name(equal: "Dan")
}
PROJECT {
name
posts @edge(type: HAS_POST, direction: OUT) @node(label: Post) {
title
}
}
}
}
RETURN {
user
}
}
`;
const { user } = await client.run({ query });
console.log(user);
/*
[{
name: "Dan",
posts: [
{
title: "Checkout @dgql/client"
}
]
}]
*/
}
main();
Usage
Variables
Use the $
symbol to use variables and provide variables
map when calling translation
or run
;
const { user } = await client.run({ query, variables: { id: "user-id" } }); // OR
const translation = client.translate({ query, variables: { id: "user-id" } }); // OR
{
MATCH {
user @node(label: User) {
WHERE {
id(equal: $id)
}
}
}
RETURN {
user
}
}
Licence
MIT