Skip to content

Add AddOnPurchaseType GraphQL

What does this MR do and why?

Add AddOnPurchaseType GraphQL

This MR adds new Graphql type AddOnPurchaseType.

Screenshots or screen recordings

Screenshot_2023-07-14_at_16.12.21

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

  1. Check out the branch
  2. Create a new root group namespace
  3. Setup some seed records
namespace = Namespace.last
add_on = GitlabSubscriptions::AddOn.find_or_create_by!(name: "code_suggestions") {|e| e.description = "Test"}
add_on_purchase = GitlabSubscriptions::AddOnPurchase.create!(
  add_on: add_on, namespace: namespace, expires_on: 1.month.from_now, quantity: 20, purchase_xid: 'A-S0001'
)
full_path = namespace.full_path # for graphql query input
  1. Go to graphql explorer: http://gdk.test:3000/-/graphql-explorer, and use following query and variables

{
  namespace(fullPath: "graph-1") {
    addOnPurchase(addOnName: "CODE_SUGGESTIONS") {
      id
      name
      assignedQuantity
      purchasedQuantity
    }
  }
}
  1. Check correct response is given.
  2. Assign add_on_purchase to user
  add_on_purchase.assigned_users.create!(user: namespace.users.first)
  1. Check the response to have correct assignedQuantity
  2. Change the add_on_type to all caps CODE_SUGGESTIONS, the response should be same
  3. Change the namespace_id to invalid id or not owned by current user
  4. Response should be empty

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #415749

Edited by Bishwa Hang Rai

Merge request reports