Skip to Content

Link

Represents a single navigational link, which may point to a product, category, page, article, or an external URL. Links can be nested to form hierarchical menus.

Type Definition

type Link { levels: Int links: [Link] title: String type: String url: String target: String product: Product productGroup: ProductGroup page: Page article: Article }

Fields

FieldTypeNullableDescriptionRelated Type
levelsIntYesThe maximum depth of nested child links below this link.
links[Link]YesThe list of child links for this link. Each child link can itself have further children.Link
titleStringYesThe display name of the link, typically shown as the link’s label in navigation components.
typeStringYesThe type of object this link points to, such as ‘product’, ‘category’, ‘page’, or ‘article’.
urlStringYesThe URL that this link points to. This can be an internal or external address.
targetStringYesThe target attribute for the link, indicating how the link should be opened (e.g., in a new tab).
productProductYesThe product object associated with this link, if the link points to a product.Product
productGroupProductGroupYesThe category object associated with this link, if the link points to a category.ProductGroup
pagePageYesThe page object associated with this link, if the link points to a page.Page
articleArticleYesThe article object associated with this link, if the link points to an article.Article

Relationships

  • links: Represents child links nested under this link, enabling hierarchical navigation menus.
  • product: If the link points to a product, this field provides the associated Product object.
  • productGroup: If the link points to a category, this field provides the associated ProductGroup object.
  • page: If the link points to a page, this field provides the associated Page object.
  • article: If the link points to an article, this field provides the associated Article object.

These relationships allow traversal from a navigation link to the detailed object it references.

Usage Examples

Basic Query

Fetch the top-level link titles and their URLs:

{ links { title url } }

Field Selection

Retrieve detailed information about a link including its type, target, and associated product if available:

{ links { title type url target product { id name price } } }

Nested Queries

Fetch a hierarchical menu with up to two levels of nested links, including titles and URLs:

{ links { title url levels links { title url links { title url } } } }

Filtering and Sorting

Since the Link type itself does not define filtering or sorting arguments, these operations should be applied at the query root or connection level where links are retrieved. For example, if a query field supports filtering links by type or sorting by title, that would be specified there.

Below is a hypothetical example assuming a menuLinks query supports filtering by type and sorting by title:

{ menuLinks(filter: { type: "product" }, sort: TITLE_ASC) { title url type } }

Note: Replace menuLinks and filter/sort arguments with actual query fields and arguments as defined in your schema.

Implements

The Link type does not implement any interfaces.

Connections

The links field provides a recursive connection to child Link objects, enabling the construction of nested navigation structures.

  • Product: Represents a product linked from this navigation item.
  • ProductGroup: Represents a category or product group linked from this navigation item.
  • Page: Represents a page linked from this navigation item.
  • Article: Represents an article linked from this navigation item.
  • Link: The same type used for nested child links.

Best Practices

  • Use the levels field to control the depth of nested links returned, preventing overly large responses.
  • When rendering navigation menus, prefer querying only necessary fields (title, url, type) to optimize performance.
  • Leverage the type field to conditionally render links differently based on their target (e.g., product links vs external URLs).
  • Use the target field to determine whether links should open in a new tab or the same window.
  • For large menus, consider paginating or lazy-loading nested links if supported by the query root.

Notes

  • The Link type supports optional fields; always check for nullability in your client code to avoid runtime errors.
  • Recursive nesting via the links field can lead to deep hierarchies; be mindful of query complexity and response size.
  • The API currently requires no authentication, but this may change in future versions. Plan your integration accordingly.
  • No computed or derived fields are defined on Link; all fields reflect stored data.
  • No field arguments are defined on Link fields.
  • When accessing related objects (product, productGroup, page, article), ensure to select only the fields you need to minimize payload size.

For all queries, use the endpoint:

https://www.mystoreurl.com/graphql/0.8.0/

and handle errors gracefully to ensure a robust integration.

Last updated on