Shopify create private metafield to store app settings

I’m building an app for Shopify using Shopify CLI, Node and React I built a settings page, at the moment the layout is this:

I’m building an app for Shopify using Shopify CLI, Node and React I built a settings page, at the moment the layout is this:

I’d like to save the value entered in API key field when I click on ‘Save settings’. I think I could use private metafields to achieve this goal: shopify metafields

I’m trying to add the field by means of graphQL and by using privateMetafieldUpsert as explained in the link

I’m stuck at this point

Hey

Did you ever figure out how to do this? I am trying to do something similar. Hope you have an answer?