Skip to content
Queries

links

Your saved links to products and categories, with their current URL.

links returns your links to products and categories with their current URL, in the same order. Use it if you store links in your own content.

links(links: [StorefrontLinkInput!]!): [StorefrontLink!]

Arguments

FieldTypeRule
links[StorefrontLinkInput!]!Up to 100 links.
links[].urlString!The saved URL or path, 1 to 2048 characters.
links[].referenceStorefrontLinkReferenceInputOptional: the resource type and id.

type is a StorefrontLinkKind: product, category, brand or collection.

  • Only links to products and categories are updated. External links stay as they are.
  • The query and the fragment are kept, such as ?size=m.
FieldTypeDescription
urlString!The current URL.
referenceStorefrontLinkReferencetype and id of the resource it points to, or null.

Example

Links.graphql
query Links($links: [StorefrontLinkInput!]!) {
  links(links: $links) {
    url
    reference { type id }
  }
}
Terminal
curl --request POST "https://storefront.ecomiq.pe/graphql" \
  --header "Content-Type: application/json" \
  --header "x-Store-Domain: my-store" \
  --data-binary '{
    "query": "query Links($links: [StorefrontLinkInput!]!) { links(links: $links) { url reference { type id } } }",
    "variables": { "links": [{ "url": "/products/blue-t-shirt?size=m" }] }
  }'
Response
{
  "data": {
    "links": [
      {
        "url": "/products/blue-pima-t-shirt?size=m",
        "reference": { "type": "product", "id": "7204558912004322039" }
      }
    ]
  }
}

Errors

CodeCause
BAD_USER_INPUTMore than 100 links, an empty URL or one longer than 2048 characters, or an invalid reference.
NOT_FOUNDThe store no longer exists.
STORE_CONTEXT_REQUIREDx-Store-Domain is missing or doesn't match a store.

REST equivalent

POST /v1/urls/links takes { "links": [...] } and responds with the links in links.

Last updated:

On this page