Conversations about creating, managing, and using metafields to store and retrieve custom data for apps and themes.
I am attempting to update the metafields on a collection using Shopify-api-node.
when I do so I get an error that says:
InputObject 'CollectionInput' doesn't accept argument 'metafields'
The correct way to do it is the way I am doing it as far as I know.
mutation{ collectionUpdate(input:{id:"<id>", metafields:[ {id:"<meta_id>" value:"2019-10-30 11:59pm"}]}){ collection{ id } } }
any ideas?
Solved! Go to the solution
This is an accepted solution.
HI @Ian_Brown ,
Thank you for DM'ing me your store information so that I can find the specific mutation you sent through our log files.
Your issue is that you were not specifying the version of the GraphQL Admin API you were sending the POST request to. In other words, you sent your POST request to the following endpoint of "admin/api/graphql.json" when you should have sent it to an endpoint with a specified API version like "admin/api/2019-10/graphql.json". When you do not specify the version, Shopify will default you to the oldest stable version (which as of today is "2019-04"). If you go through the Shopify documentation on the "CollectionInput" object with the "2019-04" version of the API, you will see this object does not accept 'metafields' as an input field. But if you use the latest stable version of our API ("2019-10") instead then this object will accept 'metafields' as an input.
To learn more visit the Shopify Help Center or the Community Blog.
Am I incorrect in the way I am trying to update metafields on a collection?
Hi @Ian_Brown ,
I have tested this on my own personal store, and it appears that the GraphQL mutation you have provided is functional and working correctly:
Perhaps there may be a formatting error or typo causing your error? E.g. perhaps if you're passing in a GraphQL variable as your input, you used `CollectionInput` as the input type instead of `CollectionInput!`
If you are still seeing this error, if you could provide the value of the X-Request-ID header in your response we would be able to analyze why your mutation may have failed through the Shopify logs
To learn more visit the Shopify Help Center or the Community Blog.
Im not sure how to get my Request-id
I can message you the store name and the app info if you want. but so far no matter how I do the code it doesn't like it
This is an accepted solution.
HI @Ian_Brown ,
Thank you for DM'ing me your store information so that I can find the specific mutation you sent through our log files.
Your issue is that you were not specifying the version of the GraphQL Admin API you were sending the POST request to. In other words, you sent your POST request to the following endpoint of "admin/api/graphql.json" when you should have sent it to an endpoint with a specified API version like "admin/api/2019-10/graphql.json". When you do not specify the version, Shopify will default you to the oldest stable version (which as of today is "2019-04"). If you go through the Shopify documentation on the "CollectionInput" object with the "2019-04" version of the API, you will see this object does not accept 'metafields' as an input field. But if you use the latest stable version of our API ("2019-10") instead then this object will accept 'metafields' as an input.
To learn more visit the Shopify Help Center or the Community Blog.