Skip to content

Examples

Platform Users — Engineers & Low-code Ops Users (ORA / Panel Builder) OR Platform ORA — AI Planning Interface Agent Workflows Plan Visualisation ADK Integration SDK UI — Frontend Shell FDK Architecture Low code Config-driven DDK Schema Definition Code Generator Generated Server MDK WEM DAL Experiment Manager Nexus Deployment Control Live Monitoring Registry Browser SCDK Source Control Pipeline Mgmt Azure DevOps deploys ↓ SDK API — GraphQL Federation Gateway Federation Gateway Component Resolvers Auth & Licensing Plugins: gql-autogeneration Migrator Helm KinD Boilerplate GenAI ··· Microservices — Domain IP Services Data Pipeline Core Platform Metrics & Analytics Spatial & Geo Simulation Event Detection Camera & Device Fire & Resource Opt. Satellite Modelling ↓ Nexus deploys Deployed OR Applications Rail Ops Dashboard Mine Mgmt Dashboard Port Ops Dashboard ··· FDK-built · DDK-backed · MDK-powered · deployed via Nexus ↑ Application Users — Operations Teams (shift managers, analysts, planners)

This page provides real-world schema examples demonstrating DDK capabilities using operational physical world scenarios.

Table of Contents


Rail Network Operations

A rail operations schema for managing lines, services, stations, and disruption events.

Schema

rail.orm.graphqls:

graphql
type Line @required(type: "CREATE,READ,UPDATE,DELETE", table: "true") {
  id: ID! @constraint(type: "primarykey")
  code: String! @constraint(type: "unique")
  name: String!
  status: LineStatus! @constraint(type: "default", value: "OPERATIONAL")

  stations: [Station]!
    @mapping(
      type: "many2many"
      foreignKey: "id"
      foreignKeyReference: "id"
      mappingTable: "LineStation"
    )
  services: [Service]!
    @mapping(type: "one2many", foreignKey: "lineId", foreignKeyReference: "id")
}

type Station @required(type: "CREATE,READ,UPDATE,DELETE", table: "true") {
  id: ID! @constraint(type: "primarykey")
  code: String! @constraint(type: "unique")
  name: String!
  zone: Int!
  latitude: Float
  longitude: Float

  lines: [Line]!
    @mapping(
      type: "many2many"
      foreignKey: "id"
      foreignKeyReference: "id"
      mappingTable: "LineStation"
    )
  stops: [ServiceStop]!
    @mapping(
      type: "one2many"
      foreignKey: "stationId"
      foreignKeyReference: "id"
    )
}

type LineStation @required(type: "CREATE,READ,DELETE", table: "true") {
  LineID: String @constraint(type: "primarykey")
  StationID: String @constraint(type: "primarykey")
  stopOrder: Int!
}

type Service @required(type: "CREATE,READ,UPDATE,DELETE", table: "true") {
  id: ID! @constraint(type: "primarykey")
  serviceNumber: String! @constraint(type: "unique")
  lineId: String
  scheduledDeparture: String!
  scheduledArrival: String!
  status: ServiceStatus! @constraint(type: "default", value: "ON_TIME")
  delayMinutes: Int @constraint(type: "default", value: "0")

  line: Line
    @mapping(type: "backRef", foreignKey: "id", foreignKeyReference: "lineId")
  stops: [ServiceStop]!
    @mapping(
      type: "one2many"
      foreignKey: "serviceId"
      foreignKeyReference: "id"
    )
  disruptions: [Disruption]!
    @mapping(
      type: "many2many"
      foreignKey: "id"
      foreignKeyReference: "id"
      mappingTable: "ServiceDisruption"
    )
}

type ServiceStop @required(type: "CREATE,READ,UPDATE,DELETE", table: "true") {
  id: ID! @constraint(type: "primarykey")
  serviceId: String
  stationId: String
  scheduledArrival: String
  scheduledDeparture: String
  actualArrival: String
  actualDeparture: String
  stopOrder: Int!

  service: Service
    @mapping(
      type: "backRef"
      foreignKey: "id"
      foreignKeyReference: "serviceId"
    )
  station: Station
    @mapping(
      type: "backRef"
      foreignKey: "id"
      foreignKeyReference: "stationId"
    )
}

