Advanced Topics
Enums, Security & Public APIs
Beyond core data modeling, GDL provides the tools to define typed constants and fine-tune the granular security of your API endpoints.
The Typed Truth: Enums
Enums (Enumerated Types) allow you to define a fixed set of allowed values for a field. GDL enums are high-fidelity, generating Go string-enums, Protobuf enums, and GraphQL enums simultaneously.
enum OrderStatus {
PENDING,
SHIPPED,
DELIVERED,
CANCELLED
}
entity Order {
OrderStatus status required
datetime orderDate
}
Public / Open Entities
By default, all GO-DUCK endpoints require a valid Keycloak JWT. The `open` keyword allows you to selectively disable authentication for specific entities with action-level granularity.
open EntityName
Disables authentication for ALL actions (Read, Create, Update, Delete) on the entity. Caution: Use with care!
open Entity(read, create)
Surgical precision. For example, allowing public read and create while requiring admin JWT for updates/deletes.
entity Article {
string(255) title required
text content
ArticleStatus status
}
// Allow public reading of articles, but require JWT for mutations
open Article(read)