# @opencreek/neo4j-graphql

> A GraphQL to Cypher query execution layer for Neo4j and JavaScript GraphQL implementations

Latest version **3.24.3-oc.2** (published 2025-03-31) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @opencreek/neo4j-graphql
pnpm add @opencreek/neo4j-graphql
yarn add @opencreek/neo4j-graphql
bun add @opencreek/neo4j-graphql
```

## Health

**Score 35/100 (D)** — status: maintenance-mode.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.24.3-oc.2 |
| Published | 2025-03-31 |
| First published | 2021-10-15 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=16.0.0 |
| Dependencies | 17 |
| Unpacked size | 2.4 MB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | Neo4j Inc. |
| Maintainers | mhlz, lionc, reckter, happenslol |
| Keywords | neo4j, graphql, server |

## Links

- npm: https://www.npmjs.com/package/@opencreek/neo4j-graphql
- Homepage: https://github.com/neo4j/graphql/tree/dev/packages/graphql
- Issues: https://github.com/neo4j/graphql/issues
- npm.io page: https://npm.io/package/@opencreek/neo4j-graphql

## Dependencies (17)

- [jose](https://npm.io/package/jose.md) ^4.13.1
- [uuid](https://npm.io/package/uuid.md) ^9.0.0
- [debug](https://npm.io/package/debug.md) ^4.3.4
- [semver](https://npm.io/package/semver.md) ^7.5.4
- [dot-prop](https://npm.io/package/dot-prop.md) ^6.0.1
- [camelcase](https://npm.io/package/camelcase.md) ^6.3.0
- [pluralize](https://npm.io/package/pluralize.md) ^8.0.0
- [deep-equal](https://npm.io/package/deep-equal.md) ^2.0.5
- [graphql-relay](https://npm.io/package/graphql-relay.md) ^0.10.0
- [graphql-compose](https://npm.io/package/graphql-compose.md) ^9.0.8
- [@apollo/subgraph](https://npm.io/package/@apollo/subgraph.md) ^2.2.3
- [@graphql-tools/merge](https://npm.io/package/@graphql-tools/merge.md) ^8.3.3
- [@graphql-tools/utils](https://npm.io/package/@graphql-tools/utils.md) ^9.0.0
- [@graphql-tools/schema](https://npm.io/package/@graphql-tools/schema.md) 9.0.19
- [@neo4j/cypher-builder](https://npm.io/package/@neo4j/cypher-builder.md) ~0.6.0
- [graphql-parse-resolve-info](https://npm.io/package/graphql-parse-resolve-info.md) ^4.12.3
- [@graphql-tools/resolvers-composition](https://npm.io/package/@graphql-tools/resolvers-composition.md) ^6.5.3

## Alternatives

- [apollo-link-http-common](https://npm.io/package/apollo-link-http-common.md) — 879.0K weekly downloads
- [react-relay](https://npm.io/package/react-relay.md) — 336.8K weekly downloads
- [relay-test-utils](https://npm.io/package/relay-test-utils.md) — 181.6K weekly downloads
- [@vendure/core](https://npm.io/package/@vendure/core.md) — 14.8K weekly downloads
- [@pnpm/deps.graph-sequencer](https://npm.io/package/@pnpm/deps.graph-sequencer.md) — 13.4K weekly downloads

## Recent versions

- 3.24.3-oc.2 (latest) — 2025-03-31
- 4.4.4-oc.test.4 — 2024-01-29
- 4.4.4-oc.test.3 — 2024-01-29
- 4.4.4-oc.test.2 — 2024-01-22
- 4.4.4-oc.test.1 — 2024-01-08
- 4.4.4-oc.test.0 — 2024-01-05
- 3.24.3-oc.1 — 2024-01-02
- 3.24.3-oc.0 — 2023-10-30
- 3.23.1-oc.custom-auth.1 — 2023-09-21
- 3.23.1-oc.custom-auth.0 — 2023-09-21
- 3.23.1-oc.3 — 2023-08-09
- 3.23.1-oc.1 — 2023-07-12
- 3.17.0-oc.2 — 2023-03-10
- 3.17.0-oc.1 — 2023-03-07
- 3.17.0-oc.0 — 2023-02-28
- … 33 more at https://npm.io/package/@opencreek/neo4j-graphql/versions

## README

# @neo4j/graphql

<p align="center">
  <a href="https://badge.fury.io/js/%40neo4j%2Fgraphql">
    <img alt="npm package" src="https://badge.fury.io/js/%40neo4j%2Fgraphql.svg">
  </a>
  <a href="https://discord.gg/neo4j">
    <img alt="Discord" src="https://img.shields.io/discord/787399249741479977?logo=discord&logoColor=white">
  </a>
  <a href="https://community.neo4j.com/c/drivers-stacks/graphql/33">
    <img alt="Discourse users" src="https://img.shields.io/discourse/users?logo=discourse&server=https%3A%2F%2Fcommunity.neo4j.com">
  </a>
</p>

A GraphQL to Cypher query execution layer for Neo4j and JavaScript GraphQL implementations.

1. [Documentation](https://neo4j.com/docs/graphql-manual/current/)

## Installation

```
$ npm install @neo4j/graphql
```

⚠ `graphql` & `neo4j-driver` are **peerDependency**(s)

```
$ npm install graphql neo4j-driver
```

## Importing

Our TypeScript source is transpiled into Common JS, this means you can use the `require` syntax;

```js
const { Neo4jGraphQL } = require("@neo4j/graphql");
```

## Quick Start

Create schema and serve over port 4000 using Apollo Server:

```js
const { Neo4jGraphQL } = require("@neo4j/graphql");
const neo4j = require("neo4j-driver");
const { ApolloServer } = require("apollo-server");

