I can see the generated query in my vscode terminal with debugging turned on: DEBUG=@neo4j/graphql:* node index2.js
@neo4j/graphql:execute About to execute Cypher:
Cypher:
MATCH (this:`Business`)
RETURN this { .name } AS this
Params:
{} +45ms
@neo4j/graphql:execute Execute successful, received 0 records +0ms
As you can see no results are returned. However, if I run the exact same query inside the neo4j browser I receive the expected results
╒═════════════════════════════════╕
│this │
╞═════════════════════════════════╡
│{name: "Market on Front"} │
├─────────────────────────────────┤
│{name: "Hanabi"} │
├─────────────────────────────────┤
│{name: "Zootown Brew"} │
├─────────────────────────────────┤
│{name: "Missoula Public Library"}│
├─────────────────────────────────┤
│{name: "Ninja Mike's"} │
├─────────────────────────────────┤
│{name: "KettleHouse Brewing Co."}│
├─────────────────────────────────┤
│{name: "Imagine Nation Brewing"} │
├─────────────────────────────────┤
│{name: "Ducky's Car Wash"} │
├─────────────────────────────────┤
│{name: "Neo4j"} │
└─────────────────────────────────┘
The code below is almost exactly copy/pasted from this github repo with the exception of upgrading from apollo-server
to @apollo/server
const { ApolloServer } = require("@apollo/server");
const { startStandaloneServer } = require('@apollo/server/standalone');
const neo4j = require("neo4j-driver");
const { Neo4jGraphQL } = require("@neo4j/graphql");
const resolvers = {
Business: {
waitTime: (obj, args, context, info) => {
var options = [0, 5, 10, 15, 30, 45];
return options[Math.floor(Math.random() * options.length)];
},
},
};
const typeDefs = /* GraphQL */ `
type Query {
fuzzyBusinessByName(searchString: String): [Business!]!
@cypher(
statement: """
CALL db.index.fulltext.queryNodes( 'businessNameIndex', $searchString+'~')
YIELD node RETURN node
"""
)
}
type Business {
businessId: ID!
waitTime: Int! @computed
averageStars: Float!
@cypher(
statement: "MATCH (this)<-[:REVIEWS]-(r:Review) RETURN avg(r.stars)"
)
recommended(first: Int = 1): [Business!]!
@cypher(
statement: """
MATCH (this)<-[:REVIEWS]-(:Review)<-[:WROTE]-(:User)-[:WROTE]->(:Review)-[:REVIEWS]->(rec:Business)
WITH rec, COUNT(*) AS score
RETURN rec ORDER BY score DESC LIMIT $first
"""
)
name: String!
city: String!
state: String!
address: String!
location: Point!
reviews: [Review!]! @relationship(type: "REVIEWS", direction: IN)
categories: [Category!]! @relationship(type: "IN_CATEGORY", direction: OUT)
}
type User {
userID: ID!
name: String!
reviews: [Review!]! @relationship(type: "WROTE", direction: OUT)
}
type Review {
reviewId: ID!
stars: Float!
date: Date!
text: String
user: User! @relationship(type: "WROTE", direction: IN)
business: Business! @relationship(type: "REVIEWS", direction: OUT)
}
type Category {
name: String!
businesses: [Business!]! @relationship(type: "IN_CATEGORY", direction: IN)
}
`;
const driver = neo4j.driver(
"bolt://localhost:7687",
neo4j.auth.basic("database", "password") # this is not the default database
);
const neoSchema = new Neo4jGraphQL({ typeDefs, driver });
neoSchema.getSchema().then(async (schema) => {
const server = new ApolloServer({ schema });
const { url } = await startStandaloneServer(server, {
listen: { port: 4000 },
});
});