Hello,
I am new to Shopify, and I really can’t find an answer to my dilemma.
I am trying to make a series of calls to the admin API (rest, GraphQL).
From what I understand from the documentation, every query abstraction needs a session object to get the accessToken and shop from like so.
const product = new shopify.rest.Product({session: session});
Since my app’s scaffold was generated by the command:
npm init @shopify/app@latest
And after reading the generated code and trying to understand how everything works, the conclusion I got to is that the session object is constructed through the middleware
shopify.validateAuthenticatedSession()
and added to the res.locals, so on every request from the frontend with app-bridge using authenticatedFetch() to make sure it is authenticated.
What I am trying to do is to query the store products every set interval of times using cron-node to do some job outside of any route something like:
cron.schedule('* * * 1 * *', function () {
await titlesUpdator(session);
});
while titleUpdator() is a normal function that runs an admin API call, and no matter how long I searched there seems to be no straightforward way to construct a session object from the sessionStorage (for now it’s an SQLite database).
Any help on how to tackle that would be greatly appreciated.
Thank you so very much.