I am developing a Shopify app with all last versions of Shopify CLI / Remix …
My app is creating a kind of “token” I need to use in my extension, I have stored this value in my Prisma database, and after reading a ton of topics, I can’t figure out how to access this value in my extension.
Some topics say to create a route and use app proxy to expose this data and get it from fetch in my extension, but where should I create this route ? In my backend app ? How to configure my app proxy then ?
Or some topics talk about metaFields, I tried to create a metaField in my app backend :
const response = await admin.graphql(
`#graphql
mutation CreateMetafieldDefinition($definition: MetafieldDefinitionInput!) {
metafieldDefinitionCreate(definition: $definition) {
createdDefinition {
id
name
}
userErrors {
field
message
code
}
}
}`,
{
variables: {
definition: {
name: "Scripts ID",
namespace: "$app:data",
key: "token",
description: "Script ids of the current user.",
type: "single_line_text_field",
ownerType: "SHOP",
access: {
admin: "MERCHANT_READ",
storefront: "PUBLIC_READ",
},
},
},
},
);
It works, but then, how to access this in my app extension ? I tried :
{{ shop.metafields.app--1661179XXXXX--data.token.value }}
But nothing is showed, I read I need to use $app for the namespace to expose it in StoreFront, but how to get it in my extension then ? Is it possible ?
Thanks, I can’t find any answer.