Backend: Add GraphQL mutation to destroy agent
About
Similar to the work in #551282 (closed) we want to add a GraphQL mutation to destroy an agent.
Proposal
What is destroyed?
This mutation will destroy the Item record itself and all of its versions (ItemVersion).
Schema
The arguments would be:
| Argument name | Type | Required? |
|---|---|---|
id |
::Types::GlobalIDType[::Ai::Catalog::Item] |
The mutation would have one nullable field:
| field name | Type | Nullable? |
|---|---|---|
item |
::Types::Ai::Catalog::ItemType |
Similar to other destroy mutations, the mutation will return a null item if the item is destroyed successfully, but the actual item when it is not destroyed successfully.
(The errors field) is defined for all mutations through BaseMutation).
Example mutation call:
mutation {
aiCatalogAgentDestroy(input: {
id: "gid://gitlab/Ai::Catalog::Item/1"
}) {
errors
item {
id
}
}
}
Must check item is an Agent
As agents are currently modelled in the same table as other AI items will be in, the Global ID type for an Agent will not guarantee that we are destroying an agent item as opposed to another other item.
The service must return an error response if the AI item is not an agent.
Authorization
The authorization for the mutation should be the same as in !196462 (merged) which is admin_ai_catalog_item at time of writing.