Skip to content

Instantly share code, notes, and snippets.

@danstarns
Created April 10, 2022 17:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danstarns/ecbb87c9952fa580451e1a0a294b3812 to your computer and use it in GitHub Desktop.
Save danstarns/ecbb87c9952fa580451e1a0a294b3812 to your computer and use it in GitHub Desktop.
example-neo4j-graphql
import { Neo4jGraphQL } from "@neo4j/graphql";
import * as neo4j from "neo4j-driver";
import { ApolloServer } from "apollo-server";
const typeDefs = `
type Movie {
title: String!
actors: [Person!]! @relationship(type: "ACTED_IN", direction: IN)
genres: [Genre!]! @relationship(type: "In_GENRE", direction: OUT)
}
type Person {
name: String!
movies: [Movie!]! @relationship(type: "ACTED_IN", direction: OUT)
}
type Genre {
name: String!
}
`;
const driver = neo4j.driver("URL", neo4j.auth.basic("USERNAME", "PASSWORD"));
const neoSchema = new Neo4jGraphQL({
typeDefs,
driver,
});
async function main() {
const server = new ApolloServer({
schema: await neoSchema.getSchema(),
});
await server.listen(4000);
}
main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment