Graphql Mutation for user setting for default seat assignment | Model Selection
Context
For Model selection when no namespace is given because a developer is working in a new repo that is not yet an GitLab project or because they use the various AI capabilities of the GitLab CLI. We are routing the request to a default duo enabled namespace chosen by the user.
Task
Create GQL nodes to mutate the default_duo_add_on_assignment
in the user preference table field.
Implementation proposal
For the return types you should use the same Types::GitlabSubscriptions::AddOnPurchaseType
. The group or namespace field should be added to it already in #552079 (closed).
mutation {
setUserDuoGroup($userId: UserID!, $addOnPurchaseId: GlobalIDType!) {
nodes {
addOnPurchase {
group { # Group type nullable
id # returns current group
}
}
}
}
def resolve(**)
add_on_purchase = authorized_find!(id: add_on_purchase_id)
assignment = add_on_purchase.assigned_users.by_user(user_to_be_removed).first
user.user_preferences.update(default_duo_add_on_assignment_id: assigment.id)
add_on_purchase
end
Edited by 🤖 GitLab Bot 🤖