subscription CommentCreated($postId: String!) {
commentCreated(postId: $postId) {
id
body
user {
username
}
}
}
When I make N subscriptions via Graphiql and create a new comment, I see N + 1 calls to the DB to fetch the user(1 for the mutation + N for the subscriptions). Is there anyway to prefetch that data so I’m not doing a DB call per subscription connection, but only per mutation?
A single user wouldn’t have more than one subscription, but if 100 users are subscribed to a post, then every comment would make 101 db hits to fetch the same user info.
I’ve already got dataloader, but that context_id is exactly what I’m looking for! I just read through that article earlier today, not sure how I missed that. Thanks!