type Disruption @required(type: "CREATE,READ,UPDATE,DELETE", table: "true") {
  id: ID! @constraint(type: "primarykey")
  title: String!
  description: String
  severity: DisruptionSeverity!
  status: DisruptionStatus! @constraint(type: "default", value: "ACTIVE")
  startedAt: String!
  resolvedAt: String

  affectedServices: [Service]!
    @mapping(
      type: "many2many"
      foreignKey: "id"
      foreignKeyReference: "id"
      mappingTable: "ServiceDisruption"
    )
}

type ServiceDisruption @required(type: "CREATE,READ,DELETE", table: "true") {
  ServiceID: String @constraint(type: "primarykey")
  DisruptionID: String @constraint(type: "primarykey")
}

enum LineStatus {
  OPERATIONAL
  SUSPENDED
  PARTIAL
}

enum ServiceStatus {
  ON_TIME
  DELAYED
  CANCELLED
  DIVERTED
}

enum DisruptionSeverity {
  LOW
  MEDIUM
  HIGH
  CRITICAL
}

enum DisruptionStatus {
  ACTIVE
  MONITORING
  RESOLVED
}

Custom Resolvers

rail.custom.graphqls:

graphql
extend type Query {
  getActiveDisruptions: [Disruption]! @resolver(type: "CUSTOM")
  getServicesByLine(lineId: ID!, date: String!): [Service]!
    @resolver(type: "CUSTOM")
  getDelayedServices(thresholdMinutes: Int!): [Service]!
    @resolver(type: "CUSTOM")
  getDisruptionImpact(disruptionId: ID!): DisruptionImpact!
    @resolver(type: "CUSTOM")
}

extend type Mutation {
  createDisruption(
    title: String!
    description: String
    severity: DisruptionSeverity!
    affectedServiceIds: [ID!]!
  ): Disruption! @resolver(type: "CUSTOM")

  resolveDisruption(disruptionId: ID!): Disruption! @resolver(type: "CUSTOM")
  updateServiceDelay(serviceId: ID!, delayMinutes: Int!): Service!
    @resolver(type: "CUSTOM")
}

extend type Subscription {
  onDisruptionUpdate: Disruption! @subscriber(type: "CUSTOM")
  onServiceStatusChange(lineId: ID!): Service! @subscriber(type: "CUSTOM")
}

type DisruptionImpact {
  affectedServicesCount: Int!
  estimatedPassengersAffected: Int!
  averageDelayMinutes: Float!
}

Sample Queries

Get Active Disruptions with Affected Services:

graphql
query {
  getActiveDisruptions {
    id
    title
    severity
    status
    startedAt
    affectedServices {
      serviceNumber
      status
      delayMinutes
      line {
        code
        name
      }
    }
  }
}

Create Disruption:

graphql
mutation {
  createDisruption(
    title: "Signalling fault between Central and Town Hall"
    severity: HIGH
    affectedServiceIds: ["svc-001", "svc-002", "svc-003"]
  ) {
    id
    title
    severity
    affectedServices {
      serviceNumber
    }
  }
}

Asset Maintenance

An operational asset management schema for tracking physical assets, maintenance schedules, and work orders across a site or network.

Schema

maintenance.orm.graphqls:

graphql
type Site @required(type: "CREATE,READ,UPDATE,DELETE", table: "true") {
  id: ID! @constraint(type: "primarykey")
  code: String! @constraint(type: "unique")
  name: String!
  locationType: LocationType!
  latitude: Float
  longitude: Float

  assets: [Asset]!
    @mapping(type: "one2many", foreignKey: "siteId", foreignKeyReference: "id")
}

type AssetType @required(type: "CREATE,READ,UPDATE,DELETE", table: "true") {
  id: ID! @constraint(type: "primarykey")
  name: String! @constraint(type: "unique")
  category: String!
  defaultMaintenanceIntervalDays: Int!
    @constraint(type: "check", value: "defaultMaintenanceIntervalDays > 0")

  assets: [Asset]!
    @mapping(
      type: "one2many"
      foreignKey: "assetTypeId"
      foreignKeyReference: "id"
    )
}

