Getting Started
How to connect to and query the Holibob GraphQL API.
Endpoint
The GraphQL API is served at a single HTTP endpoint. All queries and mutations are sent as POST requests to this endpoint.
Depending on the environment, the URL follows this pattern:
| Environment | URL pattern |
|---|---|
| Local development | http://localhost:4000/graphql |
| Staging | Configured per deployment |
| Production | Configured per deployment |
Making a request
Send a POST request with a JSON body containing the query field and optionally variables:
{
"query": "query { viewer { id email } }",
"variables": {}
}
Headers
Include the following headers with every request:
| Header | Purpose |
|---|---|
Content-Type | Must be application/json |
Authorization | Bearer token for authenticated requests |
Client libraries
Apollo Client (React)
The recommended client for React applications is Apollo Client. The booking-web and hub-web applications use Apollo Client with generated React hooks.
import { ApolloClient, InMemoryCache, gql } from "@apollo/client";
const client = new ApolloClient({
uri: "https://your-api-endpoint/graphql",
cache: new InMemoryCache(),
});
graphql-request
For server-side or non-React usage, graphql-request provides a lightweight client:
import { GraphQLClient } from "graphql-request";
const client = new GraphQLClient("https://your-api-endpoint/graphql", {
headers: { Authorization: "Bearer YOUR_TOKEN" },
});
Pagination
Paginated fields implement the PaginatedList interface. Use limit and offset arguments to page through results:
query {
productList(limit: 10, offset: 0) {
nodes {
id
name
}
totalCount
}
}
Error handling
GraphQL errors are returned in the errors array of the response body. Each error object contains a message field and optionally extensions with additional context.
{
"data": null,
"errors": [
{
"message": "Not authorized",
"extensions": {
"code": "FORBIDDEN"
}
}
]
}