Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Is it possible to find the product associated with specific contracts?

Is it possible to find the product associated with specific contracts?

cavin
Shopify Partner
3 0 0

Im working with the subscription API and I want to use the Graph QL admin API to query subscription contracts but I want to pull in the products/variants that are associated with specific subscription contracts.

My understanding is that products/variants are only associated with selling plan groups and not selling plans but is there any way to get the specific relationship data that I'm looking for?

 

 

Reply 1 (1)

dwyckoff
Shopify Staff
15 1 3

Hey Cavin, great question.
Investigating our API, it looks like you are correct that there is no direct connection between a subscription contract and it's variants. The best you can do is pull all the product / variant ids for a contract:

query subsContract($subscriptionContractId: ID!) {
  subscriptionContract(
    id: $subscriptionContractId
  ) {
    lines(first: 250) {
      edges {
        node {
          productId,
          variantId
        }
      }
    }
  }
}

 And then on the client side you can iteratively pull the product & variants with the response.
I'd love to have some context about how you are pulling contract ids, and why you need the product / variant data. Then I could document this potential use case with our team.

To learn more visit the Shopify Help Center or the Community Blog.