graphql - 如何在 Shopify 中使用 GraphQL 更新 Shop Metafields
问题描述
如何在 shopify 中使用 GraphQL 创建/更新商店元字段?我可以使用以下内容轻松创建集合元字段:
mutation {
collectionUpdate(
input: {
id: "gid"
metafields: [
{
namespace: "testNamespace"
key: "testKey"
value: "someValue2"
valueType: STRING
}
{
id: "gid"
value: "value"
}
]
}
) {
collection {
id
metafields(first: 10) {
edges {
node {
id
value
}
}
}
}
userErrors {
field
message
}
}
}
但是这家商店似乎没有等价物。此外,可以使用以下方法检索商店元字段:
{
shop {
metafield(namespace:"namespace",key:"key") {
id
value
}
}
}
解决方案
要更新任何元字段,您可以使用突变“ metafieldsSet ”
mutation setMetafield($metafields: [MetafieldsSetInput!]!) {
metafieldsSet(metafields:$metafields){
metafields{
id
key
value
}
userErrors{
code
message
}
}
}
MetafieldsSetInput需要您可以从商店查询中获取的所有者 ID
query shopDetails{
shop{
id
}
}
推荐阅读
- python - 如何在从智能手机接收蓝牙数据时使用键盘移动 Pygame 的多边形?
- c# - 适用于 Unity 的 Visual Studio 工具不可用
- google-apps-script - 不断收到谷歌脚本插件的应用错误
- r - How to create full path out of parent/child pairs
- r - ShinyApps 错误:未处理的异常子任务
- mybatis - 需要迭代来自java的列表并将多个值传递给iBatis sql查询的LIKE子句
- python - NaN 与 pyspark
- python - 如何加入 Pandas Dataframes 并多次保留左列?
- dart - 如何将 photo_reference 值存储为字符串?
- android - Drawable array from xml into int for recycler adapter