Error Using `metaobjectUpsert` Mutation in Shopify Admin GraphQL API (2024-10)

Description

I’m trying to use the metaobjectUpsert mutation in my local GraphiQL instance (localhost:3000/graphiql) with the Shopify Admin GraphQL API version 2024-10, but I encountered the following errors:

  1. Unknown type error:

    Unknown type metaobjectUpsertInput! Did you mean "metaobjectHandleInput", "metaobjectConnection", or "metaobjectSEO"?
    
  2. Field query error:

    Cannot query field "metaobjectUpsert" on type "mutation".
    

Steps to Reproduce

  1. Copy the example mutation for metaobjectUpsert from Shopify’s documentation.
  2. Paste it into the GraphiQL editor at localhost:3000/graphiql.
  3. Run the mutation with the required input fields.

Expected Behavior

The mutation should successfully upsert a metaobject as described in the Shopify documentation.

Actual Behavior

The mutation fails with the errors mentioned above.

Please let me know if additional details are required. Any guidance on resolving this would be appreciated!

Hi - just to confirm, have you checked that all the input fields that you’re using valid? Are there any headerIds being returned when the mutation fails? Can you post the exact mutation (replacing any sensitive info with placeholders)?

1. Have you checked that all the input fields that you’re using valid?

I am assuming that it is valid, since I copy the mutation and input variables from the doc.

2. Are there any headerIds being returned when the mutation fails? and 3. Can you post the exact mutation (replacing any sensitive info with placeholders)?

Yes, please refer to the screenshot below.

I am new to Shopify Hydrogen, any guidance on resolving this would be appreciated :slight_smile:

If you run this in the GraphiQL app, do you see the same error?

When I run this in the GraphiQL app, I do not get the error.

Sorry, I accidentally marked your answer as a solution.

When I run the mutation in the GraphiQL app, it works. What should I do next to ensure my localhost:3000/graphiql runs the mutation without an error?

It looks like there’s something happening outside of the mutation, in the code of your app that would be causing this issue. You could try removing parts until it works as expected.

Could you clarify what you mean by ‘outside of the mutation’?

If the issue is in my app’s code, it shouldn’t affect localhost:3000/graphiql, since GraphiQL sends requests directly to the Storefront API—unless there’s something I’m missing?

Also, when you suggest ‘removing parts,’ could you specify which parts you mean? A bit more detail would be really helpful!