[GraphQL MetafieldDefinition] How to get whether a metafield allows multiple values ​​or not by API

We can choose single/multiple values values in a single metafield when add a metafield definition.

I’d like to get whether the metafield allows multiple values ​​or not by GraphQL MetafieldDefinition API.

I tried query like this

query {
metafieldDefinitions(first: 10, ownerType: ORDER) {
edges {
node {
id
key
namespace
name
metafieldsCount
type {
category
}
}
}
}
}

and the response was

"node": {
"id": "gid://shopify/MetafieldDefinition/786366676",
"key": "_int_array",
"namespace": "custom",
"name": "整数のリスト",
"metafieldsCount": 1,
"type": {
"category": "NUMBER"
}
}
},

How can I get any information of it’s single or multiplue?

Hello @ttpp :waving_hand:

Your best bet is to query the name of the type and check that it starts with “list.”

query Definition {
  metafieldDefinitions(first: 10, ownerType: ORDER) {
    edges {
      node {
        type {
          name
        }
      }
    }
  }
}

This prefix is consistently used for all types that support a list of values.

This problem was resolved thanks to your support!

1 Like