Neo4j GraphQL Server
  • Introduction
  • Neo4j GraphQL Server
  • Neo4j GraphQL Binding
    • neo4jGraphQLBinding
    • neo4jIDL
    • neo4jAssertConstraints
    • buildNeo4jTypeDefs
    • buildNeo4jResolvers
  • GRANDstack Starter
  • GraphQL Community Graph
Powered by GitBook
On this page
  • API Reference
  • Example
  1. Neo4j GraphQL Binding

neo4jIDL

Updates your Neo4j-GraphQL schema by calling the graphql.idl procedure.

Previousneo4jGraphQLBindingNextneo4jAssertConstraints

Last updated 6 years ago

In order to update your Neo4j-GraphQL schema, you can use the neo4jIDLexport, which sends a request to Neo4j to call the procedure using the typeDefs you provide.

Block strings in @cypher directives are supported by turning them into single line statements before sending the call to graphql.idl.

API Reference

  • typeDefs (required): Your GraphQL type definitions in .

  • driver(required): Your Neo4j driver instance (More info ).

  • log (default: false): Logs result from operation.

Example

typeDefs

type Movie @model {
  title: String!
  released: Int
  actors: [Person] @relation(name:"ACTED_IN",direction:IN)
  # computed field
  directors: [Person] @cypher(statement: """
    MATCH (this)<-[:DIRECTED]-(d) RETURN d
  """)
}
type Person @model {
  name: String!
  born: Int
  movies: [Movie] @relation(name:"ACTED_IN")
}
type Query {
  coActors(name:ID!): [Person] @cypher(statement:"""
    MATCH (p:Person {name:$name})-[:ACTED_IN]->()<-[:ACTED_IN]-(co) 
    RETURN distinct co
  """)
}
type Mutation {
  rateMovie(user:ID!, movie:ID!, rating:Int!): Int @cypher(statement: """
    MATCH (p:Person {name:$user}),(m:Movie {title:$movie}) 
    MERGE (p)-[r:RATED]->(m) SET r.rating=$rating 
    RETURN r.rating
  """)
}
schema {
   query: Query
   mutation: Mutation
}
import { neo4jIDL } from 'neo4j-graphql-binding';

neo4jIDL({
  typeDefs: typeDefs,
  driver: driver,
  log: true
});
graphql.idl
SDL format
here