# Inconsistency on metafield fields returned by queries

**URL:** <https://community.shopify.dev/t/inconsistency-on-metafield-fields-returned-by-queries/39051>\
**Category:** GraphQL Admin API Troubleshooting\
**Tags:** general-gql-troubles\
**Created:** [October 26, 2026, 3:46pm UTC](https://community.shopify.dev/t/inconsistency-on-metafield-fields-returned-by-queries/39051 "2026-10-26T15:46:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![AMillasseau](https://avatars.discourse-cdn.com/v4/letter/a/d07c76/32.png) [@AMillasseau](https://community.shopify.dev/u/AMillasseau)\
**Post date:** [October 26, 2026, 3:46pm UTC](https://community.shopify.dev/t/inconsistency-on-metafield-fields-returned-by-queries/39051/1 "2026-10-26T15:46:23Z")

</div>

Hello,  
On my queries requests on metafields, I notice a strange behavior (tested in 2026-04 and unstable).  
Query 1:

```auto
query getShopMetafield {
  shop {
    metafields(first: 1) {
      nodes {
        namespace
        value
        key
      }
    }
  }
}

```

Data 1:

```auto
{
  "shop": {
    "metafields": {
      "nodes": [
        {
          "namespace": "custom",
          "value": "value",
          "key": "my_metafield"
        }
      ]
    }
  }
}

```

Query 2:

```auto
query getFilteredShopMetafield {
  shop {
    metafields(first: 1, keys: ["custom.my_metafield"]) {
      nodes {
        namespace
        value
        key
      }
    }
  }
}

```

Data 2:

```auto
{
  "shop": {
    "metafields": {
      "nodes": [
        {
          "namespace": "custom",
          "value": "value",
          "key": "custom.my_metafield"
        }
      ]
    }
  }
}

```

The key is prefixed by the namespace in its field only on second query. I didn’t find any documentation about this. Can it be considered an inconsistency or is there a special meaning to this behavior?

Thank you in advance

---

<div class="post-metadata">

**Author:** ![Wes-Dev-Shopify](https://avatars.discourse-cdn.com/v4/letter/w/e68b1a/32.png) [@Wes-Dev-Shopify](https://community.shopify.dev/u/Wes-Dev-Shopify)\
**Post date:** [October 26, 2026, 10:33pm UTC](https://community.shopify.dev/t/inconsistency-on-metafield-fields-returned-by-queries/39051/2 "2026-10-26T22:33:28Z")

</div>

Hey @AMillasseau - thanks for flagging this.

I reproduced it and can confirm that filtering with `keys: ["custom.my_metafield"]` returns `custom.my_metafield` in the `key` field, while the unfiltered query returns `my_metafield`.

The docs partly call this out. The [`keys` argument on `Shop.metafields`](https://shopify.dev/docs/api/admin-graphql/2026-10/objects/Shop) says keys in the `namespace.key` format “will be returned in the same format,” but the [`Metafield.key` field](https://shopify.dev/docs/api/admin-graphql/2026-10/objects/Metafield) only describes `key` as “The unique identifier for the metafield within its namespace” and doesn’t mention that it can include the namespace.

I’m checking whether this is expected, and if it is, I’ll look into clarifying the docs. I’ll update this thread when I know more.

---

<div class="post-metadata">

**Author:** ![Wes-Dev-Shopify](https://avatars.discourse-cdn.com/v4/letter/w/e68b1a/32.png) [@Wes-Dev-Shopify](https://community.shopify.dev/u/Wes-Dev-Shopify)\
**Post date:** [November 13, 2026, 6:18pm UTC](https://community.shopify.dev/t/inconsistency-on-metafield-fields-returned-by-queries/39051/3 "2026-11-13T18:18:26Z")

</div>

Hey @AMillasseau - following up on this one. I did some digging, and it looks like the behaviour you found is expected: when you request a metafield using the combined `namespace.key` format, its `key` field comes back in that same format. Requesting `custom.my_metafield` through `keys` returns `custom.my_metafield`, and requesting just `my_metafield` returns `my_metafield`.

We’ve updated the reference docs to make this clearer:

- [`Metafield.key`](https://shopify.dev/docs/api/admin-graphql/latest/objects/Metafield) now notes that it returns the combined `namespace.key` value when the metafield was requested that way, such as through the `keys` argument.
- The `keys` argument on `metafields` (for example on [`Shop`](https://shopify.dev/docs/api/admin-graphql/latest/objects/Shop)) now explains that each returned `key` matches the format of its entry in the list.

If you want a consistent value no matter how you query, you can build it from the `namespace` and `key` fields, since `namespace` is returned either way.

---

<div class="post-metadata">

**Author:** ![AMillasseau](https://avatars.discourse-cdn.com/v4/letter/a/d07c76/32.png) [@AMillasseau](https://community.shopify.dev/u/AMillasseau)\
**Post date:** [November 16, 2026, 8:26am UTC](https://community.shopify.dev/t/inconsistency-on-metafield-fields-returned-by-queries/39051/4 "2026-11-16T08:26:26Z")

</div>

Ok, Thank you for the clarification!
