{"id":14976150,"url":"https://github.com/usama0121/neo4j-graphql-py","last_synced_at":"2025-10-27T18:30:34.853Z","repository":{"id":45178104,"uuid":"283796223","full_name":"Usama0121/neo4j-graphql-py","owner":"Usama0121","description":"A GraphQL to Cypher query execution layer for Neo4j and Python GraphQL implementations.","archived":false,"fork":false,"pushed_at":"2022-01-03T17:53:45.000Z","size":64,"stargazers_count":21,"open_issues_count":7,"forks_count":8,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-09-06T07:11:40.023Z","etag":null,"topics":["graph","graphql","graphql-api","graphql-python","graphql-query","graphql-query-builder","graphql-resolver","graphql-server","graphql-server-framework","neo4j","neo4j-database","neo4j-driver","neo4j-server","python","python-3","python-graphql-server","python3","python3-library"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Usama0121.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-07-30T14:23:49.000Z","updated_at":"2024-08-12T10:29:13.000Z","dependencies_parsed_at":"2022-09-02T08:51:12.834Z","dependency_job_id":null,"html_url":"https://github.com/Usama0121/neo4j-graphql-py","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/Usama0121/neo4j-graphql-py","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Usama0121%2Fneo4j-graphql-py","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Usama0121%2Fneo4j-graphql-py/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Usama0121%2Fneo4j-graphql-py/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Usama0121%2Fneo4j-graphql-py/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Usama0121","download_url":"https://codeload.github.com/Usama0121/neo4j-graphql-py/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Usama0121%2Fneo4j-graphql-py/sbom","scorecard":{"id":146445,"data":{"date":"2025-08-11","repo":{"name":"github.com/Usama0121/neo4j-graphql-py","commit":"13016b4a907bf6df2be43c533af11264495c9ef5"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.5,"checks":[{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/python-package.yml:22: update your workflow using https://app.stepsecurity.io/secureworkflow/Usama0121/neo4j-graphql-py/python-package.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/python-package.yml:24: update your workflow using https://app.stepsecurity.io/secureworkflow/Usama0121/neo4j-graphql-py/python-package.yml/master?enable=pin","Warn: pipCommand not pinned by hash: .github/workflows/python-package.yml:29","Warn: pipCommand not pinned by hash: .github/workflows/python-package.yml:30","Warn: pipCommand not pinned by hash: .github/workflows/python-package.yml:31","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   3 pipCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/python-package.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"License","score":9,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Warn: project license file does not contain an FSF or OSI license."],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":0,"reason":"13 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: PYSEC-2021-98 / GHSA-68w8-qjq3-2gfm","Warn: Project is vulnerable to: GHSA-7xr5-9hcq-chf9","Warn: Project is vulnerable to: GHSA-8x94-hmjh-97hq","Warn: Project is vulnerable to: PYSEC-2020-34 / GHSA-fr28-569j-53c4","Warn: Project is vulnerable to: PYSEC-2021-9 / GHSA-fvgf-6h6h-3322","Warn: Project is vulnerable to: PYSEC-2020-33 / GHSA-m6gj-h9gm-gw44","Warn: Project is vulnerable to: PYSEC-2021-99 / GHSA-p99v-5w3c-jqq9","Warn: Project is vulnerable to: GHSA-rrqc-c2jx-6jgv","Warn: Project is vulnerable to: GHSA-rxjp-mfm9-w4wr","Warn: Project is vulnerable to: GHSA-v6rh-hp5x-86rv","Warn: Project is vulnerable to: PYSEC-2021-6 / GHSA-xgxc-v2qg-chmh","Warn: Project is vulnerable to: GHSA-xpfp-f569-q3p2","Warn: Project is vulnerable to: PYSEC-2023-179 / GHSA-8mjr-6c96-39w8"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-16T09:29:39.317Z","repository_id":45178104,"created_at":"2025-08-16T09:29:39.317Z","updated_at":"2025-08-16T09:29:39.317Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281319718,"owners_count":26481047,"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","status":"online","status_checked_at":"2025-10-27T02:00:05.855Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["graph","graphql","graphql-api","graphql-python","graphql-query","graphql-query-builder","graphql-resolver","graphql-server","graphql-server-framework","neo4j","neo4j-database","neo4j-driver","neo4j-server","python","python-3","python-graphql-server","python3","python3-library"],"created_at":"2024-09-24T13:53:23.675Z","updated_at":"2025-10-27T18:30:34.591Z","avatar_url":"https://github.com/Usama0121.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# neo4j-graphql-py\n\nA GraphQL to Cypher query execution layer for Neo4j and Python GraphQL implementations.\n\n## Installation and usage\n\nInstall\n\n```\npip install neo4j-graphql-py\n```\n\n\nThen call `neo4j_graphql()` in your GraphQL resolver. Your GraphQL query will be translated to Cypher and the query passed to Neo4j.\n\n~~~python\nfrom neo4j_graphql_py import neo4j_graphql\n\ndef resolve(obj, info, **kwargs):\n    return neo4j_graphql(obj, info.context, info, **kwargs)\n\nresolvers = {\n  'Query': {\n    'Movie':resolve\n  }\n}\n~~~\n\n## What is `neo4j-graphql-py`\n\nA package to make it easier to use GraphQL and [Neo4j](https://neo4j.com/) together. `neo4j-graphql-py` translates GraphQL queries to a single [Cypher](https://neo4j.com/developer/cypher/) query, eliminating the need to write queries in GraphQL resolvers and for batching queries. It also exposes the Cypher query language through GraphQL via the `@cypher` schema directive.\n\n## How it works\n\n### Start with a GraphQL schema\n\nGraphQL First Development is all about starting with a well defined GraphQL schema. Here we'll use the GraphQL schema IDL syntax:\n\n~~~python\ntype_defs = '''\ndirective @cypher(statement: String!) on FIELD_DEFINITION\ndirective @relation(name:String!, direction:String!) on FIELD_DEFINITION\n\ntype Movie {\n  movieId: ID!\n  title: String\n  year: Int\n  plot: String\n  poster: String\n  imdbRating: Float\n  similar(first: Int = 3, offset: Int = 0): [Movie] @cypher(statement: \"MATCH (this)-[:IN_GENRE]-\u003e(:Genre)\u003c-[:IN_GENRE]-(o:Movie) RETURN o\")\n  degree: Int @cypher(statement: \"RETURN SIZE((this)--\u003e())\")\n  actors(first: Int = 3, offset: Int = 0): [Actor] @relation(name: \"ACTED_IN\", direction:\"IN\")\n}\n\ntype Actor {\n  id: ID!\n  name: String\n  movies: [Movie]\n}\n\n\ntype Query {\n  Movie(id: ID, title: String, year: Int, imdbRating: Float, first: Int, offset: Int): [Movie]\n}\n'''\n~~~\n\nWe define two types, `Movie` and `Actor` as well as a top level Query `Movie` which becomes our entry point. This looks like a standard GraphQL schema, except for the use of two directives `@relation` and `@cypher`. In GraphQL directives allow us to annotate fields and provide an extension point for GraphQL.\n\n* `@cypher` directive - maps the specified Cypher query to the value of the field. In the Cypher query, `this` is bound to the current object being resolved.\n* `@relation` directive - used to indicate relationships in the data model. The `name` argument specifies the relationship type, and `direction` indicates the direction of the relationship (\"IN\" or \"OUT\" are valid values)\n\n\n\n### Translate GraphQL To Cypher\n\nInside each resolver, use `neo4j-graphql()` to generate the Cypher required to resolve the GraphQL query, passing through the query arguments, context and resolveInfo objects.\n\n~~~python\nfrom neo4j_graphql_py import neo4j_graphql\n\nresolvers = {\n  # entry point to GraphQL service\n  'Query': {\n    'Movie': lambda obj, info, **kwargs: neo4j_graphql(obj, info.context,info, **kwargs)\n  }\n}\n~~~\n\nGraphQL to Cypher translation works by inspecting the GraphQL schema, the GraphQL query and arguments. For example, this simple GraphQL query\n\n~~~graphql\n{\n  Movie(title: \"River Runs Through It, A\") {\n    title\n    year\n    imdbRating\n  }\n}\n~~~\n\nis translated into the Cypher query\n\n~~~cypher\nMATCH (movie:Movie {title: \"River Runs Through It, A\"})\nRETURN movie { .title , .year , .imdbRating } AS movie\nSKIP 0\n~~~\n\nA slightly more complicated traversal\n\n~~~graphql\n{\n  Movie(title: \"River Runs Through It, A\") {\n    title\n    year\n    imdbRating\n    actors {\n      name\n    }\n  }\n}\n~~~\n\nbecomes\n\n~~~cypher\nMATCH (movie:Movie {title: \"River Runs Through It, A\"})\nRETURN movie { .title , .year , .imdbRating, actors: [(movie)\u003c-[:ACTED_IN]-(movie_actors:Actor) | movie_actors { .name }] }\nAS movie\nSKIP 0\n~~~\n\n## `@cypher` directive\n\n**NOTE: The `@cypher` directive has a dependency on the APOC procedure library, specifically the function `apoc.cypher.runFirstColumn` to run sub-queries. If you'd like to make use of the `@cypher` feature you'll need to install [appropriate version of APOC](https://github.com/neo4j-contrib/neo4j-apoc-procedures) in Neo4j**\n\nGraphQL is fairly limited when it comes to expressing complex queries such as filtering, or aggregations. We expose the graph querying language Cypher through GraphQL via the `@cypher` directive. Annotate a field in your schema with the `@cypher` directive to map the results of that query to the annotated GraphQL field. For example:\n\n~~~graphql\ntype Movie {\n  movieId: ID!\n  title: String\n  year: Int\n  plot: String\n  similar(first: Int = 3, offset: Int = 0): [Movie] @cypher(statement: \"MATCH (this)-[:IN_GENRE]-\u003e(:Genre)\u003c-[:IN_GENRE]-(o:Movie) RETURN o ORDER BY COUNT(*) DESC\")\n}\n~~~\n\nThe field `similar` will be resolved using the Cypher query\n\n~~~cypher\nMATCH (this)-[:IN_GENRE]-\u003e(:Genre)\u003c-[:IN_GENRE]-(o:Movie) RETURN o ORDER BY COUNT(*) DESC\n~~~\n\nto find movies with overlapping Genres.\n\nQuerying a GraphQL field marked with a `@cypher` directive executes that query as a subquery:\n\n*GraphQL:*\n~~~graphql\n{\n  Movie(title: \"River Runs Through It, A\") {\n    title\n    year\n    imdbRating\n    actors {\n      name\n    }\n    similar(first: 3) {\n      title\n    }\n  }\n}\n~~~\n\n*Cypher:*\n~~~cypher\nMATCH (movie:Movie {title: \"River Runs Through It, A\"})\nRETURN movie { .title , .year , .imdbRating,\n  actors: [(movie)\u003c-[:ACTED_IN]-(movie_actors:Actor) | movie_actors { .name }],\n  similar: [ x IN apoc.cypher.runFirstColumn(\"\n        WITH {this} AS this\n        MATCH (this)-[:IN_GENRE]-\u003e(:Genre)\u003c-[:IN_GENRE]-(o:Movie)\n        RETURN o\",\n        {this: movie}, true) | x { .title }][..3]\n} AS movie\nSKIP 0\n~~~\n\n\n### Query Neo4j\n\nInject a Neo4j driver instance in the context of each GraphQL request and `neo4j-graphql-py` will query the Neo4j database and return the results to resolve the GraphQL query.\n\n~~~python\nfrom neo4j_graphql_py import make_executable_schema\nschema = make_executable_schema(type_defs, resolvers)\n~~~\n\n~~~python\nimport neo4j\ndef context(request):\n    global driver\n    if driver is None:\n        driver = neo4j.GraphDatabase.driver(\"bolt://localhost:7687\", auth=(\"neo4j\", \"neo4j\"))\n\n    return {'driver': driver, 'request': request}\n~~~\n\n~~~python\nfrom ariadne.asgi import GraphQL\nimport uvicorn\nrootValue = {}\napp = GraphQL(schema=schema, root_value=rootValue, context_value=context, debug=True)\nuvicorn.run(app)\n~~~\n\nSee [/examples](https://github.com/Usama0121/neo4j-graphql-py/tree/master/examples/ariadne_uvicorn) for complete examples using different GraphQL server libraries.\n\n\n## Benefits\n\n* Send a single query to the database\n* No need to write queries for each resolver\n* Exposes the power of the Cypher query language through GraphQL\n\n## Examples\n\nSee [/examples](https://github.com/Usama0121/neo4j-graphql-py/tree/master/examples) for complete examples using different GraphQL server libraries.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fusama0121%2Fneo4j-graphql-py","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fusama0121%2Fneo4j-graphql-py","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fusama0121%2Fneo4j-graphql-py/lists"}