Access a community of over 900,000 Shopify Merchants and Partners and engage in meaningful conversations with your peers.
Hello,
Sorry for the rather basic question. I'm new to GraphQL and the Storefront API. I'm trying to expose some metafields. If i'm reading the docs correctly, I need to first expose them (one time) to then be able to request. I'm having no trouble with basic storefront requests.
Below is what my request looks like. Any thoughts on why this isn't working?
Very much appreciated and again sorry for such a basic question.
best
Eric
function apiSetup () {
return fetch('https://apbookserlin.myshopify.com/admin/api/2021-04/graphql.json', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Shopify-Access-Token': {ADMIN_API_KEY}
},
body: JSON.stringify({
query: `
mutation($input: MetafieldStorefrontVisibilityInput!) {
metafieldStorefrontVisibilityCreate(
input: $input
) {
metafieldStorefrontVisibility {
id
}
userErrors {
field
message
}
}
}
`,
variables: {
"input": {
"namespace": "event",
"key": "time",
"ownerType": "ARTICLE"
}
},
}),
}).then(response => response.json());
}
apiSetup().then(response => {
console.log(response);
});
I was able to figure this out.
The endpoint should be:
/admin/api/graphql.json
The headers should be as follows:
X-Shopify-Access-Token: [Set this to you password field not the api key]
User | RANK |
---|---|
3 | |
2 | |
1 | |
1 | |
1 |