Which mutation to use when inserting data into variants metafield's

I’ve been reading the official documentation and it seems like I can use both metafieldsSet and productVariantUpdate mutation to insert data into variants metafields.

So which one is the appropriate one to use?

Another question is how do you guys work your way around these problems? When trying to do something in Shopify do you execute anything that seems relevant or do you keep researching until you reach a certain level of confidence that it’s the desired solution and it’s gonna work?

Thanks!

I’ve done it with metafieldsSet. May work to do it either way.

Usually the way I work around things like this is just by testing them out. I have a dev store that I generally use for testing but even with a live store many times you can test things like this without any impact to the store. For example just create a new metafield that isn’t used and then test the graphql call on it.

+1 for metafieldsSet.

As for OP’s second question, I also agree that testing is generally the best way to figure these things out.

The Shopify GraphQL API is well-documented for most of the common cases, but there are many edge cases where things like parameters, fields, or error messages aren’t documented, and the only way to be aware of them is trial-and-error, and reaching out to Shopify Partners Support when you’re stuck.