From 394a614b514a8b960b0c76717293b3e41eaff826 Mon Sep 17 00:00:00 2001 From: Keegan Carruthers-Smith Date: Wed, 8 Apr 2026 15:16:45 +0200 Subject: [PATCH] repos: remove unread fields from graphql query We didn't actually read the majority of fields on the graphql query for repositories. So we remove all unread fields. In particular this removes the field "Language" which is expensive to compute if not cached. In practice I suspect this will dramatically improve the performance of "src repos list" command. --- cmd/src/repos.go | 41 ++--------------------------------------- 1 file changed, 2 insertions(+), 39 deletions(-) diff --git a/cmd/src/repos.go b/cmd/src/repos.go index d7131c6f87..c1347f5889 100644 --- a/cmd/src/repos.go +++ b/cmd/src/repos.go @@ -4,7 +4,6 @@ import ( "context" "flag" "fmt" - "time" "github.com/sourcegraph/sourcegraph/lib/errors" @@ -51,53 +50,17 @@ Use "src repos [command] -h" for more information about a command. const repositoryFragment = ` fragment RepositoryFields on Repository { - id name - url - description - language - createdAt - updatedAt - externalRepository { - id - serviceType - serviceID - } defaultBranch { name displayName } - viewerCanAdminister - keyValuePairs { - key - value - } } ` type Repository struct { - ID string `json:"id"` - Name string `json:"name"` - URL string `json:"url"` - Description string `json:"description"` - Language string `json:"language"` - CreatedAt time.Time `json:"createdAt"` - UpdatedAt *time.Time `json:"updatedAt"` - ExternalRepository ExternalRepository `json:"externalRepository"` - DefaultBranch GitRef `json:"defaultBranch"` - ViewerCanAdminister bool `json:"viewerCanAdminister"` - KeyValuePairs []KeyValuePair `json:"keyValuePairs"` -} - -type KeyValuePair struct { - Key string `json:"key"` - Value *string `json:"value"` -} - -type ExternalRepository struct { - ID string `json:"id"` - ServiceType string `json:"serviceType"` - ServiceID string `json:"serviceID"` + Name string `json:"name"` + DefaultBranch GitRef `json:"defaultBranch"` } type GitRef struct {