aerogear / create-graphql

Command-line utility to build production-ready servers with GraphQL.
MIT License
440 stars 38 forks source link

Creating a New Project Settings #100

Open idkjs opened 7 years ago

idkjs commented 7 years ago

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

<!--- If describing a bug, tell us what happens instead of the expected behavior.
      Provide a screenshot when possible and full code sample -->
<!--- If suggesting a change/improvement, explain the difference from current behavior -->
 …/yelpql-demo/yelpql  ⬢ 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)
    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)
(node:24310) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Exited with status 1
(node:24310) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): Error: Exited with status 1
(node:24310) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 3): Error: Exited with status 1
 …/yelpql-demo/yelpql  ⬢ 6.9.2  cd
### Expected Behavior
<!--- If you're describing a bug, tell us what should happen -->
<!--- If you're suggesting a change/improvement, tell us how it should work -->

Your Environment

software version
create-graphql 1.1.17
node 8.1.0
npm or yarn used npm.
macOS Sierra

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. screen shot 2017-06-20 at 16 53 23

JCMais commented 7 years ago

Can you post a Schema file that we can use to reproduce this issue?

idkjs commented 7 years ago

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
idkjs commented 7 years ago

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
idkjs commented 7 years ago

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 
sibelius commented 7 years ago

it looks like the error is here: https://github.com/graphql-community/create-graphql/blob/4882069e4537034d695e209847055cc4972efc17/packages/generator/src/utils.js#L169