Get Booking Slots
About
The bookingSlots query retrieves available time slots for a booking product on a specific date. This query is essential for building the booking UI — when a customer selects a date, you use this query to fetch and display the available slots they can choose from before adding the product to cart.
Why This Query Is Needed
When adding a booking product to the cart, the booking input requires a specific time slot (e.g., "slot": "12:00 PM - 01:00 PM"). But the available slots depend on the product's configuration (duration, break time, operating hours) and the selected date (day-of-week availability, existing bookings). This query resolves all of that and returns only the slots that are actually available for selection.
The typical flow is:
- Query the product to get
bookingProductIdfrom thebookingProductsrelationship - Customer selects a date on the frontend
- Query
bookingSlotswith thebookingProductIdand selected date to get available slots - Customer picks a slot from the results
- Add to cart using the selected slot value in the
bookingJSON
Different Response Structures
The response structure differs based on the booking type:
- Default, Appointment, Table, Event — Slots are returned as a flat list. Each item has
from,to,timestamp, andqtyfields directly on it. - Rental (Hourly) — Slots are returned in a grouped structure. Each item has a
timefield (the time range group label) and aslotsarray containing the individual hourly slots within that group. - Rental (Daily) and Event — These types typically don't use time slots (daily rentals use date ranges, events use ticket quantities), so this query may return an empty array for them.
Arguments
| Argument | Type | Required | Description |
|---|---|---|---|
id | Int! | Yes | The bookingProductId — obtained from the product query's bookingProducts relationship (not the product ID). |
date | String! | Yes | The date to check for available slots in YYYY-MM-DD format. |
Response Fields
Non-Rental Booking Types (Flat Structure)
| Field | Type | Description |
|---|---|---|
slotId | Int | Slot identifier (may be null). |
from | String | Slot start time (e.g., "10:00 AM"). |
to | String | Slot end time (e.g., "11:00 AM"). |
timestamp | String | Unix timestamp range in format "from-to" (e.g., "1774413000-1774416600"). |
qty | String | Number of available bookings for this slot. |
Rental Hourly Booking Type (Grouped Structure)
| Field | Type | Description |
|---|---|---|
slotId | Int | Slot identifier (may be null). |
time | String | Time range group label (e.g., "10:00 AM - 12:00 PM"). |
slots | [Slot] | Array of individual hourly slots within the time range group. |
slots[].from | String | Individual slot start time (e.g., "10:00 AM"). |
slots[].to | String | Individual slot end time (e.g., "11:00 AM"). |
slots[].timestamp | String | Unix timestamp range for the individual slot. |
slots[].qty | String | Number of available bookings for this individual slot. |
Response by Booking Type
| Booking Type | Response Structure | Fields to Query |
|---|---|---|
| Default | Flat list | slotId, from, to, timestamp, qty |
| Appointment | Flat list | slotId, from, to, timestamp, qty |
| Table | Flat list | slotId, from, to, timestamp, qty |
| Event | Empty array (events use ticket quantities, not time slots) | — |
| Rental (Hourly) | Grouped by time ranges | slotId, time, slots |
| Rental (Daily) | Empty array (daily rentals use date ranges, not time slots) | — |
How to Get the bookingProductId
The id parameter for this query is not the product ID — it is the bookingProductId from the product's bookingProducts relationship. Query it like this:
query getProduct($id: ID!) {
product(id: $id) {
id
name
bookingProducts {
edges {
node {
_id # This is the bookingProductId to use
type # default, appointment, rental, table, event
}
}
}
}
}Use the _id value from bookingProducts.edges.node as the id argument in the bookingSlots query.
Common Use Cases
Build a Date + Slot Picker (Non-Rental)
# Step 1: User selects a date, fetch available slots
query {
bookingSlots(id: 1, date: "2026-03-26") {
from
to
timestamp
qty
}
}Then use the from and to values to construct the slot field for the add-to-cart mutation:
{
"booking": "{\"type\":\"appointment\",\"date\":\"2026-03-26\",\"slot\":\"10:00 AM - 11:00 AM\"}"
}Build an Hourly Rental Slot Picker
# Fetch grouped rental slots
query {
bookingSlots(id: 5, date: "2026-03-26") {
time
slots
}
}Display the time groups as headers and individual slots as selectable options. Then use the selected slot for add-to-cart:
{
"booking": "{\"type\":\"rental\",\"renting_type\":\"hourly\",\"date\":\"2026-03-26\",\"slot\":\"10:00 AM - 11:00 AM\"}"
}Best Practices
- Use
bookingProductId, Not Product ID — Theidargument must be the_idfrom thebookingProductsrelationship, not the main product ID - Check for Empty Results — An empty array means no slots are available for that date; prompt the user to select a different date
- Check
qty— Only display slots whereqtyis greater than 0 - Handle Both Structures — Use the product's booking
typeto determine whether to expect flat slots or grouped rental slots - Refresh on Date Change — Re-query whenever the user changes the selected date
Related Resources
- Single Product - Get product details including
bookingProductsrelationship - Add to Cart - Add booking product to cart with selected slot

