App reviews, troubleshooting, and recommendations
I'm adding a webhook, and in that webhook I want to make a graphql call to modify an order.
export const action = async ({ request }) => {
const { payload, topic, shop, session, admin } = await authenticate.webhook(request);
switch (topic) {
...
case "CHECKOUTS_CREATE":
if (admin) {
admin.graphql.query(`query here...`)
}
...
I assumed that I could use the graphql client here, but I get a TS error `Argument of type 'string' is not assignable to parameter of type 'GraphqlParams'.`
What is the right way to do this?
OK, so for some reason the `admin.graphql` that comes back from `authenticate.webhook` is different than what comes back from `authenticate.admin`. If I pass `{data: "query here..."}` this works. Now I just need to craft the right query.
Damn, thanks man. I really hate Shopify's docs.
inside yourAppName/app/routes/webhooks.jsx
case "CHECKOUTS_CREATE":
if (session) {
const response = await admin.graphql.query({data: `
query {
shop {
name
}
}`
});
}
break;
I'm getting the same issue. Would you mind sharing the docs you refer to / what was your solution?
Thanks!
if anyone is facing the same issue, here's what works for me:
isHook - true if it's from webhook's admin, false if it's from the web admin.
I have spent so long trying to figure out how to make admin graphQL calls from a webhook, and your answer solved it. Sincerely, thank you so much for sharing.
PS: Why there doesn't seem to be anything about this in the docs is beyond me!
June brought summer energy to our community. Members jumped in with solutions, clicked ...
By JasonH Jun 5, 2025Learn how to build powerful custom workflows in Shopify Flow with expert guidance from ...
By Jacqui May 7, 2025Did You Know? May is named after Maia, the Roman goddess of growth and flourishing! ...
By JasonH May 2, 2025