Add Graphql endpoints for Duo Settings
What does this MR do and why?
This MR adds Graphql endpoints for interfacing with the ai_settings table. This will support the work here for adding UI functionality to update the AI Gateway URL. Currently it can only be set by using the ENV variable AI_GATEWAY_URL or by updating ::Ai::Setting in the rails console, but we need a way for the frontend to be able to interact with this value.
This MR adds:
- A query endpoint for Duo settings
- An update mutation + service for updating Duo settings
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.
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
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
| Before | After |
|---|---|
How to set up and validate locally
Prequisites
- You will need an active GitLab Ultimate license.
- Make sure you are set up with a Duo Enterprise subscription by running the following command in the terminal:
GITLAB_SIMULATE_SAAS=0 bundle exec 'rake gitlab:duo:setup_instance[duo_enterprise]'
Test it!
-
Start GDK (
gdk start) and visit http://gdk.test:3000/-/graphql-explorer -
Test the Duo settings query by running the following query in the graphql explorer
query getDuoSettings {
duoSettings {
aiGatewayUrl
}
}
You should expect a response that looks something like the below:
{
"data": {
"aiGatewayUrl": "<YOUR_AI_GATEWAY_URL>"
},
"correlationId": "01JHSNX0Y2VZJ6E0R9NPBYNRVX"
}
- Test the Duo settings update mutation by running the following in the graphql explorer
mutation updateDuoSettings($input: DuoSettingsUpdateInput!) {
duoSettingsUpdate(input:$input) {
aiGatewayUrl
errors
}
}
In the variables tab add the following:
{
"input": {
"aiGatewayUrl": "http://0.0.0.0:8080"
}
}
You should expect a response that looks something like the below:
{
"data": {
"duoSettingsUpdate": {
"duoSettings": {
"aiGatewayUrl": "http://0.0.0.0:8080"
},
"errors": []
}
},
"correlationId": "01JHSP4QKATXBGEEF3PWFD0T3F"
}
Related to #473143 (closed)