Scalars
Built-In Scalars
The first step in our workflow is creating the uniform types
that will serve as the building blocks for our api. These will serve two purposes: GraphQL
schema generation, and compile time type safety for our resolvers. Let's begin with the built-in scalars. Uniform GraphQL
ships with 5 built-in scalars:
Uniform GraphQL | TypeScript | GraphQL |
---|---|---|
t.string | string | String! |
t.float | number | Float! |
t.int | number | Int! |
t.id | string \| number | ID! |
t.boolean | boolean | Boolean! |
Custom Scalars
Use the t.scalar
type factory to create custom scalars, which will carry both runtime and compile time type information just like any other type in our system.