That's why I chose to add the populate attribute, so if we just want the ids, we set it to false, which will save db access for the mongoose populate operation.
The issue for me was that if we use populate: false, the resolver would be returning an array of IDs, which GraphQL would complain about, since it's not of type Hobby.
I have personally used an approach where I specify extra GraphQL field populatedHobbies of type [Hobby] and keep hobbies endpoint, which would return [ID]
There is a way, mentioned in NestJs doc, to create a combine type but it does not work with combining a scalar and object types. ex :
That's why I chose to add the populate attribute, so if we just want the ids, we set it to false, which will save db access for the mongoose populate operation.
Right, I was looking into that as well.
The issue for me was that if we use
populate: false
, the resolver would be returning an array of IDs, which GraphQL would complain about, since it's not of typeHobby
.I have personally used an approach where I specify extra GraphQL field
populatedHobbies
of type[Hobby]
and keephobbies
endpoint, which would return[ID]
Good idea !