What's your biggest current challenge? Have your say in Community Polls along the right column.

Re: Unable to create admin filterable metafield definitions

Solved

Unable to create admin filterable metafield definitions

TomDavies
Shopify Partner
19 1 6

I'm attempting to use the new Admin filterable metafield capability as outlined here: https://shopify.dev/docs/apps/build/custom-data/metafields/use-metafield-capabilities#admin-filterab...

 

However, the API returns this error for all of my attempts:

 

The capability admin_filterable is not valid for this definition.

Here is an example mutation:

 

 

mutation metafieldDefinitionUpdate($definition: MetafieldDefinitionUpdateInput!) {
  metafieldDefinitionUpdate(definition: $definition) {
 userErrors {
   field
   message
 }
 updatedDefinition {
   key
   name
   namespace
   ownerType
   id
   useAsCollectionCondition
   capabilities {
     adminFilterable {
       enabled
         }
       }
     }
  }
}

 

 

 

And here are the variables"

 

 

{
  "definition": {
    "namespace": "custom",
    "key": "material",
    "name": "material",
    "ownerType": "PRODUCT",
    "capabilities": {
      "adminFilterable": {
        "enabled": true
      }
    }
  }
}

 

 

 

And this is the response:

 

 

{
  "data": {
    "metafieldDefinitionUpdate": {
      "userErrors": [
        {
          "field": [
            "definition"
          ],
          "message": "The capability admin_filterable is not valid for this definition."
        }
      ],
      "updatedDefinition": null
    }
  },

 

 

 

Also note the example in the linked dev doc has two typos that would not work on the 2024-10 API. "adminFilterStatus" is not supported in the response params, and "type" is not allowed in metafield definition updates.

️ Flair product badges https://apps.shopify.com/flair ️ Best Sellers - https://apps.shopify.com/best-sellers
Accepted Solution (1)

Jesse_McGinnis
Shopify Staff
6 1 0

This is an accepted solution.

What definition type do you have? The admin filterable capability is only supported by a few of the types right now.

 

As an aside: we'll get this list into the dev docs so it's easier to find (and fixup those errors in the example mutation).

To learn more visit the Shopify Help Center or the Community Blog.

View solution in original post

Replies 4 (4)

Jesse_McGinnis
Shopify Staff
6 1 0

This is an accepted solution.

What definition type do you have? The admin filterable capability is only supported by a few of the types right now.

 

As an aside: we'll get this list into the dev docs so it's easier to find (and fixup those errors in the example mutation).

To learn more visit the Shopify Help Center or the Community Blog.

TomDavies
Shopify Partner
19 1 6

Ah that must be it. I was using "number_integer". Any chance that is on the roadmap for the near future? My use case is to store product sales rank info. Might be a good idea to list the restriction about types on the https://shopify.dev/docs/api/admin-graphql/2024-10/mutations/metafieldDefinitionUpdate and https://shopify.dev/docs/apps/build/custom-data/metafields/use-metafield-capabilities#admin-filterab... docs too. Thanks!

️ Flair product badges https://apps.shopify.com/flair ️ Best Sellers - https://apps.shopify.com/best-sellers
Jesse_McGinnis
Shopify Staff
6 1 0

We'll expand the types supported — just timing and priorities 😁

 

We'll add the supported types to the capabilities page; feels like the natural home to me. 

To learn more visit the Shopify Help Center or the Community Blog.

TomDavies
Shopify Partner
19 1 6

Excellent, thanks Jesse! I can appreciate needing to time and prioritize things 🙂 I hope to see number_integer in the near future, ideally with support for less than and great than options in addition to the current checkbox "is equal" version.

 

Also, fyi the smartCollectionCondition works great, but one thing that seems off is the condition is not applied until you save and reload or come back into the collection. Perhaps that is already on your radar, but wanted to mention it in case you were not aware.

 

And lastly, one capability that'd be super powerful is the ability to use a metafield value for custom sorting, in case you don't have that on your list yet.

 

Thanks again!

- Tom

️ Flair product badges https://apps.shopify.com/flair ️ Best Sellers - https://apps.shopify.com/best-sellers