Add bulk item consumer creation GraphQL mutation
What does this MR do and why?
Adds a new AiCatalogItemConsumerBulkCreate GraphQL mutation that enables an AI catalog agent or flow across multiple projects at once asynchronously via Sidekiq.
This is the backend portion of Iteration 1 — enabling bulk selection of individual projects for agent/flow enablement.
The mutation is gated behind the ai_catalog_bulk_item_consumer_create feature flag.
What's remaining
- Catch and log errors when creating the consumers fails
- Add a limit to how many can be batch added at once
- Email a report of the results (We need to decide how to do this idempotently)
- Restrict all operations to a single organization
- Enable feature flag
- Remove feature flag
References
- Issue: #595242
How to set up and validate locally
-
Enable the feature flag:
Feature.enable(:ai_catalog_bulk_item_consumer_create) -
Run the GraphQL mutation:
mutation { aiCatalogItemConsumerBulkCreate(input: { itemId: "gid://gitlab/Ai::Catalog::Item/<ITEM_ID>" projectIds: [ "gid://gitlab/Project/<PROJECT_1_ID>", "gid://gitlab/Project/<PROJECT_2_ID>" ] triggerTypes: ["mention", "assign"] }) { errors } } -
Verify the response has empty errors and item consumers were created:
Ai::Catalog::ItemConsumer.where(ai_catalog_item_id: item.id).pluck(:project_id, :group_id) -
Try again with a project or item you don't have access to, and verify that you receive an error message.
Edited by Keeyan Nejad