type Asset @required(type: "CREATE,READ,UPDATE,DELETE", table: "true") {
  id: ID! @constraint(type: "primarykey")
  serialNumber: String! @constraint(type: "unique")
  name: String!
  assetTypeId: String
  siteId: String
  status: AssetStatus! @constraint(type: "default", value: "OPERATIONAL")
  commissionedAt: String!
  lastMaintenanceAt: String
  nextMaintenanceDue: String

  assetType: AssetType
    @mapping(
      type: "backRef"
      foreignKey: "id"
      foreignKeyReference: "assetTypeId"
    )
  site: Site
    @mapping(type: "backRef", foreignKey: "id", foreignKeyReference: "siteId")
  workOrders: [WorkOrder]!
    @mapping(type: "one2many", foreignKey: "assetId", foreignKeyReference: "id")
}

type Technician @required(type: "CREATE,READ,UPDATE,DELETE", table: "true") {
  id: ID! @constraint(type: "primarykey")
  employeeId: String! @constraint(type: "unique")
  name: String!
  specialisation: String!
  isAvailable: Boolean @constraint(type: "default", value: "true")

  assignments: [WorkOrderAssignment]!
    @mapping(
      type: "one2many"
      foreignKey: "technicianId"
      foreignKeyReference: "id"
    )
}

type WorkOrder @required(type: "CREATE,READ,UPDATE,DELETE", table: "true") {
  id: ID! @constraint(type: "primarykey")
  workOrderNumber: String! @constraint(type: "unique")
  assetId: String
  type: WorkOrderType!
  priority: WorkOrderPriority! @constraint(type: "default", value: "NORMAL")
  status: WorkOrderStatus! @constraint(type: "default", value: "OPEN")
  description: String!
  scheduledAt: String
  completedAt: String

  asset: Asset
    @mapping(type: "backRef", foreignKey: "id", foreignKeyReference: "assetId")
  assignments: [WorkOrderAssignment]!
    @mapping(
      type: "one2many"
      foreignKey: "workOrderId"
      foreignKeyReference: "id"
    )
}

type WorkOrderAssignment @required(type: "CREATE,READ,DELETE", table: "true") {
  TechnicianID: String @constraint(type: "primarykey")
  WorkOrderID: String @constraint(type: "primarykey")
  assignedAt: String!

  technician: Technician
    @mapping(
      type: "backRef"
      foreignKey: "id"
      foreignKeyReference: "TechnicianID"
    )
  workOrder: WorkOrder
    @mapping(
      type: "backRef"
      foreignKey: "id"
      foreignKeyReference: "WorkOrderID"
    )
}

enum AssetStatus {
  OPERATIONAL
  DEGRADED
  OFFLINE
  DECOMMISSIONED
}

enum WorkOrderType {
  PREVENTIVE
  CORRECTIVE
  INSPECTION
  EMERGENCY
}

enum WorkOrderPriority {
  LOW
  NORMAL
  HIGH
  CRITICAL
}

enum WorkOrderStatus {
  OPEN
  IN_PROGRESS
  ON_HOLD
  COMPLETED
  CANCELLED
}

enum LocationType {
  DEPOT
  STATION
  SUBSTATION
  FIELD_SITE
}

Custom Resolvers

maintenance.custom.graphqls:

graphql
extend type Query {
  getOverdueAssets: [Asset]! @resolver(type: "CUSTOM")
  getOpenWorkOrders(priority: WorkOrderPriority): [WorkOrder]!
    @resolver(type: "CUSTOM")
  getAssetMaintenanceHistory(assetId: ID!): [WorkOrder]!
    @resolver(type: "CUSTOM")
  getAvailableTechnicians(specialisation: String): [Technician]!
    @resolver(type: "CUSTOM")
}

extend type Mutation {
  createWorkOrder(
    assetId: ID!
    type: WorkOrderType!
    priority: WorkOrderPriority!
    description: String!
    scheduledAt: String
  ): WorkOrder! @resolver(type: "CUSTOM")

  assignTechnician(workOrderId: ID!, technicianId: ID!): WorkOrderAssignment!
    @resolver(type: "CUSTOM")
  completeWorkOrder(workOrderId: ID!): WorkOrder! @resolver(type: "CUSTOM")
}

extend type Subscription {
  onCriticalWorkOrderCreated: WorkOrder! @subscriber(type: "CUSTOM")
}

Sample Queries

Get Overdue Assets with Open Work Orders:

