Skip to content

Add GraphQL Blame endpoint

What does this MR do and why?

Add a Graphql blame end point.

Expose git blame data via a graphql endpoint.
Relies on !128101 (merged) to get blame span value as per this discussion. That MR needs to be merged first

Contributes to #393764 (closed)
Feature flag: #419808 (closed)

How to set up and validate locally

  1. Make sure to enable the feature flag graphql_git_blame - Feature.enable(:graphql_git_blame)

Create as root create a project called blame-test. Add a file 'test file' and add some text across multiple lines.

Using GraphiQL app locally pointing to GDK (Graphql endpoint http://127.0.0.1:3000/api/graphql)

query TestQuery($fullPath: ID!) {
  project(fullPath: $fullPath) {
    repository {
      blobs(paths: ["test file"]) {
        nodes {
          blame(fromLine: 2, toLine: 6 ){
            lineno
            span
            previousPath
            lines
            commit {
              webPath
              sha
              authoredDate
              message
              author {
                avatarUrl
                webPath
                username
              }
            }
          }
        }
      }
    }
  }
}

Query Variables:

{
  "fullPath": "root/blame-test"
}

Should return:

Screenshot_2023-08-01_at_22.24.04

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #393764 (closed)

Edited by Ash McKenzie

Merge request reports