Created
April 10, 2022 17:52
-
-
Save danstarns/ecbb87c9952fa580451e1a0a294b3812 to your computer and use it in GitHub Desktop.
example-neo4j-graphql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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