const typeDefs = `
    type Movie {
        title: String
        year: Int
        imdbRating: Float
        genres: [Genre!]! @relationship(type: "IN_GENRE", direction: OUT)
    }

    type Genre {
        name: String
        movies: [Movie!]! @relationship(type: "IN_GENRE", direction: IN)
    }
`;

const driver = neo4j.driver("bolt://localhost:7687", neo4j.auth.basic("neo4j", "letmein"));

const neoSchema = new Neo4jGraphQL({ typeDefs, driver });

async function main() {
    const schema = await neoSchema.getSchema();

    const server = new ApolloServer({
        schema,
        context: ({ req }) => ({ req }),
    });

    await server.listen(4000);

    console.log("Online");
}
```

## Example Queries

### Create Movie

```graphql
mutation {
    createMovies(input: [{ title: "The Matrix", year: 1999, imdbRating: 8.7 }]) {
        movies {
            title
        }
    }
}
```

### Connect to Genre

```graphql
mutation {
    updateMovies(
        where: { title: "The Matrix" }
        connect: { genres: { where: { node: { OR: [{ name: "Sci-fi" }, { name: "Action" }] } } } }
    ) {
        movies {
            title
        }
    }
}
```

### Create Movie and connect Genre

```graphql
mutation {
    createMovies(
        input: [
            {
                title: "The Matrix"
                year: 1999
                imdbRating: 8.7
                genres: { connect: { where: { node: { AND: [{ name: "Sci-fi" }, { name: "Action" }] } } } }
            }
        ]
    ) {
        movies {
            title
        }
    }
}
```

### Find Movies with Genres

```graphql
query {
    movies {
        title
        genres {
            name
        }
    }
}
```

## Auth

Define, nested & related, authorization rules such as; “grant update access to all moderators of a post”;

```graphql
type User {
    id: ID!
    username: String!
}

type Post {
    id: ID!
    title: String!
    moderator: User @relationship(type: "MODERATES_POST", direction: IN)
}

extend type Post @auth(rules: [{ allow: [{ moderator: { id: "$jwt.sub" } }], operations: [UPDATE] }])
```

Specify rules on fields;

```graphql
type User {
    id: ID!
    username: String!
}

extend type User {
    password: String! @auth(rules: [{ OR: [{ allow: { id: "$jwt.sub" } }, { roles: ["admin"] }] }])
}
```

Use RBAC;

```graphql
type Customer @auth(rules: [{ operations: [READ], roles: ["read:customer"] }]) {
    id: ID
    name: String
    password: String @auth(rules: [{ operations: [READ], roles: ["admin"] }])
}

type Invoice @auth(rules: [{ operations: [READ], roles: ["read:invoice"] }]) {
    id: ID
    csv: String
    total: Int
}
```

## Licence

[Apache 2.0](https://github.com/neo4j/graphql/blob/master/packages/graphql/LICENSE.txt)

---
_Source: https://npm.io/package/@opencreek/neo4j-graphql · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
