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?
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
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
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.
1 Like