Field 'appSubscription' doesn't exist on type 'QueryRoot'

Topic summary

A developer encounters an error when querying appSubscription directly in Shopify’s GraphQL API (version 2024-10). The error message indicates that the field doesn’t exist on the QueryRoot type.

The Issue:

  • Attempting to fetch app subscription charge status using appSubscription(id: $chargeId) fails
  • The query structure appears to directly access appSubscription as a root-level field

Working Solution Provided:
Another user shares a PHP implementation that successfully retrieves subscription data by:

  • Using the node query instead of appSubscription
  • Base64-encoding the subscription GID before passing it to the query
  • Querying through the node interface with fragment spreading (... on AppSubscription)
  • Using API version 2025-01

Key Difference:
The working approach uses node(id:) as the entry point rather than querying appSubscription directly, suggesting the API structure may have changed or requires this indirect access pattern for subscription queries.

Summarized with AI on November 2. AI used: claude-sonnet-4-5-20250929.

Hi all,

i am using 2024-10 API version and trying fetch charge status but getting below error.

Error: Field ‘appSubscription’ doesn’t exist on type ‘QueryRoot’. Below is the code

const response = await admin.graphql(
#graphql query GetChargeStatus { appSubscription(id: $chargeId) { id status } },
{
“variables”: {
“id”: gid://shopify/AppSubscription/${charge_id}
}
}
);

Any help would be really appreciated.

This works for me in PHP

public function getRecurringCharge() {
$shop_url = ‘your-shop-name.myshopify.com’;
$access_token = ‘your-access-token’;

$encodedId = base64_encode(“gid://shopify/AppSubscription/28125626551”);

$query = <<<QUERY
{
node(id: “$encodedId”) {
… on AppSubscription {
id
name
status
currentPeriodEnd
test
trialDays
createdAt
returnUrl
lineItems {
id
}
}
}
}
QUERY;

$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => “https://$shop_url/admin/api/2025-01/graphql.json”,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => ‘POST’,
CURLOPT_HTTPHEADER => [
‘Content-Type: application/json’,
“X-Shopify-Access-Token: $access_token”,
],
CURLOPT_POSTFIELDS => json_encode([‘query’ => $query])
]);

$response = curl_exec($curl);
$error = curl_error($curl);
curl_close($curl);

if ($error) {
throw new Exception(“cURL Error: $error”);
}

return json_decode($response, true);
}