GraphQL Webhook Body Shape

What is the expected shape of the webhook body that will be sent from Shopify when creating a webhook via the GraphQL API?

I haven't been able to find this kind of into in the GraphQL documentation. It's frustratingly bare:

https://shopify.dev/docs/admin-api/graphql/reference/object/webhooksubscription

 

Can I rely on the expected body of the webhooks created via the REST API? What about webhook topics that aren't available in the REST API e.g. APP_SUBSCRIPTIONS_UPDATE?

TrackPack

Gain shipment visibility, increase customer confidence and optimize your customer support using TrackPack's Email / SMS shipping notifications and order tracking page generator.
0 Likes
mikedasilva
Shopify Staff
Shopify Staff
26 2 2

Hi @TrackPack,

When creating a webhook subscription through the GraphQL API, the response you get really depends on what your query looks like. For example, if you create a webhook subscription with the following mutation:

mutation {
  eventBridgeWebhookSubscriptionCreate(
    topic: ORDERS_CREATE
    webhookSubscription: {
      arn: "arn:aws:events:us-east-1::event-source/aws.partner/shopify.com/XXXXX/example-name-here"
      format: JSON
  })
  {
    webhookSubscription {
      id
    }
    userErrors {
      message
    }
  }
}

 

 

You'll get a response that also includes the webhookSubscription with "id" because you specified to return that in the query above.

{
    "data": {
        "eventBridgeWebhookSubscriptionCreate": {
            "webhookSubscription": {
                "id": "gid://shopify/WebhookSubscription/1234567890"
            },
            "userErrors": []
        }
    },
    "extensions": {
        "cost": {
            "requestedQueryCost": 10,
            "actualQueryCost": 10,
            "throttleStatus": {
                "maximumAvailable": 1000.0,
                "currentlyAvailable": 990,
                "restoreRate": 50.0
            }
        }
    }
}

 

You can add other fields that you'd like returned when creating a subscription, you just have to modify that query. 

 

Cheers,

Mike

mikedasilva | Developer @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

0 Likes

Hi @mikedasilva ,

Forgive me if my question wasn't clear. I'm not asking about the shape of the mutation response that gets returned to me when creating a webhook subscription. My question is about the shape of the object that Shopify will send through to the WebhookSubscription.endpoint. This is not documented anywhere in the GraphQL Admin API docs so I'd like to be pointed to some documentation around that.

Thanks!

TrackPack

Gain shipment visibility, increase customer confidence and optimize your customer support using TrackPack's Email / SMS shipping notifications and order tracking page generator.
0 Likes
mikedasilva
Shopify Staff
Shopify Staff
26 2 2

Hi @TrackPack,

Ah yes, sorry, I misunderstood the question. The payload that you receive will be the same as what you would get when you subscribe to the webhook via the rest API. So as you may have already come across, there's a list of events and topics with example responses available here https://shopify.dev/docs/admin-api/rest/reference/events/webhook.

I'll forward along the feedback about that information missing from the GraphQL reference docs.

Cheers,

Mike

 

mikedasilva | Developer @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

0 Likes

@mikedasilva this is good to know for the webhooks that the REST API covers. However, there are others that can only be created using the GraphQL API e.g. APP_SUBSCRIPTIONS_UPDATE that have no documentation around them.

Could you provide a reference for the webhook body shapes for all the webhooks that are only available via the GraphQL API?

Thank you

TrackPack

Gain shipment visibility, increase customer confidence and optimize your customer support using TrackPack's Email / SMS shipping notifications and order tracking page generator.
0 Likes