i made a neo4j graph database in the desktop application and now i want to make an api for the same data base. first i tried to use the graph ql toolbox extension on the desktop application and i got queries to work but i couldnt figure out how to do anything with like making an api and connecting it to our website. im now trying it in vscode by following this and this guide. im trying to use the introspect tool because my database is pretty big and i dont want to manually make each type and define its properties. i have no experience with apollo servers so i tried to follow the guide but its not working for me. here is the index.js file
import { startStandaloneServer } from '@apollo/server/standalone';
import { Neo4jGraphQL } from "@neo4j/graphql";
import { toGraphQLTypeDefs } from "@neo4j/introspector";
import neo4j from "neo4j-driver";
const driver = neo4j.driver(
"neo4j://localhost:7687",
neo4j.auth.basic("neo4j", "password")
);
const sessionFactory = () =>
driver.session({ defaultAccessMode: neo4j.session.READ });
// We create a async function here until "top level await" has landed
// so we can use async/await
async function main() {
const readonly = true; // We don't want to expose mutations in this case
const typeDefs = await toGraphQLTypeDefs(sessionFactory, readonly);
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}`);
}
main();
here is the output