Skip to content

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:

  1. Query the product to get bookingProductId from the bookingProducts relationship
  2. Customer selects a date on the frontend
  3. Query bookingSlots with the bookingProductId and selected date to get available slots
  4. Customer picks a slot from the results
  5. Add to cart using the selected slot value in the booking JSON

The shape of the response depends on the product's booking type — Default, Appointment, and Table return a flat list, Rental returns time-range groups, and Event returns nothing. See Response by Booking Type.

Arguments

ArgumentTypeRequiredDescription
idInt!YesThe bookingProductId — obtained from the product query's bookingProducts relationship (not the product ID).
dateString!YesThe date to check for available slots in YYYY-MM-DD format.

Response Fields

Every entry is the same object type. Which fields carry a value depends on the booking type — the unused ones come back null.

FieldTypePopulated forDescription
slotIdStringAllIdentifier for the entry. Flat types repeat the timestamp range here; grouped rental entries carry the group's index.
fromStringFlat typesSlot start. Appointment and Table return a time ("10:00 AM"); Default returns a full day and time ("Thu, 13 Aug 08:00 AM").
toStringFlat typesSlot end, in the same format as from.
timestampStringFlat typesUnix range as "from-to", e.g. "1786595400-1786599000".
qtyStringAppointment, TableBookings still available for the slot. null for Default.
timeStringRentalLabel of the time-range group, e.g. "08:00 AM - 11:59 PM".
slotsIterableRentalJSON array of the individual hourly slots in the group, each an object of from, to, timestamp, and qty.

Select slots on its own — it is a JSON value, so it returns whole and cannot take a sub-selection. Do not select id: the entries have no standalone endpoint, so asking for it fails the whole entry.

Response by Booking Type

Booking TypeResponse StructureFields to Query
DefaultFlat — one entry spanning the product's whole availability windowslotId, from, to, timestamp
AppointmentFlat — one entry per bookable slotslotId, from, to, timestamp, qty
TableFlat — one entry per bookable sittingslotId, from, to, timestamp, qty
RentalGrouped by time range, hourly slots nested insideslotId, time, slots
EventEmpty array — availability is sold as tickets

Rental returns the grouped hourly shape whichever renting type the product uses, daily included. Read the ticket fields on the product's bookingProducts node for events.

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:

graphql
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)

graphql
# Step 1: User selects a date, fetch available slots
query {
  bookingSlots(id: 3, date: "2026-08-13") {
    from
    to
    timestamp
    qty
  }
}

Then use the from and to values to construct the slot field for the add-to-cart mutation:

json
{
  "booking": "{\"type\":\"appointment\",\"date\":\"2026-08-13\",\"slot\":\"10:00 AM - 10:45 AM\"}"
}

Build an Hourly Rental Slot Picker

graphql
# Fetch grouped rental slots
query {
  bookingSlots(id: 4, date: "2026-08-13") {
    time
    slots
  }
}

Display the time groups as headers and individual slots as selectable options. Then use the selected slot for add-to-cart:

json
{
  "booking": "{\"type\":\"rental\",\"renting_type\":\"hourly\",\"date\":\"2026-08-13\",\"slot\":\"12:00 PM - 01:00 PM\"}"
}

Best Practices

  1. Use the bookingProductId, not the product ID — the id argument takes the _id from the bookingProducts relationship
  2. Check for empty results — an empty array means no slots are available on that date; prompt for a different one
  3. Check qty where it applies — Appointment and Table slots carry a qty; hide any slot whose qty is 0. Default slots return qty as null, so there is nothing to test.
  4. Handle both structures — read the product's booking type to know whether to expect flat slots or grouped rental groups
  5. Refresh on date change — re-query whenever the customer picks a different date
  • Single Product - Get product details including bookingProducts relationship
  • Add to Cart - Add booking product to cart with selected slot

Released under the MIT License.