Hi,
I am helping a client build a method /webhook that edits the orders object whenever a new order is created, I got the webhook working well, but when i go to call the admin api for graphQL in the event hook event it doesn’t work.
Line 36 is when the issue occurs, is this the correct way to build a simple script that mutates/edits the order object whenever a new order is created?
it doesnt find he admin object after deconstructing
// Authenticate webhook and parse the shop and topic
const { shop, topic, payload, admin} = await authenticate.webhook(request);
Please help my client needs this asap
P.S
I tried converting the remix app to use a mysql db but it broke my app and webhook. I am just lost what I want to do is simple but I am having infrastructure issues
it doesnt find he admin object after deconstructing
// Authenticate webhook and parse the shop and topic
const { shop, topic, payload, admin} = await authenticate.webhook(request);
First off, I assume you’re using the Shopify Remix app template, just based off of the short snippet of code you shared.
The authentication of both session tokens and webhooks relies on the Session manager. There are different session adapters available, some are managed by Shopify but others can be custom to support other databases like MongoDB.
Which session adapter are you using for integrating the Shopify package to your database?
The problem might be that your session manager isn’t loading the session properly. If the Shopify NPM package cannot find your session, then admin will be undefined. Please see this line here:
So i fixed the issue kinda, i created another route called api/test
if im using a clean loader without an auth (request token) the get api/test works fine, but when i add a. request param it doesnt work and throws 410 error why might this be. it isnt even hitting the end point. am i missing something?
I did a quick test using a newly created remix app (created with shopify app init). I then added the following scope and webhook to my shopify.app.toml:
This successfully logged the webhook being received, as well as the response from the GraphQL with the orders for the shop. You should be able to hopefully use this as a rough template for what you are trying to accomplish.
If you are running into further issues please include any errors you are receiving along with your code snippets. As Dylan mentioned it may also be related to the session manager you are using if the code snippets above aren’t working as expected with your setup, in which case please provide more details on what you are using for a session manager and any other additional configurations you may have made.
If you are just using the webhooks remix template you shouldn’t have to worry about the session manager as that should all work out of the box. The code snippet I provided I tested with a newly created app remix, and saw the webhook logged along with the GraphQL response data as expected. Could you provide the log output you are seeing along with any errors?