graphql-mongodb-example
graphql-mongodb-example copied to clipboard
Population with GraphQL?
Hi @sayden
Great example! I am trying to see learn how to best model field Population using GraphQL.
I see that for your UserSchema mongoose schema you have the hobbies and friends fields both of which are ObjectIds and reference Hobby/Friend types respectively.
However in your GraphQL model, you don't seem to account for the possibility of the hobby and friend field taking on an ObjectId or HobbyType / UserType object.
I want users to be able to receive a list of ObjectIds or populated objects depending on their query params.
How would you best do this?