Hey everyone, how do you verify that the theme app embed has been enabled without relying on the Assets API? Currently, I’m sending a request from the theme app embed to my app to confirm activation, but the downside is that it only gets triggered when someone visits the store. I feel like there should be a better way any suggestions?
As of now, you can detect it only using Asset API. While that is not a bad thing, since reading Assets are not a problem.
You would need to query settings_data.json and check for your app embed.
Here’s a good documentation for it:
Yeah, @Simo_Aissaoui you should be able to utilize the theme part of the GraphQL Admin API to get the details as I shared in this other topic.
@RobDukarski @prakhar thank you guys It worked
I thought I needed an exemption to access the Assets API but it turns out I don’t for querying
Appreciate your help!
Hi Simo - you only need exempion for write but read is okay ![]()
Thank you so much for your help, Liam ![]()
@Liam-Shopify @prakhar Hi,
Since Asset API is now deprecated, what is the alternate method that is followed now to fetch the app embed status??
I am also looking for same !!
You can fetch the theme resource using the GraphQL admin API: theme - GraphQL Admin
@baggio_giacomo The document you shared seems to depict the way of fetching a theme based on the id right, if I’m not wrong. I have a question here like, how come you know the current theme details using the graphql, because with the current theme details only we will be able to check the app embed status. As per my learnings so far, there is no direct approach to get the current published theme. That can be done only by fetching the available themes from the store and then by checking their role, which is a time consuming process right? As @prakhar mentioned in his chat, until now asset API is the only option to go with finding active theme. @Liam-Shopify does shopify has any leads because as all know asset API is deprecated and shopify officially wants us to move to graphql..
To get the published theme you just need to call this query:
query getMainTheme {
themes(first: 1, roles: [MAIN]) {
nodes {
id
name
}
}
}
query {
themes(first: 1, roles: [MAIN]) {
nodes {
name
id
role
files(filenames: "config/settings_data.json", first: 10) {
nodes {
filename
body {
... on OnlineStoreThemeFileBodyText {
content
}
}
}
}
}
}
}
try this.
The documentation on this topic is really very scarce.