metaobject Definition Updatemutation
mutation
2024-10latest
Requires write
access scope.
Updates a metaobject definition with new settings and metafield definitions.
Arguments
The input fields for updating a metaobject definition.
The ID of the metaobject definition to update.
Was this section helpful?
MetaobjectDefinitionUpdatePayload returns
The updated metaobject definition.
The list of errors that occurred from executing the mutation.
Was this section helpful?
Code examples for MUTATION: metaobjectDefinitionUpdate
Query Reference for MUTATION: metaobjectDefinitionUpdate
"mutation metaobjectDefinitionUpdate($definition: MetaobjectDefinitionUpdateInput!, $id: ID!) {\n metaobjectDefinitionUpdate(definition: $definition, id: $id) {\n metaobjectDefinition {\n # MetaobjectDefinition fields\n }\n userErrors {\n field\n message\n }\n }\n}"
Input Reference for MUTATION: metaobjectDefinitionUpdate
"{\n \"definition\": {\n \"access\": {\n \"admin\": \"MERCHANT_READ\",\n \"storefront\": \"NONE\"\n },\n \"capabilities\": {\n \"onlineStore\": {\n \"data\": {\n \"createRedirects\": true,\n \"urlHandle\": \"<your-urlHandle>\"\n },\n \"enabled\": true\n },\n \"publishable\": {\n \"enabled\": true\n },\n \"renderable\": {\n \"data\": {\n \"metaDescriptionKey\": \"<your-metaDescriptionKey>\",\n \"metaTitleKey\": \"<your-metaTitleKey>\"\n },\n \"enabled\": true\n },\n \"translatable\": {\n \"enabled\": true\n }\n },\n \"description\": \"<your-description>\",\n \"displayNameKey\": \"<your-displayNameKey>\",\n \"fieldDefinitions\": [\n {\n \"create\": {\n \"description\": \"<your-description>\",\n \"key\": \"<your-key>\",\n \"name\": \"<your-name>\",\n \"required\": true,\n \"type\": \"<your-type>\",\n \"validations\": [\n {\n \"name\": \"<your-name>\",\n \"value\": \"<your-value>\"\n }\n ]\n },\n \"delete\": {\n \"key\": \"<your-key>\"\n },\n \"update\": {\n \"description\": \"<your-description>\",\n \"key\": \"<your-key>\",\n \"name\": \"<your-name>\",\n \"required\": true,\n \"validations\": [\n {\n \"name\": \"<your-name>\",\n \"value\": \"<your-value>\"\n }\n ]\n }\n }\n ],\n \"name\": \"<your-name>\",\n \"resetFieldOrder\": true\n },\n \"id\": \"gid://shopify/<objectName>/10079785100\"\n}"
Schema Reference for MUTATION: metaobjectDefinitionUpdate
"input MetaobjectDefinitionUpdateInput {\n access: MetaobjectAccessInput\n capabilities: MetaobjectCapabilityUpdateInput\n description: String\n displayNameKey: String\n fieldDefinitions: [MetaobjectFieldDefinitionOperationInput!]\n name: String\n resetFieldOrder: Boolean\n}\n\ninput MetaobjectAccessInput {\n admin: MetaobjectAdminAccess\n storefront: MetaobjectStorefrontAccess\n}\n\ninput MetaobjectCapabilityUpdateInput {\n onlineStore: MetaobjectCapabilityOnlineStoreInput\n publishable: MetaobjectCapabilityPublishableInput\n renderable: MetaobjectCapabilityRenderableInput\n translatable: MetaobjectCapabilityTranslatableInput\n}\n\ninput MetaobjectFieldDefinitionOperationInput {\n create: MetaobjectFieldDefinitionCreateInput\n delete: MetaobjectFieldDefinitionDeleteInput\n update: MetaobjectFieldDefinitionUpdateInput\n}\n"
Display Examples for MUTATION: metaobjectDefinitionUpdate
[ { "example": { "type_name": "metaobjectdefinitionupdate", "title": "Create additional field definitions on an existing metaobject definition", "description": "To add a field definition to an existing metaobject definition, use the `metaobjectDefinitionUpdate`\nmutation with the `create` `MetaobjectFieldDefinitionOperationInput`.\nThe following example shows adding a new field definition named \"Description\" to the\n\"LookBook\" metaobject definition.\n", "query_string": "mutation UpdateMetaobjectDefinition($id: ID!, $definition: MetaobjectDefinitionUpdateInput!) {\n metaobjectDefinitionUpdate(id: $id, definition: $definition) {\n metaobjectDefinition {\n id\n name\n displayNameKey\n fieldDefinitions {\n name\n key\n type {\n name\n }\n }\n }\n userErrors {\n field\n message\n code\n }\n }\n}", "variables": { "id": "gid://shopify/MetaobjectDefinition/578408816", "definition": { "displayNameKey": "description", "fieldDefinitions": [ { "create": { "key": "description", "name": "Description", "type": "single_line_text_field" } } ] } }, "response": { "data": { "metaobjectDefinitionUpdate": { "metaobjectDefinition": { "id": "gid://shopify/MetaobjectDefinition/578408816", "name": "LookBook", "displayNameKey": "description", "fieldDefinitions": [ { "name": "Another Lookbook", "key": "another_lookbook", "type": { "name": "metaobject_reference" } }, { "name": "Season", "key": "cover_image", "type": { "name": "file_reference" } }, { "name": "Season", "key": "season", "type": { "name": "single_line_text_field" } }, { "name": "Year", "key": "year", "type": { "name": "number_integer" } }, { "name": "Description", "key": "description", "type": { "name": "single_line_text_field" } } ] }, "userErrors": [] } } }, "api_name": "admin", "minimum_api_version": "2023-10", "maximum_api_version": "unstable", "location": "/components/content/metaobjects/test/unit/graph_api/admin/mutations/metaobject_definition_update_test.rb", "curl_example": "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation UpdateMetaobjectDefinition($id: ID!, $definition: MetaobjectDefinitionUpdateInput!) { metaobjectDefinitionUpdate(id: $id, definition: $definition) { metaobjectDefinition { id name displayNameKey fieldDefinitions { name key type { name } } } userErrors { field message code } } }\",\n \"variables\": {\n \"id\": \"gid://shopify/MetaobjectDefinition/578408816\",\n \"definition\": {\n \"displayNameKey\": \"description\",\n \"fieldDefinitions\": [\n {\n \"create\": {\n \"key\": \"description\",\n \"name\": \"Description\",\n \"type\": \"single_line_text_field\"\n }\n }\n ]\n }\n }\n}'\n", "remix_example": "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation UpdateMetaobjectDefinition($id: ID!, $definition: MetaobjectDefinitionUpdateInput!) {\n metaobjectDefinitionUpdate(id: $id, definition: $definition) {\n metaobjectDefinition {\n id\n name\n displayNameKey\n fieldDefinitions {\n name\n key\n type {\n name\n }\n }\n }\n userErrors {\n field\n message\n code\n }\n }\n }`,\n {\n variables: {\n \"id\": \"gid://shopify/MetaobjectDefinition/578408816\",\n \"definition\": {\n \"displayNameKey\": \"description\",\n \"fieldDefinitions\": [\n {\n \"create\": {\n \"key\": \"description\",\n \"name\": \"Description\",\n \"type\": \"single_line_text_field\"\n }\n }\n ]\n }\n },\n },\n);\n\nconst data = await response.json();\n", "ruby_example": "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n mutation UpdateMetaobjectDefinition($id: ID!, $definition: MetaobjectDefinitionUpdateInput!) {\n metaobjectDefinitionUpdate(id: $id, definition: $definition) {\n metaobjectDefinition {\n id\n name\n displayNameKey\n fieldDefinitions {\n name\n key\n type {\n name\n }\n }\n }\n userErrors {\n field\n message\n code\n }\n }\n }\nQUERY\n\nvariables = {\n \"id\": \"gid://shopify/MetaobjectDefinition/578408816\",\n \"definition\": {\n \"displayNameKey\": \"description\",\n \"fieldDefinitions\": [{\"create\"=>{\"key\"=>\"description\", \"name\"=>\"Description\", \"type\"=>\"single_line_text_field\"}}]\n }\n}\n\nresponse = client.query(query: query, variables: variables)\n", "node_example": "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation UpdateMetaobjectDefinition($id: ID!, $definition: MetaobjectDefinitionUpdateInput!) {\n metaobjectDefinitionUpdate(id: $id, definition: $definition) {\n metaobjectDefinition {\n id\n name\n displayNameKey\n fieldDefinitions {\n name\n key\n type {\n name\n }\n }\n }\n userErrors {\n field\n message\n code\n }\n }\n }`,\n \"variables\": {\n \"id\": \"gid://shopify/MetaobjectDefinition/578408816\",\n \"definition\": {\n \"displayNameKey\": \"description\",\n \"fieldDefinitions\": [\n {\n \"create\": {\n \"key\": \"description\",\n \"name\": \"Description\",\n \"type\": \"single_line_text_field\"\n }\n }\n ]\n }\n },\n },\n});\n", "php_example": "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n mutation UpdateMetaobjectDefinition($id: ID!, $definition: MetaobjectDefinitionUpdateInput!) {\n metaobjectDefinitionUpdate(id: $id, definition: $definition) {\n metaobjectDefinition {\n id\n name\n displayNameKey\n fieldDefinitions {\n name\n key\n type {\n name\n }\n }\n }\n userErrors {\n field\n message\n code\n }\n }\n }\nQUERY;\n\n$variables = [\n \"id\" => \"gid://shopify/MetaobjectDefinition/578408816\",\n \"definition\" => [\n \"displayNameKey\" => \"description\",\n \"fieldDefinitions\" => [{\"create\"=>{\"key\"=>\"description\", \"name\"=>\"Description\", \"type\"=>\"single_line_text_field\"}}],\n ],\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" }, "titleStringKey": "variables", "inputVariableEntries": [ { "arg": { "name": "id", "description": "The ID of the metaobject definition to update.", "type": { "kind": "SCALAR", "name": "ID", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "ID!", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "id", "argValue": " \"gid://shopify/MetaobjectDefinition/578408816\"", "typeKind": "MUTATION" }, { "arg": { "name": "definition", "description": "The input fields for updating a metaobject definition.", "type": { "kind": "INPUT_OBJECT", "name": "MetaobjectDefinitionUpdateInput", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "MetaobjectDefinitionUpdateInput!", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "definition", "argValue": " {\"displayNameKey\":\"description\",\"fieldDefinitions\":[{\"create\":{\"key\":\"description\",\"name\":\"Description\",\"type\":\"single_line_text_field\"}}]}", "typeKind": "MUTATION" } ] }, { "example": { "type_name": "metaobjectdefinitionupdate", "title": "Delete a field definition from a metaobject definition", "description": "To delete a field definition from an existing metaobject definnition,\nuse the `metaobjectDefinitionUpdate` mutation with the `delete`\n`MetaobjectFieldDefinitionOperationInput`.\n\nThe following example shows deleting the \"Season\" field definition on \"Lookbook\".\n", "query_string": "mutation UpdateMetaobjectDefinition($id: ID!, $definition: MetaobjectDefinitionUpdateInput!) {\n metaobjectDefinitionUpdate(id: $id, definition: $definition) {\n metaobjectDefinition {\n id\n name\n fieldDefinitions {\n name\n key\n }\n }\n userErrors {\n field\n message\n code\n }\n }\n}", "variables": { "id": "gid://shopify/MetaobjectDefinition/578408816", "definition": { "fieldDefinitions": [ { "delete": { "key": "season" } } ] } }, "response": { "data": { "metaobjectDefinitionUpdate": { "metaobjectDefinition": { "id": "gid://shopify/MetaobjectDefinition/578408816", "name": "LookBook", "fieldDefinitions": [ { "name": "Another Lookbook", "key": "another_lookbook" }, { "name": "Season", "key": "cover_image" }, { "name": "Year", "key": "year" } ] }, "userErrors": [] } } }, "api_name": "admin", "minimum_api_version": "2023-10", "maximum_api_version": "unstable", "location": "/components/content/metaobjects/test/unit/graph_api/admin/mutations/metaobject_definition_update_test.rb", "curl_example": "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation UpdateMetaobjectDefinition($id: ID!, $definition: MetaobjectDefinitionUpdateInput!) { metaobjectDefinitionUpdate(id: $id, definition: $definition) { metaobjectDefinition { id name fieldDefinitions { name key } } userErrors { field message code } } }\",\n \"variables\": {\n \"id\": \"gid://shopify/MetaobjectDefinition/578408816\",\n \"definition\": {\n \"fieldDefinitions\": [\n {\n \"delete\": {\n \"key\": \"season\"\n }\n }\n ]\n }\n }\n}'\n", "remix_example": "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation UpdateMetaobjectDefinition($id: ID!, $definition: MetaobjectDefinitionUpdateInput!) {\n metaobjectDefinitionUpdate(id: $id, definition: $definition) {\n metaobjectDefinition {\n id\n name\n fieldDefinitions {\n name\n key\n }\n }\n userErrors {\n field\n message\n code\n }\n }\n }`,\n {\n variables: {\n \"id\": \"gid://shopify/MetaobjectDefinition/578408816\",\n \"definition\": {\n \"fieldDefinitions\": [\n {\n \"delete\": {\n \"key\": \"season\"\n }\n }\n ]\n }\n },\n },\n);\n\nconst data = await response.json();\n", "ruby_example": "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n mutation UpdateMetaobjectDefinition($id: ID!, $definition: MetaobjectDefinitionUpdateInput!) {\n metaobjectDefinitionUpdate(id: $id, definition: $definition) {\n metaobjectDefinition {\n id\n name\n fieldDefinitions {\n name\n key\n }\n }\n userErrors {\n field\n message\n code\n }\n }\n }\nQUERY\n\nvariables = {\n \"id\": \"gid://shopify/MetaobjectDefinition/578408816\",\n \"definition\": {\n \"fieldDefinitions\": [{\"delete\"=>{\"key\"=>\"season\"}}]\n }\n}\n\nresponse = client.query(query: query, variables: variables)\n", "node_example": "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation UpdateMetaobjectDefinition($id: ID!, $definition: MetaobjectDefinitionUpdateInput!) {\n metaobjectDefinitionUpdate(id: $id, definition: $definition) {\n metaobjectDefinition {\n id\n name\n fieldDefinitions {\n name\n key\n }\n }\n userErrors {\n field\n message\n code\n }\n }\n }`,\n \"variables\": {\n \"id\": \"gid://shopify/MetaobjectDefinition/578408816\",\n \"definition\": {\n \"fieldDefinitions\": [\n {\n \"delete\": {\n \"key\": \"season\"\n }\n }\n ]\n }\n },\n },\n});\n", "php_example": "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n mutation UpdateMetaobjectDefinition($id: ID!, $definition: MetaobjectDefinitionUpdateInput!) {\n metaobjectDefinitionUpdate(id: $id, definition: $definition) {\n metaobjectDefinition {\n id\n name\n fieldDefinitions {\n name\n key\n }\n }\n userErrors {\n field\n message\n code\n }\n }\n }\nQUERY;\n\n$variables = [\n \"id\" => \"gid://shopify/MetaobjectDefinition/578408816\",\n \"definition\" => [\n \"fieldDefinitions\" => [{\"delete\"=>{\"key\"=>\"season\"}}],\n ],\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" }, "titleStringKey": "variables", "inputVariableEntries": [ { "arg": { "name": "id", "description": "The ID of the metaobject definition to update.", "type": { "kind": "SCALAR", "name": "ID", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "ID!", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "id", "argValue": " \"gid://shopify/MetaobjectDefinition/578408816\"", "typeKind": "MUTATION" }, { "arg": { "name": "definition", "description": "The input fields for updating a metaobject definition.", "type": { "kind": "INPUT_OBJECT", "name": "MetaobjectDefinitionUpdateInput", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "MetaobjectDefinitionUpdateInput!", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "definition", "argValue": " {\"fieldDefinitions\":[{\"delete\":{\"key\":\"season\"}}]}", "typeKind": "MUTATION" } ] }, { "example": { "type_name": "metaobjectdefinitionupdate", "title": "Update an existing field definition on a metaobject definition", "description": "To update a field definition on an existing metaobject, use the `metaobjectDefinitionUpdate`\nmutation with the `update` `MetaobjectFieldDefinitionOperationInput`.\nThe following example shows updating the name of the \"Season\" field definition on the \"Lookbook\"\nmetaobject definition to be \"Edition\".\n", "query_string": "mutation UpdateMetaobjectDefinition($id: ID!, $definition: MetaobjectDefinitionUpdateInput!) {\n metaobjectDefinitionUpdate(id: $id, definition: $definition) {\n metaobjectDefinition {\n name\n fieldDefinitions {\n name\n key\n }\n }\n userErrors {\n field\n message\n code\n }\n }\n}", "variables": { "id": "gid://shopify/MetaobjectDefinition/578408816", "definition": { "fieldDefinitions": [ { "update": { "key": "season", "name": "Edition" } } ] } }, "response": { "data": { "metaobjectDefinitionUpdate": { "metaobjectDefinition": { "name": "LookBook", "fieldDefinitions": [ { "name": "Another Lookbook", "key": "another_lookbook" }, { "name": "Season", "key": "cover_image" }, { "name": "Edition", "key": "season" }, { "name": "Year", "key": "year" } ] }, "userErrors": [] } } }, "api_name": "admin", "minimum_api_version": "2023-10", "maximum_api_version": "unstable", "location": "/components/content/metaobjects/test/unit/graph_api/admin/mutations/metaobject_definition_update_test.rb", "curl_example": "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation UpdateMetaobjectDefinition($id: ID!, $definition: MetaobjectDefinitionUpdateInput!) { metaobjectDefinitionUpdate(id: $id, definition: $definition) { metaobjectDefinition { name fieldDefinitions { name key } } userErrors { field message code } } }\",\n \"variables\": {\n \"id\": \"gid://shopify/MetaobjectDefinition/578408816\",\n \"definition\": {\n \"fieldDefinitions\": [\n {\n \"update\": {\n \"key\": \"season\",\n \"name\": \"Edition\"\n }\n }\n ]\n }\n }\n}'\n", "remix_example": "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation UpdateMetaobjectDefinition($id: ID!, $definition: MetaobjectDefinitionUpdateInput!) {\n metaobjectDefinitionUpdate(id: $id, definition: $definition) {\n metaobjectDefinition {\n name\n fieldDefinitions {\n name\n key\n }\n }\n userErrors {\n field\n message\n code\n }\n }\n }`,\n {\n variables: {\n \"id\": \"gid://shopify/MetaobjectDefinition/578408816\",\n \"definition\": {\n \"fieldDefinitions\": [\n {\n \"update\": {\n \"key\": \"season\",\n \"name\": \"Edition\"\n }\n }\n ]\n }\n },\n },\n);\n\nconst data = await response.json();\n", "ruby_example": "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n mutation UpdateMetaobjectDefinition($id: ID!, $definition: MetaobjectDefinitionUpdateInput!) {\n metaobjectDefinitionUpdate(id: $id, definition: $definition) {\n metaobjectDefinition {\n name\n fieldDefinitions {\n name\n key\n }\n }\n userErrors {\n field\n message\n code\n }\n }\n }\nQUERY\n\nvariables = {\n \"id\": \"gid://shopify/MetaobjectDefinition/578408816\",\n \"definition\": {\n \"fieldDefinitions\": [{\"update\"=>{\"key\"=>\"season\", \"name\"=>\"Edition\"}}]\n }\n}\n\nresponse = client.query(query: query, variables: variables)\n", "node_example": "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation UpdateMetaobjectDefinition($id: ID!, $definition: MetaobjectDefinitionUpdateInput!) {\n metaobjectDefinitionUpdate(id: $id, definition: $definition) {\n metaobjectDefinition {\n name\n fieldDefinitions {\n name\n key\n }\n }\n userErrors {\n field\n message\n code\n }\n }\n }`,\n \"variables\": {\n \"id\": \"gid://shopify/MetaobjectDefinition/578408816\",\n \"definition\": {\n \"fieldDefinitions\": [\n {\n \"update\": {\n \"key\": \"season\",\n \"name\": \"Edition\"\n }\n }\n ]\n }\n },\n },\n});\n", "php_example": "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n mutation UpdateMetaobjectDefinition($id: ID!, $definition: MetaobjectDefinitionUpdateInput!) {\n metaobjectDefinitionUpdate(id: $id, definition: $definition) {\n metaobjectDefinition {\n name\n fieldDefinitions {\n name\n key\n }\n }\n userErrors {\n field\n message\n code\n }\n }\n }\nQUERY;\n\n$variables = [\n \"id\" => \"gid://shopify/MetaobjectDefinition/578408816\",\n \"definition\" => [\n \"fieldDefinitions\" => [{\"update\"=>{\"key\"=>\"season\", \"name\"=>\"Edition\"}}],\n ],\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" }, "titleStringKey": "variables", "inputVariableEntries": [ { "arg": { "name": "id", "description": "The ID of the metaobject definition to update.", "type": { "kind": "SCALAR", "name": "ID", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "ID!", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "id", "argValue": " \"gid://shopify/MetaobjectDefinition/578408816\"", "typeKind": "MUTATION" }, { "arg": { "name": "definition", "description": "The input fields for updating a metaobject definition.", "type": { "kind": "INPUT_OBJECT", "name": "MetaobjectDefinitionUpdateInput", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "MetaobjectDefinitionUpdateInput!", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "definition", "argValue": " {\"fieldDefinitions\":[{\"update\":{\"key\":\"season\",\"name\":\"Edition\"}}]}", "typeKind": "MUTATION" } ] }, { "example": { "type_name": "metaobjectdefinitionupdate", "title": "Update base attributes of a metaobject definition", "description": "To update a metaobject definition, use the `metaobjectDefinitionUpdate` mutation.\nThe following example shows updating the name of the metaobject definition \"Lookbook\" to\n\"Stylebook\" and changing the display name key to \"season\".\n", "query_string": "mutation UpdateMetaobjectDefinition($id: ID!, $definition: MetaobjectDefinitionUpdateInput!) {\n metaobjectDefinitionUpdate(id: $id, definition: $definition) {\n metaobjectDefinition {\n id\n name\n displayNameKey\n }\n userErrors {\n field\n message\n code\n }\n }\n}", "variables": { "id": "gid://shopify/MetaobjectDefinition/578408816", "definition": { "name": "StyleBook", "displayNameKey": "season" } }, "response": { "data": { "metaobjectDefinitionUpdate": { "metaobjectDefinition": { "id": "gid://shopify/MetaobjectDefinition/578408816", "name": "StyleBook", "displayNameKey": "season" }, "userErrors": [] } } }, "api_name": "admin", "minimum_api_version": "2023-10", "maximum_api_version": "unstable", "location": "/components/content/metaobjects/test/unit/graph_api/admin/mutations/metaobject_definition_update_test.rb", "curl_example": "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation UpdateMetaobjectDefinition($id: ID!, $definition: MetaobjectDefinitionUpdateInput!) { metaobjectDefinitionUpdate(id: $id, definition: $definition) { metaobjectDefinition { id name displayNameKey } userErrors { field message code } } }\",\n \"variables\": {\n \"id\": \"gid://shopify/MetaobjectDefinition/578408816\",\n \"definition\": {\n \"name\": \"StyleBook\",\n \"displayNameKey\": \"season\"\n }\n }\n}'\n", "remix_example": "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation UpdateMetaobjectDefinition($id: ID!, $definition: MetaobjectDefinitionUpdateInput!) {\n metaobjectDefinitionUpdate(id: $id, definition: $definition) {\n metaobjectDefinition {\n id\n name\n displayNameKey\n }\n userErrors {\n field\n message\n code\n }\n }\n }`,\n {\n variables: {\n \"id\": \"gid://shopify/MetaobjectDefinition/578408816\",\n \"definition\": {\n \"name\": \"StyleBook\",\n \"displayNameKey\": \"season\"\n }\n },\n },\n);\n\nconst data = await response.json();\n", "ruby_example": "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n mutation UpdateMetaobjectDefinition($id: ID!, $definition: MetaobjectDefinitionUpdateInput!) {\n metaobjectDefinitionUpdate(id: $id, definition: $definition) {\n metaobjectDefinition {\n id\n name\n displayNameKey\n }\n userErrors {\n field\n message\n code\n }\n }\n }\nQUERY\n\nvariables = {\n \"id\": \"gid://shopify/MetaobjectDefinition/578408816\",\n \"definition\": {\n \"name\": \"StyleBook\",\n \"displayNameKey\": \"season\"\n }\n}\n\nresponse = client.query(query: query, variables: variables)\n", "node_example": "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation UpdateMetaobjectDefinition($id: ID!, $definition: MetaobjectDefinitionUpdateInput!) {\n metaobjectDefinitionUpdate(id: $id, definition: $definition) {\n metaobjectDefinition {\n id\n name\n displayNameKey\n }\n userErrors {\n field\n message\n code\n }\n }\n }`,\n \"variables\": {\n \"id\": \"gid://shopify/MetaobjectDefinition/578408816\",\n \"definition\": {\n \"name\": \"StyleBook\",\n \"displayNameKey\": \"season\"\n }\n },\n },\n});\n", "php_example": "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n mutation UpdateMetaobjectDefinition($id: ID!, $definition: MetaobjectDefinitionUpdateInput!) {\n metaobjectDefinitionUpdate(id: $id, definition: $definition) {\n metaobjectDefinition {\n id\n name\n displayNameKey\n }\n userErrors {\n field\n message\n code\n }\n }\n }\nQUERY;\n\n$variables = [\n \"id\" => \"gid://shopify/MetaobjectDefinition/578408816\",\n \"definition\" => [\n \"name\" => \"StyleBook\",\n \"displayNameKey\" => \"season\",\n ],\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" }, "titleStringKey": "variables", "inputVariableEntries": [ { "arg": { "name": "id", "description": "The ID of the metaobject definition to update.", "type": { "kind": "SCALAR", "name": "ID", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "ID!", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "id", "argValue": " \"gid://shopify/MetaobjectDefinition/578408816\"", "typeKind": "MUTATION" }, { "arg": { "name": "definition", "description": "The input fields for updating a metaobject definition.", "type": { "kind": "INPUT_OBJECT", "name": "MetaobjectDefinitionUpdateInput", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "MetaobjectDefinitionUpdateInput!", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "definition", "argValue": " {\"name\":\"StyleBook\",\"displayNameKey\":\"season\"}", "typeKind": "MUTATION" } ] }, { "example": { "type_name": "metaobjectdefinitionupdate", "title": "Update ordering of fields on an existing metaobject definition", "description": "To update the ordering of fields on an existing metaobject definition,\nuse the `metaobjectDefinitionUpdate` mutation with the `resetFieldOrder` boolean.\n\nThe following example shows updating the ordering of the fields on the \"Color\" metaobject definition.\nPrior to the update, the ordering of the fields is \"name\", \"hex\", \"accent_color\". After the update,\nthe ordering changes to \"hex\", \"name\", and \"accent_color\".\n", "query_string": "mutation UpdateMetaobjectDefinition($id: ID!, $definition: MetaobjectDefinitionUpdateInput!) {\n metaobjectDefinitionUpdate(id: $id, definition: $definition) {\n metaobjectDefinition {\n id\n name\n fieldDefinitions {\n name\n key\n }\n }\n userErrors {\n field\n message\n code\n }\n }\n}", "variables": { "id": "gid://shopify/MetaobjectDefinition/228758553", "definition": { "resetFieldOrder": true, "fieldDefinitions": [ { "update": { "key": "hex" } }, { "update": { "key": "name" } }, { "update": { "key": "accent_color" } } ] } }, "response": { "data": { "metaobjectDefinitionUpdate": { "metaobjectDefinition": { "id": "gid://shopify/MetaobjectDefinition/228758553", "name": "Color", "fieldDefinitions": [ { "name": "Hex code", "key": "hex" }, { "name": "Name", "key": "name" }, { "name": "Accent color", "key": "accent_color" }, { "name": "Related colors", "key": "related_colors" }, { "name": "Secondary Hex code", "key": "secondary_hex" } ] }, "userErrors": [] } } }, "api_name": "admin", "minimum_api_version": "2023-10", "maximum_api_version": "unstable", "location": "/components/content/metaobjects/test/unit/graph_api/admin/mutations/metaobject_definition_update_test.rb", "curl_example": "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation UpdateMetaobjectDefinition($id: ID!, $definition: MetaobjectDefinitionUpdateInput!) { metaobjectDefinitionUpdate(id: $id, definition: $definition) { metaobjectDefinition { id name fieldDefinitions { name key } } userErrors { field message code } } }\",\n \"variables\": {\n \"id\": \"gid://shopify/MetaobjectDefinition/228758553\",\n \"definition\": {\n \"resetFieldOrder\": true,\n \"fieldDefinitions\": [\n {\n \"update\": {\n \"key\": \"hex\"\n }\n },\n {\n \"update\": {\n \"key\": \"name\"\n }\n },\n {\n \"update\": {\n \"key\": \"accent_color\"\n }\n }\n ]\n }\n }\n}'\n", "remix_example": "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation UpdateMetaobjectDefinition($id: ID!, $definition: MetaobjectDefinitionUpdateInput!) {\n metaobjectDefinitionUpdate(id: $id, definition: $definition) {\n metaobjectDefinition {\n id\n name\n fieldDefinitions {\n name\n key\n }\n }\n userErrors {\n field\n message\n code\n }\n }\n }`,\n {\n variables: {\n \"id\": \"gid://shopify/MetaobjectDefinition/228758553\",\n \"definition\": {\n \"resetFieldOrder\": true,\n \"fieldDefinitions\": [\n {\n \"update\": {\n \"key\": \"hex\"\n }\n },\n {\n \"update\": {\n \"key\": \"name\"\n }\n },\n {\n \"update\": {\n \"key\": \"accent_color\"\n }\n }\n ]\n }\n },\n },\n);\n\nconst data = await response.json();\n", "ruby_example": "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n mutation UpdateMetaobjectDefinition($id: ID!, $definition: MetaobjectDefinitionUpdateInput!) {\n metaobjectDefinitionUpdate(id: $id, definition: $definition) {\n metaobjectDefinition {\n id\n name\n fieldDefinitions {\n name\n key\n }\n }\n userErrors {\n field\n message\n code\n }\n }\n }\nQUERY\n\nvariables = {\n \"id\": \"gid://shopify/MetaobjectDefinition/228758553\",\n \"definition\": {\n \"resetFieldOrder\": true,\n \"fieldDefinitions\": [{\"update\"=>{\"key\"=>\"hex\"}}, {\"update\"=>{\"key\"=>\"name\"}}, {\"update\"=>{\"key\"=>\"accent_color\"}}]\n }\n}\n\nresponse = client.query(query: query, variables: variables)\n", "node_example": "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation UpdateMetaobjectDefinition($id: ID!, $definition: MetaobjectDefinitionUpdateInput!) {\n metaobjectDefinitionUpdate(id: $id, definition: $definition) {\n metaobjectDefinition {\n id\n name\n fieldDefinitions {\n name\n key\n }\n }\n userErrors {\n field\n message\n code\n }\n }\n }`,\n \"variables\": {\n \"id\": \"gid://shopify/MetaobjectDefinition/228758553\",\n \"definition\": {\n \"resetFieldOrder\": true,\n \"fieldDefinitions\": [\n {\n \"update\": {\n \"key\": \"hex\"\n }\n },\n {\n \"update\": {\n \"key\": \"name\"\n }\n },\n {\n \"update\": {\n \"key\": \"accent_color\"\n }\n }\n ]\n }\n },\n },\n});\n", "php_example": "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n mutation UpdateMetaobjectDefinition($id: ID!, $definition: MetaobjectDefinitionUpdateInput!) {\n metaobjectDefinitionUpdate(id: $id, definition: $definition) {\n metaobjectDefinition {\n id\n name\n fieldDefinitions {\n name\n key\n }\n }\n userErrors {\n field\n message\n code\n }\n }\n }\nQUERY;\n\n$variables = [\n \"id\" => \"gid://shopify/MetaobjectDefinition/228758553\",\n \"definition\" => [\n \"resetFieldOrder\" => true,\n \"fieldDefinitions\" => [{\"update\"=>{\"key\"=>\"hex\"}}, {\"update\"=>{\"key\"=>\"name\"}}, {\"update\"=>{\"key\"=>\"accent_color\"}}],\n ],\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" }, "titleStringKey": "variables", "inputVariableEntries": [ { "arg": { "name": "id", "description": "The ID of the metaobject definition to update.", "type": { "kind": "SCALAR", "name": "ID", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "ID!", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "id", "argValue": " \"gid://shopify/MetaobjectDefinition/228758553\"", "typeKind": "MUTATION" }, { "arg": { "name": "definition", "description": "The input fields for updating a metaobject definition.", "type": { "kind": "INPUT_OBJECT", "name": "MetaobjectDefinitionUpdateInput", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "MetaobjectDefinitionUpdateInput!", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "definition", "argValue": " {\"resetFieldOrder\":true,\"fieldDefinitions\":[{\"update\":{\"key\":\"hex\"}},{\"update\":{\"key\":\"name\"}},{\"update\":{\"key\":\"accent_color\"}}]}", "typeKind": "MUTATION" } ] } ]