Questions and discussions about using the Shopify CLI and Shopify-built libraries.
I'm attempting to retrieve metaobjects filtered by their display_name. Here is my GraphQL query:
query GetMetaobjects { metaobjects( first: 250 query: "display_name:\"*⑭公開日未設定作品(ONE SHOT CINEMA 近日公開作品)*\"" type: "custom" ) { nodes { id displayName } } }
const graphqlQuery = `#graphql
query GetMetaobjects($query: String, $first: Int = 200) {
metaobjects(
first: $first
type: "custom"
query: $query
) {
nodes {
__typename
id
display_name
}
}
}
`
const response = await admin.graphql(graphqlQuery, {
variables: {
query: `display_name:"*${name}*"`,
},
})
`display_name:"*${name}*"`
`display_name:\\"*${name}*\\"` `display_name:\"*${name}*\"`
but I still can't get the same result; it's all empty.
I believe the issue lies in the escape special character part, but what did I miss?
I have also encountered this issue.
I'm currently resolve it by using single quote and sting combine ( not template literal using back quote )
instead of
`display_name:"*${name}*"`
do
'display_name:' + '"' + '*${name}*' + '"'
and it working as expected , still don't know why 😅 hope it help