Add start_date and end_date args to subscriptionUsage

What does this MR do and why?

This adds start_date and end_date args to subscriptionUsage as part of https://gitlab.com/gitlab-org/gitlab/-/work_items/594756

Clients can now query subscription usage passing date range. Defaults to beginning and end of current month.

References

Screenshots or screen recordings

N/A

How to set up and validate locally

  1. Checkout this MR's steps to generate some data.
  2. Open GraphQL and execute this query:

Query:

query getSubscriptionUsage($namespacePath: ID,  $startDate: ISO8601Date, $endDate: ISO8601Date) {
  subscriptionUsage(namespacePath: $namespacePath, startDate: $startDate, endDate: $endDate) {
    enabled
    isOutdatedClient
    lastEventTransactionAt
    startDate
    endDate
    purchaseCreditsPath
    creditsUsed
    overageTermsAccepted
    canAcceptOverageTerms
    dapPromoEnabled
    subscriptionPortalUsageDashboardUrl
    monthlyWaiver {
      totalCredits
      creditsUsed
      dailyUsage {
        date
        creditsUsed
      }
    }
    monthlyCommitment {
      totalCredits
      creditsUsed
      dailyUsage {
        date
        creditsUsed
      }
    }
    overage {
      isAllowed
      creditsUsed
      dailyUsage {
        date
        creditsUsed
      }
    }
    paidTierTrial {
      isActive
      dailyUsage {
        date
        creditsUsed
      }
    }
    usersUsage {
      totalUsersUsingCredits
      totalUsersUsingMonthlyCommitment
      totalUsersUsingOverage
      creditsUsed
      dailyUsage {
        date
        creditsUsed
      }
      users(first: 10, sort: TOTAL_CREDITS_USED_DESC) {
        pageInfo {
          hasNextPage
          hasPreviousPage
          startCursor
          endCursor
        }
        nodes {
          id
          name
          username
          avatarUrl
          usage {
            creditsUsed
            totalCredits
            monthlyCommitmentCreditsUsed
            monthlyWaiverCreditsUsed
            paidTierTrialCreditsUsed
            overageCreditsUsed
          }
          usedFlowTypes {
            id
            title
          }
          events(first: 5) {
            pageInfo {
              hasNextPage
              hasPreviousPage
              startCursor
              endCursor
            }
            nodes {
              timestamp
              eventType
              flowType
              creditsUsed
              sessionLink
              location {
                ... on Project {
                  id
                  name
                  fullPath
                }
                ... on Group {
                  id
                  name
                  fullPath
                }
              }
            }
          }
        }
      }
    }
  }
}

Variables:

{
  "namespacePath": "ultimate-group1",
  "startDate": "2026-03-01",
  "endDate": "2026-03-31"
}

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Sheldon Led

Merge request reports

Loading
Loading