subscriptionBillingCycles
Returns subscription billing cycles for a contract ID.
SubscriptionBillingCycleConnection arguments
- Anchor to afterafter•
The elements that come after the specified cursor.
- Anchor to beforebefore•
The elements that come before the specified cursor.
- Anchor to billingCyclesDateRangeSelectorbilling•
Cycles Date Range Selector Select subscription billing cycles within a date range.
- Anchor to billingCyclesIndexRangeSelectorbilling•
Cycles Index Range Selector Select subscription billing cycles within an index range.
- Anchor to contractIdcontract•
Id ID!required The ID of the subscription contract to retrieve billing cycles for.
- Anchor to firstfirst•
The first
n
elements from the paginated list.- Anchor to lastlast•
The last
n
elements from the paginated list.- Anchor to reversereverse•BooleanDefault:false
Reverse the order of the underlying list.
- Anchor to sortKeysort•
Key SubscriptionBilling Default:CYCLE_INDEXCycles Sort Keys Sort the underlying list using a key. If your query is slow or returns an error, then try specifying a sort key that matches the field used in the search.
Anchor to Possible returnsPossible returns
- Anchor to edgesedges•[Subscription
Billing non-nullCycle Edge!]! The connection between the node and its parent. Each edge contains a minimum of the edge's cursor and the node.
- Anchor to nodesnodes•[Subscription
Billing non-nullCycle!]! A list of nodes that are contained in SubscriptionBillingCycleEdge. You can fetch data about an individual node, or you can follow the edges to fetch data about a collection of related nodes. At each node, you specify the fields that you want to retrieve.
- Anchor to pageInfopage•
Info PageInfo! non-null An object that’s used to retrieve cursor information about the current page.
- Get the billing cycles between specific dates
- Get the billing cycles between specific indexes
Examples
query subscriptionBillingCycles($contractId: ID!) {
subscriptionBillingCycles(first: 10, contractId: $contractId, billingCyclesDateRangeSelector: {startDate: "2022-12-15T00:00:00Z", endDate: "2023-02-15T00:00:00Z"}) {
edges {
node {
billingAttemptExpectedDate
}
}
}
}
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2024-04/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "query subscriptionBillingCycles($contractId: ID!) { subscriptionBillingCycles(first: 10, contractId: $contractId, billingCyclesDateRangeSelector: {startDate: \"2022-12-15T00:00:00Z\", endDate: \"2023-02-15T00:00:00Z\"}) { edges { node { billingAttemptExpectedDate } } } }",
"variables": {
"contractId": "gid://shopify/SubscriptionContract/593791907"
}
}'
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
query subscriptionBillingCycles($contractId: ID!) {
subscriptionBillingCycles(first: 10, contractId: $contractId, billingCyclesDateRangeSelector: {startDate: "2022-12-15T00:00:00Z", endDate: "2023-02-15T00:00:00Z"}) {
edges {
node {
billingAttemptExpectedDate
}
}
}
}`,
{
variables: {
"contractId": "gid://shopify/SubscriptionContract/593791907"
},
},
);
const data = await response.json();
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `query subscriptionBillingCycles($contractId: ID!) {
subscriptionBillingCycles(first: 10, contractId: $contractId, billingCyclesDateRangeSelector: {startDate: "2022-12-15T00:00:00Z", endDate: "2023-02-15T00:00:00Z"}) {
edges {
node {
billingAttemptExpectedDate
}
}
}
}`,
"variables": {
"contractId": "gid://shopify/SubscriptionContract/593791907"
},
},
});
session = ShopifyAPI::Auth::Session.new(
shop: "your-development-store.myshopify.com",
access_token: access_token
)
client = ShopifyAPI::Clients::Graphql::Admin.new(
session: session
)
query = <<~QUERY
query subscriptionBillingCycles($contractId: ID!) {
subscriptionBillingCycles(first: 10, contractId: $contractId, billingCyclesDateRangeSelector: {startDate: "2022-12-15T00:00:00Z", endDate: "2023-02-15T00:00:00Z"}) {
edges {
node {
billingAttemptExpectedDate
}
}
}
}
QUERY
variables = {
"contractId": "gid://shopify/SubscriptionContract/593791907"
}
response = client.query(query: query, variables: variables)