Skip to Content

routes

Get all available route endpoints in the store.

Query Structure

query { routes { rootUrl accountUrl accountEditUrl accountLoginUrl accountLogoutUrl accountRegisterUrl accountPasswordRecoverUrl accountPasswordChangeUrl accountOrdersUrl accountWishlistUrl searchUrl cartUrl checkoutUrl catalogUrl blogUrl } }

Arguments

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

Return Type

Type: Routes

The Routes object contains URLs for various store endpoints. All fields are optional and return a string URL if available.

FieldTypeDescription
rootUrlStringURL to store root
accountUrlStringURL to user account page
accountEditUrlStringURL to user account edit page
accountLoginUrlStringURL to user account login page
accountLogoutUrlStringURL to sign out current user
accountRegisterUrlStringURL to register a new customer account
accountPasswordRecoverUrlStringURL to account password recovery
accountPasswordChangeUrlStringURL to account password update
accountOrdersUrlStringURL to user account orders page
accountWishlistUrlStringURL to user account wishlist page
searchUrlStringURL to store search page
cartUrlStringURL to cart
checkoutUrlStringURL to checkout
catalogUrlStringURL to catalog
blogUrlStringURL to blog

Examples

Basic Query

query { routes { rootUrl cartUrl checkoutUrl } }

Advanced Query

query { routes { rootUrl accountUrl accountLoginUrl accountLogoutUrl accountRegisterUrl accountPasswordRecoverUrl accountPasswordChangeUrl accountOrdersUrl accountWishlistUrl searchUrl cartUrl checkoutUrl catalogUrl blogUrl } }

Field Selection

query { routes { accountUrl accountOrdersUrl searchUrl catalogUrl } }

cURL Example

curl -X POST https://www.mystoreurl.com/graphql/0.8.0 \ -H "Content-Type: application/json" \ -d '{"query":"query { routes { rootUrl cartUrl checkoutUrl } }"}'

JavaScript Example

async function fetchRoutes() { const endpoint = "https://www.mystoreurl.com/graphql/0.8.0"; const query = ` query { routes { rootUrl cartUrl checkoutUrl } } `; try { const response = await fetch(endpoint, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ query }) }); if (!response.ok) { throw new Error(`Network error: ${response.status} ${response.statusText}`); } const result = await response.json(); if (result.errors) { console.error("GraphQL errors:", result.errors); return null; } return result.data.routes; } catch (error) { console.error("Fetch error:", error); return null; } } // Usage example fetchRoutes().then(routes => { if (routes) { console.log("Store root URL:", routes.rootUrl); console.log("Cart URL:", routes.cartUrl); console.log("Checkout URL:", routes.checkoutUrl); } });

Response Format

The response contains a routes object with optional string fields representing URLs for various store endpoints.

Example response:

{ "data": { "routes": { "rootUrl": "https://www.mystoreurl.com/", "accountUrl": "https://www.mystoreurl.com/account", "accountLoginUrl": "https://www.mystoreurl.com/account/login", "cartUrl": "https://www.mystoreurl.com/cart", "checkoutUrl": "https://www.mystoreurl.com/checkout", "catalogUrl": "https://www.mystoreurl.com/catalog", "blogUrl": "https://www.mystoreurl.com/blog" } } }

Error Handling

The routes query may return errors in the following scenarios:

Error CodeDescriptionHandling Recommendation
400Bad Request - The query is malformedVerify query syntax and structure
404Not Found - The endpoint does not existCheck the API endpoint URL
500Internal Server ErrorRetry after some time; contact support if persistent
GRAPHQL_VALIDATION_FAILEDQuery validation failedEnsure requested fields exist and query is valid

GraphQL errors will be returned in the errors field of the response JSON. Always check for and handle errors in your client code.

Performance Considerations

  • The routes query returns a small, fixed set of URLs and is lightweight.
  • No arguments or filters are accepted, so performance impact is minimal.
  • Responses can be cached on the client side or via CDN to reduce repeated requests.
  • Rate limiting may apply at the API gateway level; handle HTTP 429 responses gracefully.
  • Avoid unnecessary repeated calls by caching route URLs in your application.

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.

TypeDescription
RoutesObject containing store route URLs

Notes

  • All route URLs are optional and may be null if not configured.
  • Use this query to dynamically retrieve store URLs instead of hardcoding them.
  • This query does not accept any arguments or filters.
  • Keep your client-side cache updated if routes change frequently.
Last updated on