Paul Damnhorns
Paul Damnhorns
Your last example is not a workaround. It's correct implementation. You should import **mongoose** models and work with them in your custom resolver function: ```diff resolve: async ({ args })...
@halindraprakoso you are right. You should add only what you really want to use in your schema. `graphql-compose-mongoose` has the ability to generate all these resolvers, but use them or...
Mongoose models do not contain what exactly types have virtuals fields. So you should add virtual fields manually to your GraphQL types. Like so: ```js const RecordTC = composeWithMongoose(Record); RecordTC.addFields({...
@ryanvanderpol you may extend any generated type even nested. Method `getFieldTC(): ObjectTypeComposer | EnumTypeComposer| ScalarTypeComposer` or `getFieldOTC(): ObjectTypeComposer` allows to get TypeComposer for any field and extend it as you...
@chongma yep it should work with an array for type definition for virtual fields! And your example above absolutely legit.
Mongoose does not return any type for virtual fields. So graphql-compose-mongoose cannot create these fields automatically. Moreover, you are using relations with other models. They are not populated automatically. So...
@chongma Agreed, my example contains errors. So your code snippet is correct👍
@antonedvard you need to use `projection` param in field config: ```js UserTC.addFields({ fullName: { type: 'String', resolve: (source) => `${source.firstName} ${source.lastname}`, projection: { firstName: 1, lastname: 1 } } });...
@lukidoescode, you need to migrate on v9.0.0. Before resolvers were generated on `composeWithMongoose()` call. But from v9, resolvers are generated on-demand via the `mongooseResolvers` resolver factory. So your code may...
> Thank you, that helped a whole lot! I already was on v9.0.0. However, I was still following the docs at https://graphql-compose.github.io/docs/plugins/plugin-mongoose.html. Thanks for reporting @lukidoescode. I've just updated it.