Hi @Alan_G thank you for your replay,
These are my mutations.
mutation CreateAppDataMetafield($metafieldsSetInput: [MetafieldsSetInput!]!) {
metafieldsSet(metafields: $metafieldsSetInput) {
metafields {
id
namespace
key
}
userErrors {
field
message
}
}
}
{
"metafieldsSetInput": [
{
"namespace": "secret_keys",
"key": "api_key",
"type": "list.metaobject_reference",
"value": "[\"gid://shopify/Metaobject/158811193691\"]",
"ownerId": "gid://shopify/AppInstallation/861391487323"
}
]
}
From this mutation I get this response
{
"data": {
"metafieldsSet": {
"metafields": [],
"userErrors": [
{
"field": [
"metafields",
"0",
"value"
],
"message": "Value requires that you have a metafield definition with the key: api_key."
}
]
}
},
"extensions": {
"cost": {
"requestedQueryCost": 10,
"actualQueryCost": 10,
"throttleStatus": {
"maximumAvailable": 2000,
"currentlyAvailable": 1990,
"restoreRate": 100
}
}
}
}
After because I saw the Value requires that you have a metafield definition with the key: api_key.
error. I decided to create the metafield definition. Using this query.
mutation {
metafieldDefinitionCreate(definition: {
name: "Test"
namespace: "secret_keys"
key: "api_key"
type: "list.metaobject_reference"
ownerType: SHOP
validations: {
name: "metaobject_definition_id"
value: "gid://shopify/MetaobjectDefinition/21219836251"
}
}) {
createdDefinition {
id
name
namespace
key
}
userErrors {
field
message
code
}
}
}
From this mutation I got the answer
{
"data": {
"metafieldDefinitionCreate": {
"createdDefinition": {
"id": "gid://shopify/MetafieldDefinition/270440890715",
"name": "Test",
"namespace": "secret_keys",
"key": "api_key"
},
"userErrors": []
}
},
"extensions": {
"cost": {
"requestedQueryCost": 10,
"actualQueryCost": 10,
"throttleStatus": {
"maximumAvailable": 2000,
"currentlyAvailable": 1990,
"restoreRate": 100
}
}
}
}
Also here I create the metaobject with this query.
mutation {
metaobjectCreate(
metaobject: {
type: "your_test_app_dataaadddsss"
fields: [
{
key: "value"
value: "111111111111"
}
]
}
) {
metaobject {
id
definition {
id
}
}
userErrors {
field
message
}
}
}
{
"data": {
"metaobjectCreate": {
"metaobject": {
"id": "gid://shopify/Metaobject/158811193691",
"definition": {
"id": "gid://shopify/MetaobjectDefinition/21219836251"
}
},
"userErrors": []
}
},
"extensions": {
"cost": {
"requestedQueryCost": 11,
"actualQueryCost": 11,
"throttleStatus": {
"maximumAvailable": 2000,
"currentlyAvailable": 1989,
"restoreRate": 100
}
}
}
}
After I run the app-data mutation query I shared initially. It still gives me the same error. As I started using the API recently I am not sure if I am making basic mistake. Thank you for your help.