graphql
query {
  getOverdueAssets {
    serialNumber
    name
    status
    nextMaintenanceDue
    assetType {
      name
      category
    }
    site {
      name
      locationType
    }
    workOrders {
      workOrderNumber
      type
      priority
      status
    }
  }
}

Create Emergency Work Order:

graphql
mutation {
  createWorkOrder(
    assetId: "asset-rail-pantograph-07"
    type: EMERGENCY
    priority: CRITICAL
    description: "Pantograph contact strip failure reported by driver on service SVC-112"
    scheduledAt: "2025-04-12T08:00:00Z"
  ) {
    id
    workOrderNumber
    priority
    asset {
      serialNumber
      name
    }
  }
}

Fleet & Logistics

A fleet operations schema for managing vehicles, depots, routes, and delivery assignments.

Schema

fleet.orm.graphqls:

graphql
type Depot @required(type: "CREATE,READ,UPDATE,DELETE", table: "true") {
  id: ID! @constraint(type: "primarykey")
  code: String! @constraint(type: "unique")
  name: String!
  address: String!
  latitude: Float!
  longitude: Float!
  capacity: Int! @constraint(type: "check", value: "capacity > 0")

  vehicles: [Vehicle]!
    @mapping(type: "one2many", foreignKey: "depotId", foreignKeyReference: "id")
  drivers: [Driver]!
    @mapping(
      type: "one2many"
      foreignKey: "homeDepotId"
      foreignKeyReference: "id"
    )
}

type Vehicle @required(type: "CREATE,READ,UPDATE,DELETE", table: "true") {
  id: ID! @constraint(type: "primarykey")
  registrationNumber: String! @constraint(type: "unique")
  type: VehicleType!
  capacityKg: Float! @constraint(type: "check", value: "capacityKg > 0")
  status: VehicleStatus! @constraint(type: "default", value: "AVAILABLE")
  depotId: String
  currentLatitude: Float
  currentLongitude: Float

  depot: Depot
    @mapping(type: "backRef", foreignKey: "id", foreignKeyReference: "depotId")
  assignments: [RouteAssignment]!
    @mapping(
      type: "one2many"
      foreignKey: "vehicleId"
      foreignKeyReference: "id"
    )
}

type Driver @required(type: "CREATE,READ,UPDATE,DELETE", table: "true") {
  id: ID! @constraint(type: "primarykey")
  employeeId: String! @constraint(type: "unique")
  name: String!
  licenceClass: String!
  homeDepotId: String
  status: DriverStatus! @constraint(type: "default", value: "AVAILABLE")

  homeDepot: Depot
    @mapping(
      type: "backRef"
      foreignKey: "id"
      foreignKeyReference: "homeDepotId"
    )
  assignments: [RouteAssignment]!
    @mapping(
      type: "one2many"
      foreignKey: "driverId"
      foreignKeyReference: "id"
    )
}

type Route @required(type: "CREATE,READ,UPDATE,DELETE", table: "true") {
  id: ID! @constraint(type: "primarykey")
  routeCode: String! @constraint(type: "unique")
  originDepotId: String
  destinationAddress: String!
  destinationLatitude: Float!
  destinationLongitude: Float!
  estimatedDurationMinutes: Int!
  distanceKm: Float!

  originDepot: Depot
    @mapping(
      type: "backRef"
      foreignKey: "id"
      foreignKeyReference: "originDepotId"
    )
  stops: [RouteStop]!
    @mapping(type: "one2many", foreignKey: "routeId", foreignKeyReference: "id")
  assignments: [RouteAssignment]!
    @mapping(type: "one2many", foreignKey: "routeId", foreignKeyReference: "id")
}

type RouteStop @required(type: "CREATE,READ,UPDATE,DELETE", table: "true") {
  id: ID! @constraint(type: "primarykey")
  routeId: String
  stopOrder: Int!
  address: String!
  latitude: Float!
  longitude: Float!
  serviceWindowStart: String
  serviceWindowEnd: String

  route: Route
    @mapping(type: "backRef", foreignKey: "id", foreignKeyReference: "routeId")
  deliveries: [Delivery]!
    @mapping(
      type: "one2many"
      foreignKey: "routeStopId"
      foreignKeyReference: "id"
    )
}

