Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 41 additions & 1 deletion modules/ROOT/pages/getting-started/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ cd neo4j-graphql-example
npm init es6 --yes
----
+
. Create an empty `index.js` file which with all of the code for this example:
. Create an empty `index.js` file which will contain all of the code for this example:
+
[source, bash, indent=0]
----
Expand Down Expand Up @@ -168,6 +168,46 @@ If successful, you should see the following output:

The address http://localhost:4000/ is the default URL in which Apollo Server starts at.

This is how your `index.js` file should look after following the previous steps:

[source, javascript]
----
import { ApolloServer } from '@apollo/server';
import { startStandaloneServer } from '@apollo/server/standalone';
import { Neo4jGraphQL } from "@neo4j/graphql";
import neo4j from "neo4j-driver";

const typeDefs = `#graphql
type Movie {
title: String
actors: [Actor!]! @relationship(type: "ACTED_IN", direction: IN)
}

type Actor {
name: String
movies: [Movie!]! @relationship(type: "ACTED_IN", direction: OUT)
}
`;

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

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

const server = new ApolloServer({
schema: await neoSchema.getSchema(),
});

const { url } = await startStandaloneServer(server, {
context: async ({ req }) => ({ req }),
listen: { port: 4000 },
});

console.log(`🚀 Server ready at ${url}`);
----

== Create nodes in the database

. Visit http://localhost:4000/ in your web browser.
Expand Down