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
Argument | Type | Description | Required | Default |
---|---|---|---|---|
None | This query does not accept any arguments. | No | N/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.
Field | Type | Description |
---|---|---|
rootUrl | String | URL to store root |
accountUrl | String | URL to user account page |
accountEditUrl | String | URL to user account edit page |
accountLoginUrl | String | URL to user account login page |
accountLogoutUrl | String | URL to sign out current user |
accountRegisterUrl | String | URL to register a new customer account |
accountPasswordRecoverUrl | String | URL to account password recovery |
accountPasswordChangeUrl | String | URL to account password update |
accountOrdersUrl | String | URL to user account orders page |
accountWishlistUrl | String | URL to user account wishlist page |
searchUrl | String | URL to store search page |
cartUrl | String | URL to cart |
checkoutUrl | String | URL to checkout |
catalogUrl | String | URL to catalog |
blogUrl | String | URL 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 Code | Description | Handling Recommendation |
---|---|---|
400 | Bad Request - The query is malformed | Verify query syntax and structure |
404 | Not Found - The endpoint does not exist | Check the API endpoint URL |
500 | Internal Server Error | Retry after some time; contact support if persistent |
GRAPHQL_VALIDATION_FAILED | Query validation failed | Ensure 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.
Related Types
Type | Description |
---|---|
Routes | Object 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