Schemas
Schema Types
Available data types for Orionjs schemas
Orionjs supports a variety of data types for schema definitions. This guide explains all available types and how to use them.
Basic Types
The most common types are directly mapped from JavaScript/TypeScript types:
Special Types
Orionjs supports special types for common use cases:
Array Types
Define arrays using TypeScript array syntax or the type option:
Nested Schema Types
You can use other schemas as types for nested structures:
Enum Types
For fields with a limited set of allowed values, use the createEnum
function:
Using createEnum
provides type safety throughout your application:
- TypeScript knows exactly which values are allowed
- The schema validation ensures only valid enum values are accepted
- GraphQL will expose the enum as a proper GraphQL enum type
Custom Types
You can create custom types by extending existing ones:
Optional Types
Make any field optional using the optional parameter:
Was this page helpful?