I'm following the Getting Started guide, but when I try to execute the mutation in Apollo Sandbox, I get:
{
"errors": [
{
"message": "Failed to connect to server. Please ensure that your database is listening on the correct host and port and that you have compatible encryption settings both on Neo4j server and driver. Note that the default encryption setting has changed in Neo4j 4.0. Caused by: connect ECONNREFUSED ::1:7687",
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"createMovies"
],
"extensions": {
"code": "INTERNAL_SERVER_ERROR",
"exception": {
"code": "ServiceUnavailable",
"name": "Neo4jError",
"retriable": true,
"stacktrace": [
"Neo4jError: Failed to connect to server. Please ensure that your database is listening on the correct host and port and that you have compatible encryption settings both on Neo4j server and driver. Note that the default encryption setting has changed in Neo4j 4.0. Caused by: connect ECONNREFUSED ::1:7687",
" at new Neo4jError (/Users/tianxiong.xiong/test/neo4j-graphql-example/node_modules/neo4j-driver-core/lib/error.js:77:16)",
" at newError (/Users/tianxiong.xiong/test/neo4j-graphql-example/node_modules/neo4j-driver-core/lib/error.js:113:12)",
" at NodeChannel._handleConnectionError (/Users/tianxiong.xiong/test/neo4j-graphql-example/node_modules/neo4j-driver-bolt-connection/lib/channel/node/node-channel.js:227:56)",
" at Socket.emit (node:events:526:28)",
" at emitErrorNT (node:internal/streams/destroy:164:8)",
" at emitErrorCloseNT (node:internal/streams/destroy:129:3)",
" at processTicksAndRejections (node:internal/process/task_queues:83:21)"
]
}
}
}
],
"data": null
}
I've a Neo4j DB spun up separately w/ docker-compose
like:
version: '3'
services:
neo4j:
image: neo4j:5.3.0
ports:
- "7474:7474"
- "7687:7687"
volumes:
- neo4j-data:/data
volumes:
neo4j-data:
And confirmed I'm able to connect to bolt://localhost:7687
via a different client.
I suspect I'm missing something when it comes to configuring the Apollo server, but I can't see that I've done anything wrong. Here's my index.js
:
const { Neo4jGraphQL } = require("@neo4j/graphql");
const { ApolloServer, gql } = require("apollo-server");
const neo4j = require("neo4j-driver");
const typeDefs = gql`
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 });
neoSchema.getSchema().then((schema) => {
const server = new ApolloServer({
schema,
});
server.listen().then(({ url }) => {
console.log(`🚀 Server ready at ${url}`);
});
})
where password
is the confirmed password for my local DB instance.