Open idkjs opened 7 years ago
Can you post a Schema file that we can use to reproduce this issue?
I posted the file to this repo.
So I then added a Business and Review mongoose model to the models folder and ran create-graphql generate -tmlc Business --schema Business
. It looks like its creating the connection first then dies. This is the output:
…/tester/tester-gql ⬢ 6.9.2 create-graphql generate -tmlc Business --schema Business
create src/connection/BusinessConnection.js
🔥 Connection created!
events.js:160
throw er; // Unhandled 'error' event
^
TypeError: Cannot read property 'forEach' of undefined
at /Users/devworx/.nvm/versions/node/v6.9.2/lib/node_modules/generator-graphql/generators/utils.js:171:27
at Array.forEach (native)
at getSchemaFieldsFromAst (/Users/devworx/.nvm/versions/node/v6.9.2/lib/node_modules/generator-graphql/generators/utils.js:162:19)
at Context.visitExpression (/Users/devworx/.nvm/versions/node/v6.9.2/lib/node_modules/generator-graphql/generators/utils.js:213:18)
at Context.invokeVisitorMethod (/Users/devworx/.nvm/versions/node/v6.9.2/lib/node_modules/generator-graphql/node_modules/ast-types/lib/path-visitor.js:344:49)
at Visitor.PVp.visitWithoutReset (/Users/devworx/.nvm/versions/node/v6.9.2/lib/node_modules/generator-graphql/node_modules/ast-types/lib/path-visitor.js:196:32)
at visitChildren (/Users/devworx/.nvm/versions/node/v6.9.2/lib/node_modules/generator-graphql/node_modules/ast-types/lib/path-visitor.js:246:25)
at Visitor.PVp.visitWithoutReset (/Users/devworx/.nvm/versions/node/v6.9.2/lib/node_modules/generator-graphql/node_modules/ast-types/lib/path-visitor.js:204:20)
at NodePath.each (/Users/devworx/.nvm/versions/node/v6.9.2/lib/node_modules/generator-graphql/node_modules/ast-types/lib/path.js:101:26)
at visitChildren (/Users/devworx/.nvm/versions/node/v6.9.2/lib/node_modules/generator-graphql/node_modules/ast-types/lib/path-visitor.js:219:18)
events.js:160
throw er; // Unhandled 'error' event
^
TypeError: Cannot read property 'forEach' of undefined
at /Users/devworx/.nvm/versions/node/v6.9.2/lib/node_modules/generator-graphql/generators/utils.js:171:27
at Array.forEach (native)
at getSchemaFieldsFromAst (/Users/devworx/.nvm/versions/node/v6.9.2/lib/node_modules/generator-graphql/generators/utils.js:162:19)
at Context.visitExpression (/Users/devworx/.nvm/versions/node/v6.9.2/lib/node_modules/generator-graphql/generators/utils.js:213:18)
at Context.invokeVisitorMethod (/Users/devworx/.nvm/versions/node/v6.9.2/lib/node_modules/generator-graphql/node_modules/ast-types/lib/path-visitor.js:344:49)
at Visitor.PVp.visitWithoutReset (/Users/devworx/.nvm/versions/node/v6.9.2/lib/node_modules/generator-graphql/node_modules/ast-types/lib/path-visitor.js:196:32)
at visitChildren (/Users/devworx/.nvm/versions/node/v6.9.2/lib/node_modules/generator-graphql/node_modules/ast-types/lib/path-visitor.js:246:25)
events.js:160
throw er; // Unhandled 'error' event
^
TypeError: Cannot read property 'forEach' of undefined
at /Users/devworx/.nvm/versions/node/v6.9.2/lib/node_modules/generator-graphql/generators/utils.js:171:27
at Array.forEach (native)
at getSchemaFieldsFromAst (/Users/devworx/.nvm/versions/node/v6.9.2/lib/node_modules/generator-graphql/generators/utils.js:162:19)
at Context.visitExpression (/Users/devworx/.nvm/versions/node/v6.9.2/lib/node_modules/generator-graphql/generators/utils.js:213:18)
at Context.invokeVisitorMethod (/Users/devworx/.nvm/versions/node/v6.9.2/lib/node_modules/generator-graphql/node_modules/ast-types/lib/path-visitor.js:344:49)
at Visitor.PVp.visitWithoutReset (/Users/devworx/.nvm/versions/node/v6.9.2/lib/node_modules/generator-graphql/node_modules/ast-types/lib/path-visitor.js:196:32)
at visitChildren (/Users/devworx/.nvm/versions/node/v6.9.2/lib/node_modules/generator-graphql/node_modules/ast-types/lib/path-visitor.js:246:25)
at Visitor.PVp.visitWithoutReset (/Users/devworx/.nvm/versions/node/v6.9.2/lib/node_modules/generator-graphql/node_modules/ast-types/lib/path-visitor.js:204:20)
at NodePath.each (/Users/devworx/.nvm/versions/node/v6.9.2/lib/node_modules/generator-graphql/node_modules/ast-types/lib/path.js:101:26)
at visitChildren (/Users/devworx/.nvm/versions/node/v6.9.2/lib/node_modules/generator-graphql/node_modules/ast-types/lib/path-visitor.js:219:18)
at Visitor.PVp.visitWithoutReset (/Users/devworx/.nvm/versions/node/v6.9.2/lib/node_modules/generator-graphql/node_modules/ast-types/lib/path-visitor.js:204:20)
at NodePath.each (/Users/devworx/.nvm/versions/node/v6.9.2/lib/node_modules/generator-graphql/node_modules/ast-types/lib/path.js:101:26)
at visitChildren (/Users/devworx/.nvm/versions/node/v6.9.2/lib/node_modules/generator-graphql/node_modules/ast-types/lib/path-visitor.js:219:18)
(node:31999) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Exited with status 1
(node:31999) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): Error: Exited with status 1
(node:31999) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 3): Error: Exited with status 1
Then I tried just creating the type from the mongoose model. Didnt works. Incidentally, this same schema runs in another project.
…/tester/tester-gql ⬢ 6.9.2 c3c3ab0a master create-graphql generate -t Business --schema Business
events.js:160
throw er; // Unhandled 'error' event
^
TypeError: Cannot read property 'forEach' of undefined
at /Users/devworx/.nvm/versions/node/v6.9.2/lib/node_modules/generator-graphql/generators/utils.js:171:27
at Array.forEach (native)
at getSchemaFieldsFromAst (/Users/devworx/.nvm/versions/node/v6.9.2/lib/node_modules/generator-graphql/generators/utils.js:162:19)
at Context.visitExpression (/Users/devworx/.nvm/versions/node/v6.9.2/lib/node_modules/generator-graphql/generators/utils.js:213:18)
at Context.invokeVisitorMethod (/Users/devworx/.nvm/versions/node/v6.9.2/lib/node_modules/generator-graphql/node_modules/ast-types/lib/path-visitor.js:344:49)
at Visitor.PVp.visitWithoutReset (/Users/devworx/.nvm/versions/node/v6.9.2/lib/node_modules/generator-graphql/node_modules/ast-types/lib/path-visitor.js:196:32)
at visitChildren (/Users/devworx/.nvm/versions/node/v6.9.2/lib/node_modules/generator-graphql/node_modules/ast-types/lib/path-visitor.js:246:25)
at Visitor.PVp.visitWithoutReset (/Users/devworx/.nvm/versions/node/v6.9.2/lib/node_modules/generator-graphql/node_modules/ast-types/lib/path-visitor.js:204:20)
at NodePath.each (/Users/devworx/.nvm/versions/node/v6.9.2/lib/node_modules/generator-graphql/node_modules/ast-types/lib/path.js:101:26)
at visitChildren (/Users/devworx/.nvm/versions/node/v6.9.2/lib/node_modules/generator-graphql/node_modules/ast-types/lib/path-visitor.js:219:18)
(node:32529) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Exited with status 1
I reran the process only now i switch nvm to 6.9.2. Same result.
…/tester/tester-gql ⬢ 6.9.2 c3c3ab0a master cd .. ✓ 5357 17:09:36
…/CODE/tester ⬢ 8.1.2 nvm use 6.9.2 ✓ 5358 17:10:04
Now using node v6.9.2 (npm v3.10.9)
…/CODE/tester ⬢ 6.9.2 nvm install 6.9.2 ✓ 5359 17:10:27
v6.9.2 is already installed.
Now using node v6.9.2 (npm v3.10.9)
…/CODE/tester ⬢ 6.9.2 create-graphql init tester692 ✓ 5360 17:10:52
`-/+o+/-
`+ooooooo/
`-+ooooooooo/-`
`.:+++::oo+++o+:/++/-.
...` `-/++/-` -o+. :o+. .:/++:.` `...`
`:++oo++:+++:.` :o+. -o+. `-/++//++oo++-
/oooooooo+.` /o/` .++- `.ooooooooo-
.+oooooo/` `+o: `+o: .+oooooo/`
`.:oo:. .+o: `/o/` `./o+-`
.oo` .++- `:o/` -o+
.oo` -++. :o+. -o+
.oo` :o+. -++. -o+
.oo` :o/` -++- -o+
.oo``/o/` .+o- -o+
.oo./o: `+o:-o+
.:+oo+o/ `+o+oo/-`
+oooooooo++++++++++++++++++++++++++++++ooooooooo:
-oooooooo+/-.```````````````````````.-/oooooooo+.
.:++++:.:/++:-` `-/++:.-/+++/:`
`-/++/-` `..`` `-/+/-.
.:+++:/oooo+::++/-`
`/ooooooooo.
/oooooo+-
`-:::-`
✓ GraphQL project tester692 created.
✓ Dependencies installed! 😎
✓ Your new project with GraphQL has been created! 🔥
…/CODE/tester ⬢ 6.9.2 cd tester ✓ 5361 17:14:31
cd: no such file or directory: tester
…/CODE/tester ⬢ 6.9.2 ls 1 ↵ 5362 17:14:44
tester-gql tester692
…/CODE/tester ⬢ 6.9.2 cd tester692 ✓ 5363 17:14:50
…/tester/tester692 ⬢ 6.9.2 create-graphql generate -tmlc Business --schema Business
create src/connection/BusinessConnection.js
🔥 Connection created!
events.js:160
throw er; // Unhandled 'error' event
^
TypeError: Cannot read property 'forEach' of undefined
at /Users/devworx/.nvm/versions/node/v6.9.2/lib/node_modules/generator-graphql/generators/utils.js:171:27
at Array.forEach (native)
at getSchemaFieldsFromAst (/Users/devworx/.nvm/versions/node/v6.9.2/lib/node_modules/generator-graphql/generators/utils.js:162:19)
at Context.visitExpression (/Users/devworx/.nvm/versions/node/v6.9.2/lib/node_modules/generator-graphql/generators/utils.js:213:18)
at Context.invokeVisitorMethod (/Users/devworx/.nvm/versions/node/v6.9.2/lib/node_modules/generator-graphql/node_modules/ast-types/lib/path-visitor.js:344:49)
at Visitor.PVp.visitWithoutReset (/Users/devworx/.nvm/versions/node/v6.9.2/lib/node_modules/generator-graphql/node_modules/ast-types/lib/path-visitor.js:196:32)
at visitChildren (/Users/devworx/.nvm/versions/node/v6.9.2/lib/node_modules/generator-graphql/node_modules/ast-types/lib/path-visitor.js:246:25)
at Visitor.events.js:160
throw er; // Unhandled 'error' event
^
TypeError: Cannot read property 'forEach' of undefined
at /Users/devworx/.nvm/versions/node/v6.9.2/lib/node_modules/generator-graphql/generators/utils.js:171:27
at Array.forEach (native)
at getSchemaFieldsFromAst (/Users/devworx/.nvm/versions/node/v6.9.2/lib/node_modules/generator-graphql/generators/utils.js:162:19)
at Context.visitExpression (/Users/devworx/.nvm/versions/node/v6.9.2/lib/node_modules/generator-graphql/generators/utils.js:213:18)
at Context.invokeVisitorMethod (/Users/devworx/.nvm/versions/node/v6.9.2/lib/node_modules/generator-graphql/node_modules/ast-types/lib/path-visitor.js:344:49)
at Visitor.PVp.visitWithoutReset (/Users/devworx/.nvm/versions/node/v6.9.2/lib/node_modules/generator-graphql/node_modules/ast-types/lib/path-visitor.js:196:32)
at visitChildren (/Users/devworx/.nvm/versions/node/v6.9.2/lib/node_modules/generator-graphql/node_modules/ast-types/lib/path-visitor.js:246:25)
at Visitor.PVp.visitWithoutReset (/Users/devworx/.nvm/versions/node/v6.9.2/lib/node_modules/generator-graphql/node_modules/ast-types/lib/path-visitor.js:204:20)
at NodePath.each (/Users/devworx/.nvm/versions/node/v6.9.2/lib/node_modules/generator-graphql/node_modules/ast-types/lib/path.js:101:26)
at visitChildren (/Users/devworx/.nvm/versions/node/v6.9.2/lib/node_modules/generator-graphql/node_modules/ast-types/lib/path-visitor.js:219:18)
events.js:160
throw er; // Unhandled 'error' event
^
TypeError: Cannot read property 'forEach' of undefined
at /Users/devworx/.nvm/versions/node/v6.9.2/lib/node_modules/generator-graphql/generators/utils.js:171:27
at Array.forEach (native)
at getSchemaFieldsFromAst (/Users/devworx/.nvm/versions/node/v6.9.2/lib/node_modules/generator-graphql/generators/utils.js:162:19)
at Context.visitExpression (/Users/devworx/.nvm/versions/node/v6.9.2/lib/node_modules/generator-graphql/generators/utils.js:213:18)
at Context.invokeVisitorMethod (/Users/devworx/.nvm/versions/node/v6.9.2/lib/node_modules/generator-graphql/node_modules/ast-types/lib/path-visitor.js:344:49)
at Visitor.PVp.visitWithoutReset (/Users/devworx/.nvm/versions/node/v6.9.2/lib/node_modules/generator-graphql/node_modules/ast-types/lib/path-visitor.js:196:32)
at visitChildren (/Users/devworx/.nvm/versions/node/v6.9.2/lib/node_modules/generator-graphql/node_modules/ast-types/lib/path-visitor.js:246:25)
at Visitor.PVp.visitWithoutReset (/Users/devworx/.nvm/versions/node/v6.9.2/lib/node_modules/generator-graphql/node_modules/ast-types/lib/path-visitor.js:204:20)
at NodePath.each (/Users/devworx/.nvm/versions/node/v6.9.2/lib/node_modules/generator-graphql/node_modules/ast-types/lib/path.js:101:26)
at visitChildren (/Users/devworx/.nvm/versions/node/v6.9.2/lib/node_modules/generator-graphql/node_modules/ast-types/lib/path-visitor.js:219:18)
PVp.visitWithoutReset (/Users/devworx/.nvm/versions/node/v6.9.2/lib/node_modules/generator-graphql/node_modules/ast-types/lib/path-visitor.js:204:20)
at NodePath.each (/Users/devworx/.nvm/versions/node/v6.9.2/lib/node_modules/generator-graphql/node_modules/ast-types/lib/path.js:101:26)
at visitChildren (/Users/devworx/.nvm/versions/node/v6.9.2/lib/node_modules/generator-graphql/node_modules/ast-types/lib/path-visitor.js:219:18)
(node:35321) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Exited with status 1
(node:35321) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): Error: Exited with status 1
(node:35321) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 3): Error: Exited with status 1
…/tester/tester692 ⬢ 6.9.2
Im wondering what node version, or whatever else I need to have set up to get a new project to run right. Also are we running create-graphql generate -tmlc Business in the root of the newly created project or from the directory we ran create-graphql init from? I assume new root but asking anyway.
Current Behavior
Your Environment
I just ran a fresh project to document. Note in the screenshot that I ran create-graphql init on node 8.1.2 but then when you switch into the created directory, the node v changes to 6.9.2. Maybe this is the issue? Do we need to create from the same 6.9.2? If so, there should be an error there.