Skip to Content

menus

Retrieve all link lists (navigation menus) available in the store.

Query Structure

query { menus { id title items { id title url type } } }

Arguments

ArgumentTypeDescriptionRequiredDefault
NoneThis query does not accept any arguments.NoN/A

Return Type

menus returns a list of Menu objects. Each Menu contains the following fields:

  • id (Integer): Unique identifier of the menu.
  • title (String): The display title of the menu.
  • items (Array of MenuItem): List of menu items belonging to the menu.

Each MenuItem includes:

  • id (Integer): Unique identifier of the menu item.
  • title (String): The display title of the menu item.
  • url (String): The URL the menu item points to.
  • type (String): The type of the menu item (e.g., “link”, “collection”, “product”).

Examples

Basic Query

query { menus { id title } }

Advanced Query

query { menus { id title items { id title url type } } }

Field Selection

query { menus { title items { title url } } }

cURL Example

curl -X POST https://www.mystoreurl.com/graphql/0.8.0/ \ -H "Content-Type: application/json" \ -d '{"query":"query { menus { id title items { id title url type } } }"}'

JavaScript Example

async function fetchMenus() { const query = ` query { menus { id title items { id title url type } } } `; try { const response = await fetch('https://www.mystoreurl.com/graphql/0.8.0/', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ query }), }); const { data, errors } = await response.json(); if (errors) { console.error('GraphQL errors:', errors); return null; } return data.menus; } catch (error) { console.error('Network error:', error); return null; } } // Usage example fetchMenus().then(menus => { if (menus) { console.log('Menus:', menus); } });

Response Format

The response contains a data object with a menus array. Each element in the array is a Menu object with its fields and nested items array.

Example response snippet:

{ "data": { "menus": [ { "id": 1, "title": "Main Menu", "items": [ { "id": 101, "title": "Home", "url": "/", "type": "link" }, { "id": 102, "title": "Shop", "url": "/collections/all", "type": "collection" } ] }, { "id": 2, "title": "Footer Menu", "items": [ { "id": 201, "title": "Contact Us", "url": "/contact", "type": "link" } ] } ] } }

Error Handling

Possible errors when querying menus include:

Error CodeDescriptionResolution
400Malformed query or invalid syntaxVerify query structure and syntax correctness.
500Internal server errorRetry after some time or contact support.
429Rate limit exceededSlow down request frequency and retry later.

If the response contains an errors array, inspect the error messages for details.

Performance Considerations

  • The menus query returns all menus and their items in a single request. For stores with a large number of menus or menu items, consider selecting only necessary fields to reduce payload size.
  • There is no built-in pagination or filtering for this query; avoid requesting unnecessary nested fields to optimize response time.
  • Rate limits apply to all API requests; implement exponential backoff or retry logic on 429 errors.
  • Responses may be cached on the client side to reduce repeated requests for menu data that changes infrequently.

Authentication

This API currently does not require authentication. However, authentication requirements may be introduced in future versions. Monitor API updates for any changes to authentication requirements.

FieldTypeDescription
idIntUnique identifier of the menu.
titleStringDisplay title of the menu.
items[MenuItem]List of menu items.
FieldTypeDescription
idIntUnique identifier of the menu item.
titleStringDisplay title of the menu item.
urlStringURL the menu item points to.
typeStringType of menu item (e.g., link).

Notes

  • This query does not accept any arguments; it returns all menus.
  • Use field selection to limit the data returned and improve performance.
  • The type field in MenuItem helps determine how to handle or display the menu item in client applications.
  • Because menus typically change infrequently, consider caching the results on the client side.
Last updated on