Our application is fetching SellingPlanGroup data from the GraphQL API and we found that in some scenarios the SellingPlanGroup.appId field has a text value rather than a Shopify GID which would point to an App object. We tried to search Apps using the text values as the handle but they do not seem to exist. Could you please clarify where those values could come from?
Looking at the webhooks for SellingPlanGroup we can see 2 fields admin_graphql_api_app and app_id. The GraphQL appId field seems to come from the app_id field. Could you please clarify why there are 2 different app fields in the SellingPlanGroup webhooks?
See below for a couple of examples
{
"admin_graphql_api_id": "gid://shopify/SellingPlanGroup/233275456",
"id": 233275456,
"admin_graphql_api_app": "gid://shopify/App/3780451",
"app_id": "ReStock",
}
{
"admin_graphql_api_id": "gid://shopify/SellingPlanGroup/949485647",
"id": 949485647,
"admin_graphql_api_app": "gid://shopify/App/66228322305",
"app_id": "gid://shopify/App/66228322305",
}
Hey @Mathieu_Nunez! The appId field on SellingPlanGroup is actually a freeform String, not a reference to an App resource. It’s a custom value that the app sets when calling sellingPlanGroupCreate. Its purpose is to be exposed in Liquid and product JSON so themes can filter selling plan groups by app.
So when you see "app_id": "ReStock", that just means the app that created that selling plan group chose to set its appId to the string “ReStock”. And when you see it set to a GID, that means the app happened to pass its own GID as the value. Both are valid since it accepts any string (or null if the app doesn’t set it at all).
As for the two fields in webhook payloads, they serve different purposes. admin_graphql_api_app is the actual GID of the App that created the selling plan group, set automatically by Shopify. app_id maps to the GraphQL appId field described above. If you need to reliably identify which app created a selling plan group, admin_graphql_api_app is the one to use since it’s always a proper GID.
Hope that clears things up!
Thanks @Donal-Shopify! This is exactly hat I was after.
1 Like