metaobjectByHandle - doesn't exist on type 'QueryRoot'

Topic summary

Main issue: The GraphQL query metaobjectByHandle returned “Field ‘metaobjectByHandle’ doesn’t exist on type ‘QueryRoot’.” This indicates the queried schema didn’t include that field.

Context: The poster referenced Shopify’s metaobjects and Admin GraphQL docs, used X-Shopify-Storefront-Access-Token, and targeted a 2024-01 endpoint. In GraphQL, QueryRoot is the top-level query type; an undefined field error usually points to a wrong API schema or endpoint.

Cause: Endpoint mismatch between Admin and Storefront APIs when using a Storefront token.

Resolution: Use the Storefront API endpoint https://.myshopify.com/api/2024-01/graphql.json instead of the Admin API endpoint https://.myshopify.com/admin/api/2024-01/graphql.json. After switching, the query worked.

Outcome: Resolved; no further actions requested or open questions.

Summarized with AI on January 3. AI used: gpt-5.

Hey there,

I’ m trying to use the graphQL query “metaobjectByHandle”. I read the documentation pages

https://shopify.dev/docs/apps/custom-data/metaobjects/manage-metaobjects and

https://shopify.dev/docs/api/admin-graphql/2024-01/queries/metaobjectByHandle but none of it solved the problem. The endpoint that I am using is https://.myshopify.com/api/2024-01/graphql.json and I already set the X-Shopify-Storefront-Access-Token correctly.

The following query is what I’m trying to get to work:

query {
  metaobjectByHandle(handle: {
    type: "

The error that I get is the following:

```javascript
{
  "errors": [
   {
      "message": "Field 'metaobjectByHandle' doesn't exist on type 'QueryRoot'",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "query",
        "metaobjectByHandle"
      ],
      "extensions": {
        "code": "undefinedField",
        "typeName": "QueryRoot",
        "fieldName": "metaobjectByHandle"
      }
    }
  ]
}

Can anyone help me with this issue? Any hint would me much appreciated!

Thanks!

I solved the problem. I used https://.myshopify.com/api/2024-01/graphql.json instead of https://.myshopify.com/admin/api/2024-01/graphql.json