type RouteAssignment
  @required(type: "CREATE,READ,UPDATE,DELETE", table: "true") {
  id: ID! @constraint(type: "primarykey")
  routeId: String
  vehicleId: String
  driverId: String
  scheduledDate: String!
  status: AssignmentStatus! @constraint(type: "default", value: "SCHEDULED")
  departedAt: String
  completedAt: String

  route: Route
    @mapping(type: "backRef", foreignKey: "id", foreignKeyReference: "routeId")
  vehicle: Vehicle
    @mapping(
      type: "backRef"
      foreignKey: "id"
      foreignKeyReference: "vehicleId"
    )
  driver: Driver
    @mapping(type: "backRef", foreignKey: "id", foreignKeyReference: "driverId")
  deliveries: [Delivery]!
    @mapping(
      type: "one2many"
      foreignKey: "routeAssignmentId"
      foreignKeyReference: "id"
    )
}

type Delivery @required(type: "CREATE,READ,UPDATE,DELETE", table: "true") {
  id: ID! @constraint(type: "primarykey")
  referenceNumber: String! @constraint(type: "unique")
  routeAssignmentId: String
  routeStopId: String
  weightKg: Float! @constraint(type: "check", value: "weightKg > 0")
  status: DeliveryStatus! @constraint(type: "default", value: "PENDING")
  deliveredAt: String
  signedOffBy: String

  routeAssignment: RouteAssignment
    @mapping(
      type: "backRef"
      foreignKey: "id"
      foreignKeyReference: "routeAssignmentId"
    )
  routeStop: RouteStop
    @mapping(
      type: "backRef"
      foreignKey: "id"
      foreignKeyReference: "routeStopId"
    )
}

enum VehicleType {
  LIGHT_RIGID
  HEAVY_RIGID
  ARTICULATED
  REFRIGERATED
}

enum VehicleStatus {
  AVAILABLE
  IN_SERVICE
  MAINTENANCE
  DECOMMISSIONED
}

enum DriverStatus {
  AVAILABLE
  ON_ROUTE
  ON_LEAVE
  OFF_DUTY
}

enum AssignmentStatus {
  SCHEDULED
  DEPARTED
  IN_PROGRESS
  COMPLETED
  CANCELLED
}

enum DeliveryStatus {
  PENDING
  IN_TRANSIT
  DELIVERED
  FAILED
  RETURNED
}

Custom Resolvers

fleet.custom.graphqls:

graphql
extend type Query {
  getActiveRoutes(date: String!): [RouteAssignment]! @resolver(type: "CUSTOM")
  getAvailableVehicles(depotId: ID!, date: String!): [Vehicle]!
    @resolver(type: "CUSTOM")
  getFleetUtilisation(
    depotId: ID!
    startDate: String!
    endDate: String!
  ): FleetUtilisation! @resolver(type: "CUSTOM")
  getPendingDeliveries(depotId: ID!): [Delivery]! @resolver(type: "CUSTOM")
}

extend type Mutation {
  assignRouteResources(
    routeId: ID!
    vehicleId: ID!
    driverId: ID!
    scheduledDate: String!
  ): RouteAssignment! @resolver(type: "CUSTOM")

  recordDelivery(deliveryId: ID!, signedOffBy: String!): Delivery!
    @resolver(type: "CUSTOM")

  reportDeliveryFailure(deliveryId: ID!, reason: String!): Delivery!
    @resolver(type: "CUSTOM")
}

extend type Subscription {
  onRouteStatusUpdate(depotId: ID!): RouteAssignment!
    @subscriber(type: "CUSTOM")
}

type FleetUtilisation {
  totalVehicles: Int!
  activeVehicles: Int!
  utilisationRate: Float!
  totalDeliveries: Int!
  completedDeliveries: Int!
  onTimeRate: Float!
}

Sample Queries

Get Active Routes for a Depot:

graphql
query {
  getActiveRoutes(date: "2025-04-12") {
    id
    status
    scheduledDate
    departedAt
    route {
      routeCode
      distanceKm
      estimatedDurationMinutes
    }
    vehicle {
      registrationNumber
      type
    }
    driver {
      name
      licenceClass
    }
    deliveries {
      referenceNumber
      status
      weightKg
    }
  }
}

Assign Vehicle and Driver to Route:

graphql
mutation {
  assignRouteResources(
    routeId: "route-syd-north-04"
    vehicleId: "veh-hrt-018"
    driverId: "drv-emp-0042"
    scheduledDate: "2025-04-12"
  ) {
    id
    status
    vehicle {
      registrationNumber
    }
    driver {
      name
    }
    route {
      routeCode
      destinationAddress
    }
  }
}

---

## Complete Schemas from Test Suite

The DDK test suite contains 30+ complete schema examples. Here are the most instructive ones, taken directly from the test files:

### Self-Referencing Many-to-Many

From `_schema/13_self_ref-many2many.graphqls` — demonstrates a self-referencing many-to-many relationship where a `Person` can have multiple friends, also of type `Person`:

```graphql
type Person @required(type: "CREATE,READ,UPDATE,DELETE", table: "true") {
  id: ID! @constraint(type: "primarykey")
  name: String!
  friends: [Person]! @mapping(type: "many2many", foreignKey: "id", foreignKeyReference: "id", mappingTable: "PersonFriend")
}

type PersonFriend @required(type: "CREATE,READ,UPDATE,DELETE", table: "true") {
  PersonID: String
  FriendID: String
}

Primitive Arrays

From _schema/25_primitive_array.graphqls — demonstrates using custom scalar types for array columns stored natively in the database:

graphql
type User @required(type: "CREATE,READ,UPDATE,DELETE", table: "true") {
  id: ID! @constraint(type: "primarykey")
  name: String!
  favouriteNumbers: Int1DArray
  ticTacToeBoard: Bool2DArray
}

Available array scalar types include Int1DArray, String1DArray, Float1DArray, Bool1DArray, Int2DArray, String2DArray, Float2DArray, and Bool2DArray.

Check Constraints

From _schema/6_check_constraints.graphqls — demonstrates applying a check constraint to validate field values at the database level:

graphql
type User @required(type: "CREATE,READ,UPDATE,DELETE", table: "true") {
  id: ID! @constraint(type: "primarykey")
  name: String!
  email: String!
  age: Int @constraint(type: "check", value: "age>0")
}

Multiple Constraints

From _schema/20_multiple_constraints.graphqls — demonstrates stacking multiple constraint directives on a single field:

graphql
type User @required(type: "CREATE,READ,UPDATE,DELETE", table: "true") {
  id: ID! @constraint(type: "primarykey")
  name: String! @constraint(type: "notnull") @constraint(type: "unique")
  email: String! @constraint(type: "notnull") @constraint(type: "unique")
  isActive: Boolean @constraint(type: "default", value: "false")
  age: Int @constraint(type: "default", value: "18")
}

Custom Resolvers

From the _19_custom_resolvers/ test directory — demonstrates the ORM schema paired with custom resolver definitions:

19_custom_resolvers.orm.graphqls:

graphql
type User @required(type: "CREATE,READ,UPDATE,DELETE", table: "true") {
  id: ID! @constraint(type: "primarykey")
  name: String!
  email: String!
}

19_custom_resolvers.custom.graphqls:

graphql
extend type Query {
  getUserByEmail(email: String!): User @resolver(type: "CUSTOM")
  getString: String @resolver(type: "CUSTOM")
  getReqString: String! @resolver(type: "CUSTOM")
}

extend type Mutation {
  createUserByEmail(name: String!, email: String!): User
    @resolver(type: "CUSTOM")
  updateUserByEmail(name: String!, email: String!): User
    @resolver(type: "CUSTOM")
}

extend type Subscription {
  subListUsers: [User] @subscriber(type: "CUSTOM")
}

Back References

From _schema/23_back_references.graphqls — demonstrates using backRef mappings to navigate relationships from the child side:

graphql
type User @required(type: "CREATE,READ,UPDATE,DELETE", table: "true") {
  id: ID! @constraint(type: "primarykey")
  name: String!
  contacts: [Contact]!
    @mapping(type: "one2many", foreignKey: "userId", foreignKeyReference: "id")
}

type Contact @required(type: "CREATE,READ,UPDATE,DELETE", table: "true") {
  id: ID! @constraint(type: "primarykey")
  userId: String
  phone: String
  myUser: User!
    @mapping(type: "backRef", foreignKey: "id", foreignKeyReference: "userId")
}

User documentation for Optimal Reality