Define Types
Object and input types as decorated classes, with the schema generated from your code.
GraphQL types in Base are classes. Each @GqlField becomes a schema field; the SDL is generated from what you write, so schema and code cannot drift.
Object types
- The thunk (
() => String) declares the GraphQL type; arrays use() => [Type]. - Nullability must match the TypeScript type —
{ nullable: true }pairs with| null, and Base'sgql-nullable-paritylint rule enforces the agreement. The schema never promises more than the types do. - Unlike ORM entities, GraphQL type classes are plain: no
declare, no base class.
Input types
Inputs get their own decorator, and can carry validation, which runs before your resolver sees the data:
The argument to @GqlInputType is the schema name. A single class can even serve as both shapes — stack @GqlObjectType() and @GqlInputType('TesterInput') on one class when the output and input shapes genuinely coincide.
Nesting
Fields reference other type classes through the same thunk form:
The generated schema mirrors the class graph. When you're ready to serve these types, head to Write Resolvers.