Add AddOnPurchase to response
What does this MR do and why?
Add AddOnPurchase to response
We extend the mutation userAddOnAssignmentCreate
's response to return
AddOnPurchase
type. This will help client to save extra request
to fetch the AddOnPurchase info again, after mutation.
We also remove ability to self-assign from this mutation for now, as it will be worked on different issue/endpoint: https://gitlab.com/gitlab-org/gitlab/-/issues/420138. This makes authorization simple with only admin_add_on_purchase
ability check.
Screenshots or screen recordings
How to set up and validate locally
- Check out the branch
- Create a new root group namespace
- 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: 5, purchase_xid: 'A-S0001'
)
add_on_purchase.to_global_id.to_s # "gid://gitlab/GitlabSubscriptions::AddOnPurchase/9"
namespace.users.first.to_global_id.to_s # "gid://gitlab/User/85"
# enable the feature flag
Feature.enable(:hamilton_seat_management)
- Go to graphql explorer (logged in as owner/admin): http://gdk.test:3000/-/graphql-explorer, and use following query and variables
mutation {
userAddOnAssignmentCreate(
input: {
userId: "gid://gitlab/User/85",
addOnPurchaseId: "gid://gitlab/GitlabSubscriptions::AddOnPurchase/9"
}) {
addOnPurchase {
id
name
purchasedQuantity
assignedQuantity
}
errors
}
}
- The response should now have additional
addOnPurchase
object attributes - If we log out as owner, and log in as developer/guest user, then perform the above query it should return
null
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #419098
Edited by Bishwa Hang Rai