Socket
Socket
Sign inDemoInstall

@dgql/client

Package Overview
Dependencies
13
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @dgql/client

Translation engine and client for the DGQL Language


Version published
Weekly downloads
2
increased by100%
Maintainers
1
Install size
257 kB
Created
Weekly downloads
 

Readme

Source

@dgql/client

npm package

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

Keywords

FAQs

Last updated on 01 Jun 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc