For discussing the development and integration of subscription-enabled shops using Shopify's Subscription APIs.
Hi All,
We've noticed that every once in a while we don't receive the contract creation webhook from Shopify, which leads to a missed subscription in our app.
To counter this, we'd like to query all active shops daily, and compare their most recent contracts to our database to catch any that were not sent. We're struggling with the GraphQL APIs to make this possible.
Many GraphQL endpoints have a query: parameter that lets us add something like
first:20, query:"created_at:>2019-12-05T10:10:10Z created_at:<2019-12-09T12:12:12Z"
But the subscriptionContracts endpoint doesn't appear to support this.
Can anybody suggest a way to get a list of all subscription contracts created within a date range? Even if there was a way for us to track a cursor that we could use with the "after:" parameter, I think that could also work.
Thanks in advance.
Chris
Solved! Go to the solution
This is an accepted solution.
Hi,
You can get the cursor for example:
{
subscriptionContracts(first: 10) {
edges {
node {
id
appAdminUrl
billingPolicy {
interval
intervalCount
minCycles
maxCycles
}
deliveryMethod {
... on SubscriptionDeliveryMethodShipping {
address {
city
countryCode
address2
firstName
}
shippingOption {
code
description
}
}
}
deliveryPolicy {
interval
intervalCount
}
deliveryPrice {
amount
currencyCode
}
}
cursor
}
}
}
After you get the cursor, the next time you could fetch the contracts created after the specific cursor (e.g. give me the next 10 contracts after the cursor):
{
subscriptionContracts(first: 10, after: "cursor of your latest subscription") {
edges {
node {
id
appAdminUrl
billingPolicy {
interval
intervalCount
minCycles
maxCycles
}
deliveryMethod {
... on SubscriptionDeliveryMethodShipping {
address {
city
countryCode
address2
firstName
}
shippingOption {
code
description
}
}
}
deliveryPolicy {
interval
intervalCount
}
deliveryPrice {
amount
currencyCode
}
}
cursor
}
}
}
Another note: if you have more details that you could share about the case where you don't receive the webhook, feel free to share it with me. If it contains any sensitive information you can always DM me the app/shop details. We can track/investigate the issue on our side.
Hope this helps!
To learn more visit the Shopify Help Center or the Community Blog.
This is an accepted solution.
Hi,
You can get the cursor for example:
{
subscriptionContracts(first: 10) {
edges {
node {
id
appAdminUrl
billingPolicy {
interval
intervalCount
minCycles
maxCycles
}
deliveryMethod {
... on SubscriptionDeliveryMethodShipping {
address {
city
countryCode
address2
firstName
}
shippingOption {
code
description
}
}
}
deliveryPolicy {
interval
intervalCount
}
deliveryPrice {
amount
currencyCode
}
}
cursor
}
}
}
After you get the cursor, the next time you could fetch the contracts created after the specific cursor (e.g. give me the next 10 contracts after the cursor):
{
subscriptionContracts(first: 10, after: "cursor of your latest subscription") {
edges {
node {
id
appAdminUrl
billingPolicy {
interval
intervalCount
minCycles
maxCycles
}
deliveryMethod {
... on SubscriptionDeliveryMethodShipping {
address {
city
countryCode
address2
firstName
}
shippingOption {
code
description
}
}
}
deliveryPolicy {
interval
intervalCount
}
deliveryPrice {
amount
currencyCode
}
}
cursor
}
}
}
Another note: if you have more details that you could share about the case where you don't receive the webhook, feel free to share it with me. If it contains any sensitive information you can always DM me the app/shop details. We can track/investigate the issue on our side.
Hope this helps!
To learn more visit the Shopify Help Center or the Community Blog.
Thanks for your reply. We'll implement this for now, but I hope Shopify will allow us to use filters and queries on subscription endpoints in the future