A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
I have a mutation query I am working on for to create or update a metadata field into an already existing product. Here is the structure of the query:
mutation {Product1: productUpdate( input: { id: "existing product id", metafields: {
id: "existing metafield id" namespace: "some namespace", key:"some key", value:"some value" } }) { product { id title metafields(first: 10) { edges { node { id key value namespace } } } } } }
The query works if the metadata id already exists, however it doesn't create a new metadata field if I remove the id key from the metadata portion of the query (the response returns no metadata fields). The productCreate mutation doesn't seem to accomplish what I want either.
If we aren't able to create new metadata fields in this way, how can go about doing that?
Solved! Go to the solution
This is an accepted solution.
I managed to resolve my own issue: turns out all I needed to do was include the valueType key in the metadata parameters and its working fine.
For some additional context, I have a request id done using my test store: 8628ca25-6209-4420-abde-75fb372b925b. I am using the api version 2020-01.
This is an accepted solution.
I managed to resolve my own issue: turns out all I needed to do was include the valueType key in the metadata parameters and its working fine.