create-graphql
create-graphql copied to clipboard
throw error while generating type and mutation base on mongoose schema
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.<anonymous> (/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.<anonymous> (/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.<anonymous> (/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.<anonymous> (/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
'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 |
Hi @hbakhtiyor, can you show me the Type and Mutation files that were outputted?
hi @lucasbento nothing outputted, only the error