From e4d5317e4f6da7959faff4c474d5d1de4f21ce8f Mon Sep 17 00:00:00 2001 From: Beatrix <68532117+abeatrix@users.noreply.github.com> Date: Mon, 5 Jun 2023 15:08:28 -0700 Subject: [PATCH] Cody: Add isCodyEnabled to graphQL schema for Site (#52941) --- CHANGELOG.md | 1 + cmd/frontend/graphqlbackend/BUILD.bazel | 1 + cmd/frontend/graphqlbackend/schema.graphql | 5 +++++ cmd/frontend/graphqlbackend/site.go | 3 +++ 4 files changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0fb4f58c55d..da495102547 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,7 @@ All notable changes to Sourcegraph are documented in this file. - Batch Changes for Gerrit Code Hosts [#52647](https://github.com/sourcegraph/sourcegraph/pull/52647). - Batch Changes now supports per-batch-change control for pushing to a fork of the upstream repository when the property `changesetTemplate.fork` is specified in the batch spec. [#51572](https://github.com/sourcegraph/sourcegraph/pull/51572) - Executors can now be configured to process multiple queues. [#52016](https://github.com/sourcegraph/sourcegraph/pull/52016) +- Added `isCodyEnabled` as a new GraphQL field to `Site`. [#52941](https://github.com/sourcegraph/sourcegraph/pull/52941) ### Changed diff --git a/cmd/frontend/graphqlbackend/BUILD.bazel b/cmd/frontend/graphqlbackend/BUILD.bazel index 8b547763ce7..6c6ed0918a0 100644 --- a/cmd/frontend/graphqlbackend/BUILD.bazel +++ b/cmd/frontend/graphqlbackend/BUILD.bazel @@ -245,6 +245,7 @@ go_library( "//internal/codeintel/dependencies", "//internal/codeintel/dependencies/shared", "//internal/codeintel/resolvers", + "//internal/cody", "//internal/conf", "//internal/conf/conftypes", "//internal/conf/deploy", diff --git a/cmd/frontend/graphqlbackend/schema.graphql b/cmd/frontend/graphqlbackend/schema.graphql index c5866b325b8..994bf8aefc9 100755 --- a/cmd/frontend/graphqlbackend/schema.graphql +++ b/cmd/frontend/graphqlbackend/schema.graphql @@ -7072,6 +7072,11 @@ type Site implements SettingsSubject { Whether users are required to have a verified email in order to access Cody. """ requiresVerifiedEmailForCody: Boolean! + + """ + Whether Cody is enabled for this site. + """ + isCodyEnabled: Boolean! } """ diff --git a/cmd/frontend/graphqlbackend/site.go b/cmd/frontend/graphqlbackend/site.go index 229c1cc5930..a72ffa75ddb 100644 --- a/cmd/frontend/graphqlbackend/site.go +++ b/cmd/frontend/graphqlbackend/site.go @@ -22,6 +22,7 @@ import ( "github.com/sourcegraph/sourcegraph/internal/actor" "github.com/sourcegraph/sourcegraph/internal/api" "github.com/sourcegraph/sourcegraph/internal/auth" + "github.com/sourcegraph/sourcegraph/internal/cody" "github.com/sourcegraph/sourcegraph/internal/conf" "github.com/sourcegraph/sourcegraph/internal/conf/deploy" "github.com/sourcegraph/sourcegraph/internal/database" @@ -558,3 +559,5 @@ func (r *siteResolver) RequiresVerifiedEmailForCody(ctx context.Context) bool { isAdmin := auth.CheckCurrentUserIsSiteAdmin(ctx, r.db) == nil return !isAdmin } + +func (r *siteResolver) IsCodyEnabled(ctx context.Context) bool { return cody.IsCodyEnabled(ctx) }