New Shopify Certification now available: Liquid Storefronts for Theme Developers

SubscriptionContracts Query Returns Empty

mt686
Shopify Partner
52 9 17

Hi!

The problem I'm having is no matter how I query subscription contracts on a store, nothing shows. I installed a custom subscription app on a store that has existing subscriptions, (by the app "Appstle"), and nothing shows when you query subscription contracts. You can see customers have subscriptions in the Shopify admin, but there's nothing there when you use the GQL api. I've tried accessing them in bulk, by id, and through the custom object. It's always a 200 ok response but with no subscription contracts. Here's examples of my querys:

Trying all subscriptions:

 

{
    subscriptionContracts(first:50){
        edges{
            node {
                id
            }
        }
    }
}

 

Returns:

 

    "data": {
        "subscriptionContracts": {
            "edges": []
        }
    },

 



Trying by customer:

 

{
    customers (first: 10, reverse: true){
        edges {
            node {
                id
                subscriptionContracts (first: 5){
                    edges {
                        node {
                            id
                        }
                    }
                }
            }
        }
    }
}

 

Returns:

 

    "data": {
        "customers": {
            "edges": [
                {
                    "node": {
                        "id": "gid://shopify/Customer/XXX",
                        "subscriptionContracts": {
                            "edges": []
                        }
                    }
                }
            ]
        }
    },

 



 Trying by id:

 

{
    subscriptionContract(id:"gid://shopify/SubscriptionContract/10916331831") {
        id
    }
}

 

 Returns:

 

    "data": {
        "subscriptionContract": null
    },

 

 

I can see through the Shopify admin there are subscription contracts that exist, through the Subscription API, but no matter how I try I cannot query them. Any help is appreciated!

Thank you

Replies 2 (2)
SBD_
Shopify Staff
Shopify Staff
1663 233 342

Hey @mt686 

 

I believe apps can only query for their own subscription contracts. More here:  https://shopify.dev/docs/apps/selling-strategies/subscriptions/contracts#requirements

Scott | Developer Advocate @ Shopify 

Brian_S
Shopify Partner
127 18 36

Thats correct - and I believe that's why they named the scope read and write own  subscription contracts (`read_own_subscription_contracts`, `write_own_subscription_contracts`)

 

The way to query for subs would be to use your subscription app's public API

 

Brian Singer
CTO & Cofounder of Subscription Service - Awtomic