I am following along with the Full Stack GraphQL Book Club. In Chapter 4: The Neo4j GraphQL Library, we are setting up GraphQL API to work with Neo4j. The code given is the class works. However, when I try changing to match my data schema I just get errors.
ReferenceError: resolvers is not defined
at Object. (/Users/seraphitssingh/Documents/GitHub/Neo4jAPI/index.js:23:48)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:17:47
[nodemon] app crashed - waiting for file changes before starting...
From what I understand from the class and the book this should be all that is need. Am I misunderstanding? what am I missing?
/Users/seraphitssingh/Documents/GitHub/Neo4jAPI/node_modules/graphql/error/syntaxError.js:15
return new _GraphQLError.GraphQLError(`Syntax Error: ${description}`, {
What ${description}` is the error talking about?
And What do I do?
^
GraphQLError: Syntax Error: Unexpected Name "const".
at syntaxError (/Users/seraphitssingh/Documents/GitHub/Neo4jAPI/node_modules/graphql/error/syntaxError.js:15:10)
at Parser.unexpected (/Users/seraphitssingh/Documents/GitHub/Neo4jAPI/node_modules/graphql/language/parser.js:1458:41)
at Parser.parseDefinition (/Users/seraphitssingh/Documents/GitHub/Neo4jAPI/node_modules/graphql/language/parser.js:212:16)
at Parser.many (/Users/seraphitssingh/Documents/GitHub/Neo4jAPI/node_modules/graphql/language/parser.js:1511:26)
at Parser.parseDocument (/Users/seraphitssingh/Documents/GitHub/Neo4jAPI/node_modules/graphql/language/parser.js:122:25)
at parse (/Users/seraphitssingh/Documents/GitHub/Neo4jAPI/node_modules/graphql/language/parser.js:32:17)
at visitTypeSources (/Users/seraphitssingh/Documents/GitHub/Neo4jAPI/node_modules/@neo4j/graphql/node_modules/@graphql-tools/merge/cjs/typedefs-mergers/merge-typedefs.js:48:54)
at mergeGraphQLTypes (/Users/seraphitssingh/Documents/GitHub/Neo4jAPI/node_modules/@neo4j/graphql/node_modules/@graphql-tools/merge/cjs/typedefs-mergers/merge-typedefs.js:66:22)
at mergeTypeDefs (/Users/seraphitssingh/Documents/GitHub/Neo4jAPI/node_modules/@neo4j/graphql/node_modules/@graphql-tools/merge/cjs/typedefs-mergers/merge-typedefs.js:13:22)
at getDocument (/Users/seraphitssingh/Documents/GitHub/Neo4jAPI/node_modules/@neo4j/graphql/dist/schema/get-document.js:24:38) {
path: undefined,
locations: [ { line: 2, column: 1 } ],
extensions: [Object: null prototype] {}
Hi @Seraphits - the error looks to be caused by line 23 in the snippet you posted:
const neoSchema = new Neo4jGraphQL({ typeDefs, resolvers, driver });
The resolvers variable is not defined in your snippet. This variable was used in the book code as an example of passing a resolver map (an object that contained manually implemented resolver functions), however, it looks like you don't need that here. Could you try removing the reference to resolvers and see if that works (passing just the driver and typeDefs):
const neoschema = new Neo4jGraphQL({typeDefs, driver})