Learn with Neo4j's New "Get to Know Graph & GenAI" Webinar Series >>

Neo4j logo

Neo4j & GraphQL

Seamlessly integrate the flexibility of the powerful GraphQL with the robust Neo4j graph database to build API-driven, intelligent applications.

Build Intelligent, Modern Applications with Ease

Interact with data intuitively. Use GraphQL's declarative queries to explore patterns and relationships effortlessly without having to learn Cypher.

Build cross-platform and mobile applications with GraphQL for Neo4j AuraDB. Enjoy the flexibility of a fully managed service and the customization of the open-source Neo4j GraphQL.

You Have Two Deployment Options:

Fully Managed

With the managed GraphQL service, you needn't worry about deployment or management due to seamless, high-performance API access out of the box.

Get Started

Self Managed

Deploy yourself. The Neo4j GraphQL enables rapid API development with full flexibility for integration into custom workflows.

Learn More

Benefits of Neo4j & GraphQL

Low Code

Not familiar with Cypher? No problem. GraphQL automatically translates queries into a single optimized Cypher query. Focus on building applications with minimal backend code while Neo4j GraphQL handles the rest.

Graph Context Made Easy

Build context-aware applications with data-rich, graph-native APIs that seamlessly align with graph databases. GraphQL with Neo4j enables deeper insights, smarter recommendations, and more dynamic user experiences.

Developer Friendly

Neo4j GraphQL generates Cypher from GraphQL, GraphQL CRUD API from type definitions, auto-generated resolvers, and custom logic with @cypher schema directive. It also comes with powerful authorization to secure your GraphQL API.

Open and Flexible

Neo4j GraphQL is available as a service in AuraDB or in library format. You can quickly build API-driven applications across open-source frameworks (React, Vue, Angular, and others) and achieve exceptional flexibility. Deploy across on-prem, cloud, or in a serverless setup.

Neo4j & GraphQL Features

Generate GraphQL CRUD API

Automatically create Query and Mutation types from your type definitions to provide instant CRUD functionality.

Configure and extend the GraphQL CRUD API to help define the database schema and GraphQL schema using the same type of definitions.

type Movie {
  title: String!
  actors: [Person!]!
    @relationship(type: "ACTED_IN", direction: IN)
}

type Person {
  name: String!
}

Generate Cypher from GraphQL

Generate a single Cypher query to resolve any arbitrary GraphQL request.

This means the resolvers are automatically implemented for your scenario. There is no need to write boilerplate data-fetching code. GraphQL generates the database query and handles the database call. Since a single Cypher query is generated, it hugely boosts performance and mitigates the N+1 query problem.

{
  movies(where: { title: "River Runs Through It" }) {
    title
    actors {
      name
    }
  }
}
MATCH (m:Movie)<-[:ACTED_IN]-(a:Actor)
WHERE m.title = "River Runs Through It"
RETURN *

Extend GraphQL with Cypher

Since GraphQL is an API query language and not a database query language, it lacks semantics for operations such as aggregations, projections, and more complex graph traversals.

Extend the power of GraphQL using @cypher with GraphQL schema directives that bind the results of a Cypher query to a GraphQL field. This allows for the expression of complex logic using Cypher and for Query and Mutation fields to define custom data fetching or mutation logic.

The Neo4j native graph database makes complex and multi-hop graph traversals highly performant to provide blazing-fast query responses

type Movie {
  title: String!
  actors: [Person!]!
    @relationship(type: "ACTED_IN", direction: IN)
  similar(first: Int = 3): [Movie!]!
    @cypher(
      statement: """
      MATCH (this)<-[:ACTED_IN|:DIRECTED]-(o)-[:ACTED_IN|:DIRECTED]->(rec:Movie)
      WITH rec, COUNT(*) AS score
      RETURN rec ORDER BY score DESC LIMIT $first
      """
    )
}

type Person {
  name: String!
}

Secure APIs with Built-In Auth

Use the out-of-the-box Auth directive to enable authorization rules to the GraphQL API using JSON Web Tokens (JWTs).

The Auth directive reduces the complexity involved in building a secure GraphQL API. Auth provides a working solution for users to quickly and easily "spin up" secure services.

Also, the power of Cypher effectively enables the translation of complex authorization rules into a single Cypher query.

type Movie {
  title: String!
  actors: [Person!]!
    @relationship(type: "ACTED_IN", direction: IN)
}

type Person {
  name: String!
}

extend type Movie
  @auth(
    rules: [{ operations: [UPDATE], allow: { actors: { name: "$jwt.sub" } } }]
  )

Easily Add Relationship Properties

Adding relationships into your data model gives your data the context to run complex queries across wide sections of your graph.

Use Neo4j and GraphQL to define an interface that represents your relationship properties. You can use this with multiple relationships by adding the properties key to your existing relationship directives.

Streamline development efforts and enable scalable, flexible applications with minimal effort.

type Movie {
  title: String!
  actors: [Person!]!
    @relationship(type: "ACTED_IN", direction: IN, properties: "ActedIn")
}

type Person {
  name: String!
}

interface ActedIn {
  roles: [String!]!
}

Load New Pages With Cursor-Based Pagination

Cursor-based pagination is the preferred method for delivering an infinite scroll on the front end.

The biggest advantage of cursor-based pagination is how it handles real-time data changes effectively. Cursors don't require the data to remain static when you add or remove records. Thus, each new page still loads correctly.

Get cursor-based pagination for all relationship fields with the filtering and sorting you’re already familiar with.

{
  movies(where: { title: "River Runs Through It" }) {
    title
    actorsConnection(first: 10, after: "opaqueCursor") {
      edges {
        roles
        node {
          name
        }
      }
      pageInfo {
        endCursor
        hasNextPage
      }
    }
  }
}