{"id":15696176,"url":"https://github.com/danstarns/dgql","last_synced_at":"2025-05-08T22:31:21.034Z","repository":{"id":47490893,"uuid":"344870595","full_name":"danstarns/DGQL","owner":"danstarns","description":"DGQL - Dynamic Graph Query Language.","archived":false,"fork":false,"pushed_at":"2021-08-29T14:42:49.000Z","size":2251,"stargazers_count":7,"open_issues_count":3,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-21T09:07:01.306Z","etag":null,"topics":["cypher","graphql","neo4j","query-language"],"latest_commit_sha":null,"homepage":"https://github.com/danstarns/DGQL","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/danstarns.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-03-05T16:34:30.000Z","updated_at":"2024-02-25T10:06:30.000Z","dependencies_parsed_at":"2022-09-07T14:11:45.035Z","dependency_job_id":null,"html_url":"https://github.com/danstarns/DGQL","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danstarns%2FDGQL","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danstarns%2FDGQL/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danstarns%2FDGQL/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danstarns%2FDGQL/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danstarns","download_url":"https://codeload.github.com/danstarns/DGQL/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251999658,"owners_count":21678020,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cypher","graphql","neo4j","query-language"],"created_at":"2024-10-03T19:08:07.644Z","updated_at":"2025-05-08T22:31:21.002Z","avatar_url":"https://github.com/danstarns.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DGQL\n\n\u003e Next Generation Application Specific Graph Query Language.\n\n[![DGQL](./docs/assets/dgql-banner-white.png)](.)\n\n~~Dynamic GraphQL~~\n\n~~Dans Graph Query Language~~\n\nDynamic Graph Query Language 👍\n\n## Packages\n\n1. [Language](https://github.com/danstarns/dgql/tree/main/packages/language) - The Javascript Implementation For The DGQL Language\n\n2. [Client](https://github.com/danstarns/dgql/tree/main/packages/client) - Executable Client for DGQL Queries\n\n3. [Builder](https://github.com/danstarns/dgql/tree/main/packages/builder) - DGQL Query Builder\n\n4. [Playground](https://github.com/danstarns/dgql/tree/main/packages/playground) - Graph app Developer playground to issue DGQL queries\n\n## Documentation\n\n- [Documentation](https://github.com/danstarns/DGQL/blob/main/docs/index.md)\n- [TCK tests](https://github.com/danstarns/DGQL/tree/main/packages/language/tests/tck/tck-test-files)\n- [DGQL Recipes](https://github.com/danstarns/dgql/tree/main/misc/recipes)\n- [Blog](https://medium.com/@danstarns/dgql-next-generation-application-specific-graph-query-language-a232e39887e7) - ⚠ In progress\n\n## Examples\n\nSee [Examples](./examples/index.md)\n\n## Prerequisites\n\nGraphQL can be separated into two sections; language \u0026 execution. To truly grasp this implementation one should first remove themselves from the conventional execution paradigms, say using Apollo Server, and look towards the pre-made \u0026 rich tooling surrounding the language. DGQL completely breaks the rules 😲 throws away the runtime and simply focuses on the language.\n\n## What\n\nThis implementation, at its core, is a transpiler from GraphQL to Cypher and simply concerns itself with the AST produced from a given selection set. Traversal of the AST enables the translator to generate Cypher from picking up on Client Directives.\n\nGiven the below DGQL Query;\n\n```graphql\n{\n  MATCH {\n    user @node(label: User) @where(name: \"Dan\") {\n      PROJECT {\n        id\n        name\n        posts @edge(type: AUTHORED, direction: OUT) @node(label: Post) {\n          title\n        }\n      }\n    }\n  }\n  RETURN {\n    user\n  }\n}\n```\n\n\u003cbr\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eOr equivalent DGQL Builder\u003c/summary\u003e\n\u003cbr\u003e\n\n[DGQL Builder](./packages/builder)\n\n```js\nconst { Builder, node, property, edge } = require(\"@dgql/builder\");\n\nconst builder = new Builder();\n\nconst [dgql, variables] = builder\n  .match({\n    user: node({ label: \"User\" })\n      .where({ name: property({ equal: \"Dan\" }) })\n      .project({\n        id: property(),\n        name: property(),\n        posts: edge({\n          type: \"AUTHORED\",\n          direction: \"OUT\",\n          node: node({ label: \"Post\" }),\n        }).project({\n          title: property(),\n        }),\n      }),\n  })\n  .return([\"user\"])\n  .build();\n```\n\n\u003c/details\u003e\n\n\u003cbr\u003e\n\nThe following Cypher is produced;\n\n```cypher\nCALL {\n  MATCH (user:User)\n  WHERE user.name = \"Dan\"\n  RETURN user {\n      .id,\n      .name,\n      posts: [ (user)-[:AUTHORED]-\u003e(posts:Post) | { title: posts.title } ]\n  } as user\n}\nRETURN user\n```\n\nUsing the [DGQL Client](https://github.com/danstarns/dgql/tree/main/packages/client) you can execute this Cypher and receive an object like:\n\n```json\n{\n  \"user\": [\n    {\n      \"id\": \"user-id-01\",\n      \"name\": \"Dan\",\n      \"posts\": [{ \"title\": \"Checkout DGQL!\" }]\n    }\n  ]\n}\n```\n\n\u003cbr\u003e\n\n💡 DGQL is just GraphQL, **and not a fork**.\n\n[![DGQL](./docs/assets/dgql-diagram-white.png)](.)\n\n## Why\n\n**Why don't you just use Cypher?** - If you are looking for a highly specific answer... Cypher may be the correct tool. If you aren't too familiar with the Cypher, and all you need is a JSON structure, similar in shape to your formulated query, then DGQL is for you. Using a DGQL query will make returning values from the database more predictable \u0026 easier to manage.\n\n**Why does it use GraphQL?** - The GraphQL parser is a widely adopted and maintained project, meaning we can lean on its tools and infrastructure. Not only does GraphQL provide a solid foundation but also comes with developers \u0026 library authors. Finally, GraphQL directives are extremely useful and enable DGQL to facilitate powerful abstractions behind them.\n\n**Why no Schema?** - This implementation is designed to be lightweight and run anywhere. The lack of schema facilitates this but also means no validation or type checking is performed, usually the expensive part of GraphQL execution.\n\n## Overview\n\n### Retrieve large subgraphs\n\n\u003c!-- prettier-ignore-start --\u003e\n\n```graphql\n{\n  MATCH {\n    blogs @node(label: Blog) {\n      PROJECT {\n        name\n        posts @edge(type: HAS_POST, direction: OUT) @node(label: Post) {\n          title\n          comments @edge(type: HAS_COMMENT, direction: OUT) @node(label: Comment) {\n            content\n            authors @edge(type: AUTHORED, direction: IN) @node(label: User) {\n              name\n            }\n          }\n        }\n      }\n    }\n  }\n  RETURN {\n    blogs\n  }\n}\n```\n\n\u003c!-- prettier-ignore-end --\u003e\n\n### Execute custom `@cypher`\n\nSometimes you may have a highly specific question, Cypher could better help you ask. Use [the `@cypher` directive](./docs/language/cypher.md), in a projection, to break the flow, and execute custom cypher.\n\n```graphql\n{\n  MATCH {\n    movies @node(label: Movie) {\n      PROJECT {\n        title\n        similar\n          @cypher(\n            arguments: { first: 3 }\n            statement: \"\"\"\n            MATCH (this)-[:ACTED_IN|:IN_GENRE]-()-[:ACTED_IN|:IN_GENRE]-(rec:Movie)\n            WITH rec, COUNT(*) AS score\n            RETURN rec ORDER BY score DESC LIMIT $first\n            \"\"\"\n          ) {\n          title\n          actors @edge(type: ACTED_IN, direction: IN) @node {\n            name\n          }\n        }\n      }\n    }\n  }\n  RETURN {\n    movies\n  }\n}\n```\n\n### Compose Queries\n\nUse [Fragments](./docs/language/fragments.md) to compose and reuse bits of your query:\n\n```graphql\n{\n  MATCH {\n    blogs @node(label: Blog) {\n      PROJECT {\n        name\n        ...Posts\n      }\n    }\n  }\n  RETURN {\n    blogs\n  }\n}\n\nfragment Posts on DGQL {\n  posts @edge(type: HAS_POST, direction: OUT) @node(label: Post) {\n    title\n    ...Comments\n    ...Authors\n  }\n}\n\nfragment Comments on DGQL {\n  comments @edge(type: HAS_COMMENT, direction: OUT) @node(label: Comment) {\n    content\n    ...Authors\n  }\n}\n\nfragment Authors on DGQL {\n  authors @edge(type: AUTHORED, direction: IN) @node(label: User) {\n    name\n  }\n}\n```\n\n### Full CRUD Operations\n\n1. [CREATE](./docs/language/create.md)\n2. [MATCH](./docs/language/match.md)\n3. [UPDATE](./docs/language/update.md)\n4. [DELETE](./docs/language/delete.md)\n\n### Play on your desktop\n\n[Playground](https://github.com/danstarns/dgql/tree/main/packages/playground).\n\n[![Image from Gyazo](https://i.gyazo.com/88e3a580586197e51e246c763d4f594e.gif)](https://gyazo.com/88e3a580586197e51e246c763d4f594e)\n\n## Licence\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanstarns%2Fdgql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanstarns%2Fdgql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanstarns%2Fdgql/lists"}