diff --git a/cmd/frontend/graphqlbackend/git_blob.go b/cmd/frontend/graphqlbackend/git_blob.go index fef57d93535..fa1b0d49c36 100644 --- a/cmd/frontend/graphqlbackend/git_blob.go +++ b/cmd/frontend/graphqlbackend/git_blob.go @@ -10,8 +10,8 @@ import ( ) type GitTreeEntryBlameArgs struct { - StartLine int32 - EndLine int32 + StartLine *int32 + EndLine *int32 IgnoreWhitespace bool } @@ -19,10 +19,17 @@ func (r *GitTreeEntryResolver) Blame(ctx context.Context, args *GitTreeEntryBlam opts := &gitserver.BlameOptions{ NewestCommit: api.CommitID(r.commit.OID()), IgnoreWhitespace: args.IgnoreWhitespace, - Range: &gitserver.BlameRange{ - StartLine: int(args.StartLine), - EndLine: int(args.EndLine), - }, + } + + if (args.StartLine == nil) != (args.EndLine == nil) { + return nil, errors.New("both startLine and endLine must be specified or neither") + } + + if args.StartLine != nil && args.EndLine != nil { + opts.Range = &gitserver.BlameRange{ + StartLine: int(*args.StartLine), + EndLine: int(*args.EndLine), + } } hr, err := r.gitserverClient.StreamBlameFile(ctx, r.commit.repoResolver.RepoName(), r.Path(), opts) diff --git a/cmd/frontend/graphqlbackend/schema.graphql b/cmd/frontend/graphqlbackend/schema.graphql index 373d38b7c21..996863be585 100755 --- a/cmd/frontend/graphqlbackend/schema.graphql +++ b/cmd/frontend/graphqlbackend/schema.graphql @@ -6063,7 +6063,7 @@ type GitBlob implements TreeEntry & File2 { """ Blame the blob. """ - blame(startLine: Int!, endLine: Int!, ignoreWhitespace: Boolean = false): [Hunk!]! + blame(startLine: Int, endLine: Int, ignoreWhitespace: Boolean = false): [Hunk!]! """ Highlight the blob contents. """