Skip to content

GraphQL API: Repository-level actions result in many thousands of repetitive git operations

Created by: slimsag

The following query takes several minutes to complete because I ask for the list of contributors for each search result. This translates into us running git shortlog -sne once for every single result, despite the fact that they all came from the same repository:

bad query

This is one example of how making GraphQL APIs performant is quite difficult in my view. What is the way to fix this? I see a few options:

  1. Aggressively cache git operations (this would be a good idea regardless of this issue, but doesn't address the main problem here such as if this query didn't involve git operations).
  2. Remove GraphQL fields that allow for creating poor queries -- i.e. why should I be able to query the contributors for a search result's repository, instead of being forced by the API to make a separate query for that information which is more correct?