Skip to content

Graphql Query get 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 node to query currently selected 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).

query {
  userDefaultAddOnPurchase($userId: UserID!) {
    nodes {
      addOnPurchase {
        group { # Group type nullable
          id # returns current group
        }
      }
    }
  }

You can use user.user_preferences.default_duo_add_on_assignment to retrieve the default add-on purchase.

def resolve(user_id:)
  User.find(user_id).user_preferences.default_duo_add_on_assignment.add_on_purchase
end
Edited by 🤖 GitLab Bot 🤖