Anchor to menuUpdatemenu
menuUpdate
mutation
Requires access scope.
Updates a menu.
Anchor to Arguments
Arguments
- Anchor to handlehandle•
The menu's handle.
- •ID!required
ID of the menu to be updated.
- Anchor to itemsitems•[Menu
Item requiredUpdate Input!]! List of the menu's items.
- Anchor to titletitle•String!required
The menu's title.
Was this section helpful?
Anchor to MenuUpdatePayload returnsMenuUpdatePayload returns
- Anchor to menumenu•
The updated menu.
- Anchor to userErrorsuser•
Errors [MenuUpdate non-nullUser Error!]! The list of errors that occurred from executing the mutation.
Was this section helpful?
- Update a menu
- menuUpdate reference
Examples
1const { admin } = await authenticate.admin(request);23const response = await admin.graphql(4 `#graphql5 mutation UpdateMenu($id: ID!, $title: String!, $handle: String!, $items: [MenuItemUpdateInput!]!) {6 menuUpdate(id: $id, title: $title, handle: $handle, items: $items) {7 menu {8 id9 handle10 items {11 id12 title13 items {14 id15 title16 }17 }18 }19 }20 }`,21 {22 variables: {23 "id": "gid://shopify/Menu/442047006",24 "title": "updated menu",25 "handle": "danielstuff-main-menu",26 "items": [27 {28 "id": "gid://shopify/MenuItem/398712010",29 "title": "Electronics",30 "url": "collection/tables",31 "resourceId": "gid://shopify/Collection/71762467",32 "type": "COLLECTION",33 "items": []34 },35 {36 "id": "gid://shopify/MenuItem/643685044",37 "title": "Furniture",38 "url": "/collections/furniture",39 "resourceId": "gid://shopify/Collection/643685044",40 "type": "COLLECTION",41 "items": [42 {43 "id": "gid://shopify/MenuItem/927352226",44 "title": "Updated Living Room",45 "url": "/collections/living-room",46 "resourceId": "gid://shopify/Collection/927352226",47 "type": "COLLECTION",48 "items": [49 {50 "id": "gid://shopify/MenuItem/307741084",51 "title": "Sofa",52 "url": "/collections/sofa",53 "resourceId": "gid://shopify/Collection/307741084",54 "type": "COLLECTION",55 "items": []56 },57 {58 "id": "gid://shopify/MenuItem/375350346",59 "title": "Sound System",60 "url": "/collections/sound-system",61 "resourceId": "gid://shopify/Collection/375350346",62 "type": "COLLECTION",63 "items": []64 },65 {66 "id": "gid://shopify/MenuItem/837241978",67 "title": "Massage Chairs",68 "url": "/collections/massage%20chairs",69 "resourceId": "gid://shopify/Collection/837241978",70 "type": "COLLECTION",71 "items": []72 },73 {74 "id": "gid://shopify/MenuItem/960081962",75 "title": "Living Room Rugs",76 "url": "/collections/living%20room%20rugs",77 "resourceId": "gid://shopify/Collection/960081962",78 "type": "COLLECTION",79 "items": []80 }81 ]82 },83 {84 "id": "gid://shopify/MenuItem/715378231",85 "title": "Kitchen",86 "url": "/collections/kitchen",87 "resourceId": "gid://shopify/Collection/715378231",88 "type": "COLLECTION",89 "items": [90 {91 "id": "gid://shopify/MenuItem/108641250",92 "title": "Chairs",93 "url": "/collections/chairs",94 "resourceId": "gid://shopify/Collection/108641250",95 "type": "COLLECTION",96 "items": []97 },98 {99 "id": "gid://shopify/MenuItem/71762467",100 "title": "Tables",101 "url": "/collections/tables",102 "resourceId": "gid://shopify/Collection/71762467",103 "type": "COLLECTION",104 "items": []105 },106 {107 "id": "gid://shopify/MenuItem/826396515",108 "title": "Kitchen Rugs",109 "url": "/collections/kitchen%20rugs",110 "resourceId": "gid://shopify/Collection/826396515",111 "type": "COLLECTION",112 "items": []113 }114 ]115 }116 ]117 },118 {119 "id": "gid://shopify/MenuItem/698896745",120 "title": "Mega Sofa Sale",121 "url": "/collections/mega%20sale",122 "resourceId": "gid://shopify/Collection/307741084",123 "type": "COLLECTION",124 "items": []125 }126 ]127 },128 },129);130131const data = await response.json();132
mutation UpdateMenu($id: ID!, $title: String!, $handle: String!, $items: [MenuItemUpdateInput!]!) {
menuUpdate(id: $id, title: $title, handle: $handle, items: $items) {
menu {
id
handle
items {
id
title
items {
id
title
}
}
}
}
}
curl -X POST \
https://your-development-store.myshopify.com/admin/api/unstable/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "mutation UpdateMenu($id: ID!, $title: String!, $handle: String!, $items: [MenuItemUpdateInput!]!) { menuUpdate(id: $id, title: $title, handle: $handle, items: $items) { menu { id handle items { id title items { id title } } } } }",
"variables": {
"id": "gid://shopify/Menu/442047006",
"title": "updated menu",
"handle": "danielstuff-main-menu",
"items": [
{
"id": "gid://shopify/MenuItem/398712010",
"title": "Electronics",
"url": "collection/tables",
"resourceId": "gid://shopify/Collection/71762467",
"type": "COLLECTION",
"items": []
},
{
"id": "gid://shopify/MenuItem/643685044",
"title": "Furniture",
"url": "/collections/furniture",
"resourceId": "gid://shopify/Collection/643685044",
"type": "COLLECTION",
"items": [
{
"id": "gid://shopify/MenuItem/927352226",
"title": "Updated Living Room",
"url": "/collections/living-room",
"resourceId": "gid://shopify/Collection/927352226",
"type": "COLLECTION",
"items": [
{
"id": "gid://shopify/MenuItem/307741084",
"title": "Sofa",
"url": "/collections/sofa",
"resourceId": "gid://shopify/Collection/307741084",
"type": "COLLECTION",
"items": []
},
{
"id": "gid://shopify/MenuItem/375350346",
"title": "Sound System",
"url": "/collections/sound-system",
"resourceId": "gid://shopify/Collection/375350346",
"type": "COLLECTION",
"items": []
},
{
"id": "gid://shopify/MenuItem/837241978",
"title": "Massage Chairs",
"url": "/collections/massage%20chairs",
"resourceId": "gid://shopify/Collection/837241978",
"type": "COLLECTION",
"items": []
},
{
"id": "gid://shopify/MenuItem/960081962",
"title": "Living Room Rugs",
"url": "/collections/living%20room%20rugs",
"resourceId": "gid://shopify/Collection/960081962",
"type": "COLLECTION",
"items": []
}
]
},
{
"id": "gid://shopify/MenuItem/715378231",
"title": "Kitchen",
"url": "/collections/kitchen",
"resourceId": "gid://shopify/Collection/715378231",
"type": "COLLECTION",
"items": [
{
"id": "gid://shopify/MenuItem/108641250",
"title": "Chairs",
"url": "/collections/chairs",
"resourceId": "gid://shopify/Collection/108641250",
"type": "COLLECTION",
"items": []
},
{
"id": "gid://shopify/MenuItem/71762467",
"title": "Tables",
"url": "/collections/tables",
"resourceId": "gid://shopify/Collection/71762467",
"type": "COLLECTION",
"items": []
},
{
"id": "gid://shopify/MenuItem/826396515",
"title": "Kitchen Rugs",
"url": "/collections/kitchen%20rugs",
"resourceId": "gid://shopify/Collection/826396515",
"type": "COLLECTION",
"items": []
}
]
}
]
},
{
"id": "gid://shopify/MenuItem/698896745",
"title": "Mega Sofa Sale",
"url": "/collections/mega%20sale",
"resourceId": "gid://shopify/Collection/307741084",
"type": "COLLECTION",
"items": []
}
]
}
}'
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation UpdateMenu($id: ID!, $title: String!, $handle: String!, $items: [MenuItemUpdateInput!]!) {
menuUpdate(id: $id, title: $title, handle: $handle, items: $items) {
menu {
id
handle
items {
id
title
items {
id
title
}
}
}
}
}`,
{
variables: {
"id": "gid://shopify/Menu/442047006",
"title": "updated menu",
"handle": "danielstuff-main-menu",
"items": [
{
"id": "gid://shopify/MenuItem/398712010",
"title": "Electronics",
"url": "collection/tables",
"resourceId": "gid://shopify/Collection/71762467",
"type": "COLLECTION",
"items": []
},
{
"id": "gid://shopify/MenuItem/643685044",
"title": "Furniture",
"url": "/collections/furniture",
"resourceId": "gid://shopify/Collection/643685044",
"type": "COLLECTION",
"items": [
{
"id": "gid://shopify/MenuItem/927352226",
"title": "Updated Living Room",
"url": "/collections/living-room",
"resourceId": "gid://shopify/Collection/927352226",
"type": "COLLECTION",
"items": [
{
"id": "gid://shopify/MenuItem/307741084",
"title": "Sofa",
"url": "/collections/sofa",
"resourceId": "gid://shopify/Collection/307741084",
"type": "COLLECTION",
"items": []
},
{
"id": "gid://shopify/MenuItem/375350346",
"title": "Sound System",
"url": "/collections/sound-system",
"resourceId": "gid://shopify/Collection/375350346",
"type": "COLLECTION",
"items": []
},
{
"id": "gid://shopify/MenuItem/837241978",
"title": "Massage Chairs",
"url": "/collections/massage%20chairs",
"resourceId": "gid://shopify/Collection/837241978",
"type": "COLLECTION",
"items": []
},
{
"id": "gid://shopify/MenuItem/960081962",
"title": "Living Room Rugs",
"url": "/collections/living%20room%20rugs",
"resourceId": "gid://shopify/Collection/960081962",
"type": "COLLECTION",
"items": []
}
]
},
{
"id": "gid://shopify/MenuItem/715378231",
"title": "Kitchen",
"url": "/collections/kitchen",
"resourceId": "gid://shopify/Collection/715378231",
"type": "COLLECTION",
"items": [
{
"id": "gid://shopify/MenuItem/108641250",
"title": "Chairs",
"url": "/collections/chairs",
"resourceId": "gid://shopify/Collection/108641250",
"type": "COLLECTION",
"items": []
},
{
"id": "gid://shopify/MenuItem/71762467",
"title": "Tables",
"url": "/collections/tables",
"resourceId": "gid://shopify/Collection/71762467",
"type": "COLLECTION",
"items": []
},
{
"id": "gid://shopify/MenuItem/826396515",
"title": "Kitchen Rugs",
"url": "/collections/kitchen%20rugs",
"resourceId": "gid://shopify/Collection/826396515",
"type": "COLLECTION",
"items": []
}
]
}
]
},
{
"id": "gid://shopify/MenuItem/698896745",
"title": "Mega Sofa Sale",
"url": "/collections/mega%20sale",
"resourceId": "gid://shopify/Collection/307741084",
"type": "COLLECTION",
"items": []
}
]
},
},
);
const data = await response.json();
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `mutation UpdateMenu($id: ID!, $title: String!, $handle: String!, $items: [MenuItemUpdateInput!]!) {
menuUpdate(id: $id, title: $title, handle: $handle, items: $items) {
menu {
id
handle
items {
id
title
items {
id
title
}
}
}
}
}`,
"variables": {
"id": "gid://shopify/Menu/442047006",
"title": "updated menu",
"handle": "danielstuff-main-menu",
"items": [
{
"id": "gid://shopify/MenuItem/398712010",
"title": "Electronics",
"url": "collection/tables",
"resourceId": "gid://shopify/Collection/71762467",
"type": "COLLECTION",
"items": []
},
{
"id": "gid://shopify/MenuItem/643685044",
"title": "Furniture",
"url": "/collections/furniture",
"resourceId": "gid://shopify/Collection/643685044",
"type": "COLLECTION",
"items": [
{
"id": "gid://shopify/MenuItem/927352226",
"title": "Updated Living Room",
"url": "/collections/living-room",
"resourceId": "gid://shopify/Collection/927352226",
"type": "COLLECTION",
"items": [
{
"id": "gid://shopify/MenuItem/307741084",
"title": "Sofa",
"url": "/collections/sofa",
"resourceId": "gid://shopify/Collection/307741084",
"type": "COLLECTION",
"items": []
},
{
"id": "gid://shopify/MenuItem/375350346",
"title": "Sound System",
"url": "/collections/sound-system",
"resourceId": "gid://shopify/Collection/375350346",
"type": "COLLECTION",
"items": []
},
{
"id": "gid://shopify/MenuItem/837241978",
"title": "Massage Chairs",
"url": "/collections/massage%20chairs",
"resourceId": "gid://shopify/Collection/837241978",
"type": "COLLECTION",
"items": []
},
{
"id": "gid://shopify/MenuItem/960081962",
"title": "Living Room Rugs",
"url": "/collections/living%20room%20rugs",
"resourceId": "gid://shopify/Collection/960081962",
"type": "COLLECTION",
"items": []
}
]
},
{
"id": "gid://shopify/MenuItem/715378231",
"title": "Kitchen",
"url": "/collections/kitchen",
"resourceId": "gid://shopify/Collection/715378231",
"type": "COLLECTION",
"items": [
{
"id": "gid://shopify/MenuItem/108641250",
"title": "Chairs",
"url": "/collections/chairs",
"resourceId": "gid://shopify/Collection/108641250",
"type": "COLLECTION",
"items": []
},
{
"id": "gid://shopify/MenuItem/71762467",
"title": "Tables",
"url": "/collections/tables",
"resourceId": "gid://shopify/Collection/71762467",
"type": "COLLECTION",
"items": []
},
{
"id": "gid://shopify/MenuItem/826396515",
"title": "Kitchen Rugs",
"url": "/collections/kitchen%20rugs",
"resourceId": "gid://shopify/Collection/826396515",
"type": "COLLECTION",
"items": []
}
]
}
]
},
{
"id": "gid://shopify/MenuItem/698896745",
"title": "Mega Sofa Sale",
"url": "/collections/mega%20sale",
"resourceId": "gid://shopify/Collection/307741084",
"type": "COLLECTION",
"items": []
}
]
},
},
});
session = ShopifyAPI::Auth::Session.new(
shop: "your-development-store.myshopify.com",
access_token: access_token
)
client = ShopifyAPI::Clients::Graphql::Admin.new(
session: session
)
query = <<~QUERY
mutation UpdateMenu($id: ID!, $title: String!, $handle: String!, $items: [MenuItemUpdateInput!]!) {
menuUpdate(id: $id, title: $title, handle: $handle, items: $items) {
menu {
id
handle
items {
id
title
items {
id
title
}
}
}
}
}
QUERY
variables = {
"id": "gid://shopify/Menu/442047006",
"title": "updated menu",
"handle": "danielstuff-main-menu",
"items": [{"id"=>"gid://shopify/MenuItem/398712010", "title"=>"Electronics", "url"=>"collection/tables", "resourceId"=>"gid://shopify/Collection/71762467", "type"=>"COLLECTION", "items"=>[]}, {"id"=>"gid://shopify/MenuItem/643685044", "title"=>"Furniture", "url"=>"/collections/furniture", "resourceId"=>"gid://shopify/Collection/643685044", "type"=>"COLLECTION", "items"=>[{"id"=>"gid://shopify/MenuItem/927352226", "title"=>"Updated Living Room", "url"=>"/collections/living-room", "resourceId"=>"gid://shopify/Collection/927352226", "type"=>"COLLECTION", "items"=>[{"id"=>"gid://shopify/MenuItem/307741084", "title"=>"Sofa", "url"=>"/collections/sofa", "resourceId"=>"gid://shopify/Collection/307741084", "type"=>"COLLECTION", "items"=>[]}, {"id"=>"gid://shopify/MenuItem/375350346", "title"=>"Sound System", "url"=>"/collections/sound-system", "resourceId"=>"gid://shopify/Collection/375350346", "type"=>"COLLECTION", "items"=>[]}, {"id"=>"gid://shopify/MenuItem/837241978", "title"=>"Massage Chairs", "url"=>"/collections/massage%20chairs", "resourceId"=>"gid://shopify/Collection/837241978", "type"=>"COLLECTION", "items"=>[]}, {"id"=>"gid://shopify/MenuItem/960081962", "title"=>"Living Room Rugs", "url"=>"/collections/living%20room%20rugs", "resourceId"=>"gid://shopify/Collection/960081962", "type"=>"COLLECTION", "items"=>[]}]}, {"id"=>"gid://shopify/MenuItem/715378231", "title"=>"Kitchen", "url"=>"/collections/kitchen", "resourceId"=>"gid://shopify/Collection/715378231", "type"=>"COLLECTION", "items"=>[{"id"=>"gid://shopify/MenuItem/108641250", "title"=>"Chairs", "url"=>"/collections/chairs", "resourceId"=>"gid://shopify/Collection/108641250", "type"=>"COLLECTION", "items"=>[]}, {"id"=>"gid://shopify/MenuItem/71762467", "title"=>"Tables", "url"=>"/collections/tables", "resourceId"=>"gid://shopify/Collection/71762467", "type"=>"COLLECTION", "items"=>[]}, {"id"=>"gid://shopify/MenuItem/826396515", "title"=>"Kitchen Rugs", "url"=>"/collections/kitchen%20rugs", "resourceId"=>"gid://shopify/Collection/826396515", "type"=>"COLLECTION", "items"=>[]}]}]}, {"id"=>"gid://shopify/MenuItem/698896745", "title"=>"Mega Sofa Sale", "url"=>"/collections/mega%20sale", "resourceId"=>"gid://shopify/Collection/307741084", "type"=>"COLLECTION", "items"=>[]}]
}
response = client.query(query: query, variables: variables)
Input variables
JSON1{2 "id": "gid://shopify/Menu/442047006",3 "title": "updated menu",4 "handle": "danielstuff-main-menu",5 "items": [6 {7 "id": "gid://shopify/MenuItem/398712010",8 "title": "Electronics",9 "url": "collection/tables",10 "resourceId": "gid://shopify/Collection/71762467",11 "type": "COLLECTION",12 "items": []13 },14 {15 "id": "gid://shopify/MenuItem/643685044",16 "title": "Furniture",17 "url": "/collections/furniture",18 "resourceId": "gid://shopify/Collection/643685044",19 "type": "COLLECTION",20 "items": [21 {22 "id": "gid://shopify/MenuItem/927352226",23 "title": "Updated Living Room",24 "url": "/collections/living-room",25 "resourceId": "gid://shopify/Collection/927352226",26 "type": "COLLECTION",27 "items": [28 {29 "id": "gid://shopify/MenuItem/307741084",30 "title": "Sofa",31 "url": "/collections/sofa",32 "resourceId": "gid://shopify/Collection/307741084",33 "type": "COLLECTION",34 "items": []35 },36 {37 "id": "gid://shopify/MenuItem/375350346",38 "title": "Sound System",39 "url": "/collections/sound-system",40 "resourceId": "gid://shopify/Collection/375350346",41 "type": "COLLECTION",42 "items": []43 },44 {45 "id": "gid://shopify/MenuItem/837241978",46 "title": "Massage Chairs",47 "url": "/collections/massage%20chairs",48 "resourceId": "gid://shopify/Collection/837241978",49 "type": "COLLECTION",50 "items": []51 },52 {53 "id": "gid://shopify/MenuItem/960081962",54 "title": "Living Room Rugs",55 "url": "/collections/living%20room%20rugs",56 "resourceId": "gid://shopify/Collection/960081962",57 "type": "COLLECTION",58 "items": []59 }60 ]61 },62 {63 "id": "gid://shopify/MenuItem/715378231",64 "title": "Kitchen",65 "url": "/collections/kitchen",66 "resourceId": "gid://shopify/Collection/715378231",67 "type": "COLLECTION",68 "items": [69 {70 "id": "gid://shopify/MenuItem/108641250",71 "title": "Chairs",72 "url": "/collections/chairs",73 "resourceId": "gid://shopify/Collection/108641250",74 "type": "COLLECTION",75 "items": []76 },77 {78 "id": "gid://shopify/MenuItem/71762467",79 "title": "Tables",80 "url": "/collections/tables",81 "resourceId": "gid://shopify/Collection/71762467",82 "type": "COLLECTION",83 "items": []84 },85 {86 "id": "gid://shopify/MenuItem/826396515",87 "title": "Kitchen Rugs",88 "url": "/collections/kitchen%20rugs",89 "resourceId": "gid://shopify/Collection/826396515",90 "type": "COLLECTION",91 "items": []92 }93 ]94 }95 ]96 },97 {98 "id": "gid://shopify/MenuItem/698896745",99 "title": "Mega Sofa Sale",100 "url": "/collections/mega%20sale",101 "resourceId": "gid://shopify/Collection/307741084",102 "type": "COLLECTION",103 "items": []104 }105 ]106}
Response
JSON1{2 "menuUpdate": {3 "menu": {4 "id": "gid://shopify/Menu/442047006",5 "handle": "danielstuff-main-menu",6 "items": [7 {8 "id": "gid://shopify/MenuItem/398712010",9 "title": "Electronics",10 "items": []11 },12 {13 "id": "gid://shopify/MenuItem/643685044",14 "title": "Furniture",15 "items": [16 {17 "id": "gid://shopify/MenuItem/927352226",18 "title": "Updated Living Room"19 },20 {21 "id": "gid://shopify/MenuItem/715378231",22 "title": "Kitchen"23 }24 ]25 },26 {27 "id": "gid://shopify/MenuItem/698896745",28 "title": "Mega Sofa Sale",29 "items": []30 }31 ]32 }33 }34}