-
Notifications
You must be signed in to change notification settings - Fork 95
Closed
Description
I try to implement a solution that uses graphql-java and dataloader over a database.
I would like to know the best pratice to load a many relations when the nested ids required a database query.
in the documentation example, imagine that we replace starWarsCharacter.getFriendsIds() by a database query getFriendIdsFromDB(starWarsCharacter).
The friendsDataFetcher would looks like :
DataFetcher friendsDataFetcher = new DataFetcher() {
@Override
public Object get(DataFetchingEnvironment environment) {
StarWarsCharacter starWarsCharacter = environment.getSource();
List<String> friendIds = getFriendIdsFromDB(starWarsCharacter);
return characterDataLoader.loadMany(friendIds);
}
};
In this case it generates again a N+1 fetch problem. For each Character we have to query for the friends ids.
How to efficiently manage that case with the dataloader?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels