Introduce codeSuggestionsContexts field to CurrentUser GraphQL type
What does this MR do and why?
Related to #512976 (closed)
We are introducing the Imports additional context to Code Suggestions as part of our focus area to improve quality. To allow for a graceful rollout to users, this additional context will be introduced behind a Feature Flag, which the GitLab Language Server can check through the GraphQL API.
This MR introduces the codeSuggestionsContexts field to the CurrentUser GraphQL type. The new field indicates which additional context categories are available for the user in Code Suggestions.
- The
repository_xraycontext (which has already been introduced) is available as long as the user has access to code suggestions - The
open_tabscontext (which has already been introduced) is available as long as the user has access to code suggestions - The
importscontext is toggled by a Feature Flag introduced in this MR
While only imports is needed for the related issue, we need to reflect the domain and return all the additional context categories for the new field.
References
Please include cross links to any resources that are relevant to this MR. This will give reviewers and future readers helpful context to give an efficient review of the changes introduced.
- For details on how the Imports Context Feature Flag will be checked on the Language Server, please refer to gitlab-org/editor-extensions/gitlab-lsp#726 (closed)
- For details on how the Imports Context will be included in Code Suggestions requests, please refer to gitlab-org/editor-extensions/gitlab-lsp#711 (closed)
- For further details on the Imports Context, please refer to the epic: gitlab-org/editor-extensions&58 (closed)
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Screenshots or screen recordings
N/A
How to set up and validate locally
Setup
-
Make sure you have Duo Code Suggestions enabled on your GDK. You can follow either instruction depending on whether your GDK is on Self-Managed or SaaS mode.
- Setting up for Self-Managed
- Setting up for SaaS (user-specific)
Alternatively, you can change the GlobalPolicy code to have it return
truefor theaccess_code_suggestionspermission. -
Make sure that the
ai_duo_code_suggestions_switchFeature Flag is enabled.
Test
Test the following query on your GDK's GraphQL explorer (e.g. http://gdk.test:3000/-/graphql-explorer)
query {
currentUser {
codeSuggestionsContexts
}
}
Before - on master branch
You should get an error:
{
"errors": [
{
"graphQLErrors": [
{
"message": "Field 'codeSuggestionsContexts' doesn't exist on type 'CurrentUser'",
}
]
}
]
}
After - on 512976-graphql-code-suggestions-features branch
With the code_suggestions_include_context_imports FF disabled
The codeSuggestionsContexts field should have the value ['repository_xray', 'open_tabs']:
{
"data": {
"currentUser": {
"codeSuggestionsContexts": [
"repository_xray",
"open_tabs"
]
}
}
}
With the code_suggestions_include_context_imports FF enabled
The codeSuggestionsContexts field should have an additional item - imports:
{
"data": {
"currentUser": {
"codeSuggestionsContexts": [
"repository_xray",
"open_tabs",
"imports"
]
}
}
}