I want to add a scripttag to an Onlinestore, and I managed to do it with the GraphQL explorer/app.
But I am completely lost in how to do it programmatically in my app, and the Shopify documentation doesn't really help me.
My goal: When a merchant presses a button in his admin page, I want my app to post a scripttag to this store.
I have created the an app with the Shopify App CLI.
In the server folder the CLI creates (these are the parts I suspect are important)
//this is in file "server.js"
router.post("/graphql", verifyRequest(), async (ctx, next) => {
await Shopify.Utils.graphqlProxy(ctx.req, ctx.res);
});
In server/handlers/mutations/
The CLI creates two files "get-subscription-url.js" and "get-one-time-url.js" where Graph Ql calls are done.
However, I dont understand how the frontend (the pages folder) can make these API calls.
If the merchant presses a button, how can I let apollo make a mutation api call? How is it authenticated?
Or do I (somehow) have to pass the API Call request to my backend, the server folder (maybe the route /graphql ?), so that the backend executes the mutation/query?