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!
Hey Community! As the holiday season unfolds, we want to extend heartfelt thanks to a...
By JasonH Dec 6, 2024Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024Hey Community! It’s time to share some appreciation and celebrate what we have accomplis...
By JasonH Nov 14, 2024