Retrieve the active subscription from the Query Root?

Hi there,

Just curious, is there an easier way to get the current merchant’s active subscription from the Query Root without relying on a GID of the app installation or the subscription ID when first creating the subscription URL?

For usage plans especially this is helpful, since we need to store the usage plan line item for capturing usage charges.

But I’m not seeing a clear cut way to retrieve the active subscription directly from a Shop instance.

Hey @Dylan

I’m assuming your talking about your apps subscription, you can get it from the currentAppInstallation

This is what I use:

query getCurrentSubscription {
  currentAppInstallation {
    activeSubscriptions {
      id
      name
      currentPeriodEnd
      trialDays
      status
    }
  }
}

If you’re after what plan the store is on as in the Shopify plan you can use

query getShopOwnerInfo {
  shop {
    name
    myshopifyDomain
    contactEmail
    email
    setupRequired
    plan {
      displayName
      shopifyPlus
      partnerDevelopment
    }
  }
}
1 Like

Thanks @JordanFinners

the getCurrentSubscription example is exactly what I was looking for.

As a side note, the activeSubscriptions field name is kind of confusing. That’s the first attribute I’ve seen where it’s plural yet there’s no connection, it’s just a single field.

But the name suggests there can be multiple. A little odd, but hey it works.

Thanks again!

1 Like