aerogear / create-graphql

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

throw error while generating type and mutation base on mongoose schema #111

Open hbakhtiyor opened 6 years ago

hbakhtiyor commented 6 years ago

Current Behavior

when run the command create-graphql generate -tm Post --schema Post, throw the error

error ``` events.js:167 throw er; // Unhandled 'error' event ^ TypeError: Cannot read property 'name' of undefined at Context.visitExpression (/home/bakhtiyor/.npm-global/lib/node_modules/generator-graphql/generators/utils.js:317:63) at Context.invokeVisitorMethod (/home/bakhtiyor/.npm-global/lib/node_modules/generator-graphql/node_modules/ast-types/lib/path-visitor.js:344:49) at Visitor.PVp.visitWithoutReset (/home/bakhtiyor/.npm-global/lib/node_modules/generator-graphql/node_modules/ast-types/lib/path-visitor.js:196:32) at visitChildren (/home/bakhtiyor/.npm-global/lib/node_modules/generator-graphql/node_modules/ast-types/lib/path-visitor.js:246:25) at Visitor.PVp.visitWithoutReset (/home/bakhtiyor/.npm-global/lib/node_modules/generator-graphql/node_modules/ast-types/lib/path-visitor.js:204:20) at NodePath.each (/home/bakhtiyor/.npm-global/lib/node_modules/generator-graphql/node_modules/ast-types/lib/path.js:101:26) at visitChildren (/home/bakhtiyor/.npm-global/lib/node_modules/generator-graphql/node_modules/ast-types/lib/path-visitor.js:219:18) at Visitor.PVp.visitWithoutReset (/home/bakhtiyor/.npm-global/lib/node_modules/generator-graphql/node_modules/ast-types/lib/path-visitor.js:204:20) at visitChildren (/home/bakhtiyor/.npm-global/lib/node_modules/generator-graphql/node_modules/ast-types/lib/path-visitor.js:246:25) at Visitor.PVp.visitWithoutReset (/home/bakhtiyor/.npm-global/lib/node_modules/generator-graphql/node_modules/ast-types/lib/path-visitor.js:204:20) Emitted 'error' event at: at Immediate. (/home/bakhtiyor/.npm-global/lib/node_modules/generator-graphql/node_modules/yeoman-generator/lib/index.js:424:16) at runCallback (timers.js:696:18) at tryOnImmediate (timers.js:667:5) at processImmediate (timers.js:649:5) events.js:167 throw er; // Unhandled 'error' event ^ TypeError: Cannot read property 'name' of undefined at Context.visitExpression (/home/bakhtiyor/.npm-global/lib/node_modules/generator-graphql/generators/utils.js:317:63) at Context.invokeVisitorMethod (/home/bakhtiyor/.npm-global/lib/node_modules/generator-graphql/node_modules/ast-types/lib/path-visitor.js:344:49) at Visitor.PVp.visitWithoutReset (/home/bakhtiyor/.npm-global/lib/node_modules/generator-graphql/node_modules/ast-types/lib/path-visitor.js:196:32) at visitChildren (/home/bakhtiyor/.npm-global/lib/node_modules/generator-graphql/node_modules/ast-types/lib/path-visitor.js:246:25) at Visitor.PVp.visitWithoutReset (/home/bakhtiyor/.npm-global/lib/node_modules/generator-graphql/node_modules/ast-types/lib/path-visitor.js:204:20) at NodePath.each (/home/bakhtiyor/.npm-global/lib/node_modules/generator-graphql/node_modules/ast-types/lib/path.js:101:26) at visitChildren (/home/bakhtiyor/.npm-global/lib/node_modules/generator-graphql/node_modules/ast-types/lib/path-visitor.js:219:18) at Visitor.PVp.visitWithoutReset (/home/bakhtiyor/.npm-global/lib/node_modules/generator-graphql/node_modules/ast-types/lib/path-visitor.js:204:20) at visitChildren (/home/bakhtiyor/.npm-global/lib/node_modules/generator-graphql/node_modules/ast-types/lib/path-visitor.js:246:25) at Visitor.PVp.visitWithoutReset (/home/bakhtiyor/.npm-global/lib/node_modules/generator-graphql/node_modules/ast-types/lib/path-visitor.js:204:20) Emitted 'error' event at: at Immediate. (/home/bakhtiyor/.npm-global/lib/node_modules/generator-graphql/node_modules/yeoman-generator/lib/index.js:424:16) at runCallback (timers.js:696:18) at tryOnImmediate (timers.js:667:5) at processImmediate (timers.js:649:5) (node:20340) UnhandledPromiseRejectionWarning: Error: Exited with status 1 at closeArgsToError (/home/bakhtiyor/.npm-global/lib/node_modules/create-graphql/node_modules/cross-spawn-promise/lib/index.js:20:16) at ChildProcess. (/home/bakhtiyor/.npm-global/lib/node_modules/create-graphql/node_modules/cross-spawn-promise/lib/index.js:76:19) at Object.onceWrapper (events.js:273:13) at ChildProcess.emit (events.js:182:13) at Process.ChildProcess._handle.onexit (internal/child_process.js:237:12) (node:20340) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1) (node:20340) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. (node:20340) UnhandledPromiseRejectionWarning: Error: Exited with status 1 at closeArgsToError (/home/bakhtiyor/.npm-global/lib/node_modules/create-graphql/node_modules/cross-spawn-promise/lib/index.js:20:16) at ChildProcess. (/home/bakhtiyor/.npm-global/lib/node_modules/create-graphql/node_modules/cross-spawn-promise/lib/index.js:76:19) at Object.onceWrapper (events.js:273:13) at ChildProcess.emit (events.js:182:13) at Process.ChildProcess._handle.onexit (internal/child_process.js:237:12) (node:20340) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2) ```
Post.js ```js 'use strict' const mongoose = require('mongoose'); const Schema = mongoose.Schema; const PostSchema = new Schema({ title: { type: String, required: true }, body: { type: String, required: true } }); module.exports = mongoose.model('Post', PostSchema); ```

Expected Behavior

Your Environment

software version
create-graphql 1.2.3
node v10.6.0
npm or yarn 6.4.1
lucasbento commented 6 years ago

Hi @hbakhtiyor, can you show me the Type and Mutation files that were outputted?

hbakhtiyor commented 6 years ago

hi @lucasbento nothing outputted, only the error