create-graphql icon indicating copy to clipboard operation
create-graphql copied to clipboard

Create a mongoose schema when generating a new type

Open farazcsk-zz opened this issue 8 years ago • 4 comments

I can see that it is possible to create a graphql type or mutation based on an existing mongoose schema using the --schema command, it would be great if creating a model without an existing mongoose schema could generate one.

For example the command:

create-graphql generate -tm User

Generates:

./src/model/User.js

farazcsk-zz avatar Dec 30 '16 14:12 farazcsk-zz

Looks good, haven't thought about it because I never had a use case for doing so.

Would you mind sharing your use case to come up with that idea?

lucasbento avatar Dec 30 '16 16:12 lucasbento

what would be the fields of this model?

sibelius avatar Dec 30 '16 16:12 sibelius

Humm, I think I got it now.

Are you looking for a command to generate an empty model as we currently do on type without schema (here)?

lucasbento avatar Dec 30 '16 16:12 lucasbento

@lucasbento he wants to create the UserModel in mongoose as well when creating an UserType if UserModel does not exist

sibelius avatar Dec 30 '16 16:12 sibelius