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!
2m ago Learn the essential skills to navigate the Shopify admin with confidence. T...
By Shopify Feb 12, 2025Learn how to expand your operations internationally with Shopify Academy’s learning path...
By Shopify Feb 4, 2025Hey Community, happy February! Looking back to January, we kicked off the year with 8....
By JasonH Feb 3, 2025