A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
Hello,
I'm running into a weird issue when creating an AppSubscription using the GraphQL API.
All my attempts to create an AppSubscription with test:true and trialDays set to 30 are failing. I'm able to create an AppSubscription instance but test is always false and trialDays is not being set as expected so I'm currently blocked with development since I'm testing using a development store. Can any explain what's going on? The mutation, variables and the response are all below.
The mutation I'm using:
mutation appSubscriptionCreate($name: String!, $lineItems: [AppSubscriptionLineItemInput!]!, $returnUrl: URL!) {
appSubscriptionCreate(name: $name, lineItems: $lineItems, returnUrl: $returnUrl) {
appSubscription {
...AppSubscriptionProps
}
confirmationUrl
userErrors {
field
message
}
}
}
fragment AppSubscriptionProps on AppSubscription {
id
createdAt
currentPeriodEnd
name
returnUrl
status
test
trialDays
lineItems {
...AppSubscriptionLineItemProps
}
}
fragment AppSubscriptionLineItemProps on AppSubscriptionLineItem {
id
plan {
pricingDetails {
... on AppRecurringPricing {
__typename
interval
price {
amount
currencyCode
}
}
... on AppUsagePricing {
__typename
balanceUsed {
amount
currencyCode
}
cappedAmount {
amount
currencyCode
}
interval
terms
}
}
}
}
The variables I'm passing in:
{
"name": "cant set test or freetrial",
"returnUrl": "https://test.com/activateCharge",
"trialDays": 30,
"test": true,
"lineItems": [
{
"plan": {
"appRecurringPricingDetails": {
"interval": "EVERY_30_DAYS",
"price": {
"amount": 15,
"currencyCode": "USD"
}
}
}
},
{
"plan": {
"appUsagePricingDetails": {
"cappedAmount": {
"amount": 100000,
"currencyCode": "USD"
},
"terms": "test terms"
}
}
}
]
}
The response:
{
"data": {
"appSubscriptionCreate": {
"appSubscription": {
"id": "gid:\/\/shopify\/AppSubscription\/13896876109",
"createdAt": "2020-09-26T20:50:33Z",
"currentPeriodEnd": null,
"name": "cant set test or freetrial",
"returnUrl": "https:\/\/test.com\/activateCharge",
"status": "PENDING",
"test": false,
"trialDays": 0,
"lineItems": [
{
"id": "gid:\/\/shopify\/AppSubscriptionLineItem\/13896876109?v=1&index=0",
"plan": {
"pricingDetails": {
"__typename": "AppRecurringPricing",
"interval": "EVERY_30_DAYS",
"price": {
"amount": "15.0",
"currencyCode": "USD"
}
}
}
},
{
"id": "gid:\/\/shopify\/AppSubscriptionLineItem\/13896876109?v=1&index=1",
"plan": {
"pricingDetails": {
"__typename": "AppUsagePricing",
"balanceUsed": {
"amount": "0.0",
"currencyCode": "USD"
},
"cappedAmount": {
"amount": "100000.0",
"currencyCode": "USD"
},
"interval": "EVERY_30_DAYS",
"terms": "test terms"
}
}
}
]
},
"confirmationUrl": "https:\/\/huges-stooges.myshopify.com\/admin\/charges\/13896876109\/confirm_recurring_application_charge?signature=BAh7BzoHaWRsKwhNgFE8AwA6EmF1dG9fYWN0aXZhdGVU--51925976d8ab5de1d6a99cb45ce46d703d864c57",
"userErrors": []
}
},
"extensions": {
"cost": {
"requestedQueryCost": 13,
"actualQueryCost": 13,
"throttleStatus": {
"maximumAvailable": 1000.0,
"currentlyAvailable": 987,
"restoreRate": 50.0
}
}
}
}
Thank you
Solved! Go to the solution
This is an accepted solution.
I was passing in the variables but didn't declare them in the mutation string... 🤦♂️
This is an accepted solution.
I was passing in the variables but didn't declare them in the mutation string... 🤦♂️