aerogear / create-graphql

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

object notation should be optional #87

Closed phra closed 7 years ago

phra commented 7 years ago

hi,

when i'm trying to generate a type and a mutation from this example schema, the generator will crashes because of missing 'type' property on the field.

'use strict'

var mongoose = require('mongoose')
var example= new mongoose.Schema({
    title: String
})

module.exports = mongoose.model('Example', example)

changing the schema in this way make the generator works again:

'use strict'

var mongoose = require('mongoose')
var example= new mongoose.Schema({
    title: { type: String, }
})

module.exports = mongoose.model('Example', example)
sibelius commented 7 years ago

this is probably a problem with the way with parse mongoose schema in this function: https://github.com/lucasbento/create-graphql/blob/master/packages/generator/src/utils.js#L134

do you wanna send a PR fixing this?

phra commented 7 years ago

Nice!