graphql-mongodb-example icon indicating copy to clipboard operation
graphql-mongodb-example copied to clipboard

Population with GraphQL?

Open viztastic opened this issue 9 years ago • 0 comments

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?

viztastic avatar Jan 01 '17 14:01 viztastic