Skip to content

Instantly share code, notes, and snippets.

@danyn
Last active October 5, 2022 04:21
Show Gist options
  • Save danyn/6654d1af55a72521f0f5eee62edd6e0f to your computer and use it in GitHub Desktop.
Save danyn/6654d1af55a72521f0f5eee62edd6e0f to your computer and use it in GitHub Desktop.
getShopMetafieldsByNamespace
query GetShopMetafieldsByNamespace($namespace: String!) {
shop {
metafields(namespace: $namespace, first:50) {
nodes {
id,
value
}
}
}
}
"""
Put a metafield on any resource must be configured with the resource gid ex(shopGid, productGid etc...)
MetafieldsSetInput: https://shopify.dev/api/admin-graphql/2022-04/mutations/metafieldsSet#returns
field = {
"key": "",
"namespace": "",
"ownerId": "resourceGid",
"type": "",
"value": ""
}
variables: {
metafields: [field1, field2],
},
"""
const PUT_METAFIELDS = `
mutation metafieldsSet($metafields: [MetafieldsSetInput!]!) {
metafieldsSet(metafields: $metafields) {
metafields {
key
namespace
value
createdAt
updatedAt
id
}
userErrors {
field
message
code
}
}
}
`;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment