What would the best approach to fetch deep nested object with graphql only when asked for. I'm talking here performance wise
Lets say you have the following mongo/mongoose schema :
User
|
|_ Name
|
|_ Friends (RefId into User)
|
|_ User
|
|_ Friends (RefId into User)
.....
suppose each user has many friends who in turn have many other friends,
how would decide how deeply you need to populate
inside a resolve
function?
the naive method of "just populating" might be harmful as many of the queries might just select the field name
which is on the 0 level, but end up populating 1/2 of your db.
Thanks in advance.