Skip to main content

GraphQL API

The Facilities Service exposes a GraphQL API that mirrors the REST endpoints.

Endpoint

EnvironmentURL
UAThttps://facilities-api.uat.digiwedge.com/graphql
Localhttp://localhost:3106/graphql

Schema

Types

enum ResourceType {
GOLF_COURSE
DRIVING_RANGE
SIMULATOR
GOLF_CART
TENNIS_COURT
PADEL_COURT
OTHER
}

type FacilityResource {
id: Int!
tenantId: Int!
clubId: Int!
name: String!
type: ResourceType!
description: String
capacity: Int
active: Boolean!
maintenanceRequired: Boolean!
createdAt: DateTime!
updatedAt: DateTime!
}

type MaintenanceLog {
id: Int!
resourceId: Int
courseId: Int
maintenanceType: String
description: String
startTime: DateTime!
endTime: DateTime
recordedBy: String
recordedAt: DateTime!
}

type ResourceUsage {
id: Int!
resourceId: Int!
bookingId: Int
assignedAt: DateTime!
releasedAt: DateTime
}

type FacilityAvailability {
resourceId: Int!
name: String!
type: ResourceType!
available: Boolean!
}

Input Types

input FacilityResourceFilterInput {
tenantId: Int!
clubId: Int
type: ResourceType
search: String
skip: Int
take: Int
includeInactive: Boolean
}

input CreateFacilityResourceInput {
tenantId: Int!
clubId: Int!
name: String!
type: ResourceType!
description: String
capacity: Int
}

input UpdateFacilityResourceInput {
name: String
description: String
capacity: Int
maintenanceRequired: Boolean
}

input AvailabilityRequestInput {
tenantId: Int!
clubId: Int
type: ResourceType
start: DateTime!
end: DateTime!
}

Queries

Facility Resources

# List resources with filters
query FacilityResources {
facilityResources(filters: {
tenantId: 1
clubId: 10
type: SIMULATOR
take: 25
}) {
id
name
type
active
}
}

# Get single resource
query FacilityResource {
facilityResource(id: 42, tenantId: 1) {
id
name
type
description
capacity
}
}

Maintenance Logs

query MaintenanceLogs {
maintenanceLogs(tenantId: 1, resourceId: 42) {
id
maintenanceType
startTime
endTime
}
}

Resource Usage

query ResourceUsages {
resourceUsages(tenantId: 1, resourceId: 42) {
id
bookingId
assignedAt
releasedAt
}
}

Mutations

Facility Resources

mutation CreateResource {
createFacilityResource(data: {
tenantId: 1
clubId: 10
name: "Simulator Bay 4"
type: SIMULATOR
capacity: 4
}) {
id
name
}
}

mutation UpdateResource {
updateFacilityResource(
id: 42
tenantId: 1
data: { maintenanceRequired: true }
) {
id
maintenanceRequired
}
}

mutation DeleteResource {
deleteFacilityResource(id: 42, tenantId: 1) {
id
active
}
}

Maintenance Logs

mutation CreateMaintenanceLog {
createMaintenanceLog(
tenantId: 1
clubId: 10
data: {
resourceId: 42
maintenanceType: "GREENS"
startTime: "2025-01-15T06:00:00Z"
}
) {
id
}
}

Resource Usage

mutation AssignResource {
createResourceUsage(
tenantId: 1
clubId: 10
data: {
resourceId: 42
bookingId: 12345
assignedAt: "2025-01-15T08:00:00Z"
}
) {
id
}
}

Availability Check

mutation CheckAvailability {
facilityAvailability(request: {
tenantId: 1
type: SIMULATOR
start: "2025-01-15T10:00:00Z"
end: "2025-01-15T12:00:00Z"
}) {
resourceId
name
available
}
}

Authentication

Include the JWT token in the Authorization header:

const client = new GraphQLClient('https://facilities-api.uat.digiwedge.com/graphql', {
headers: {
Authorization: `Bearer ${token}`,
},
});