Skip to Content
SchemaConventions

Schema Definition

gqlkit generates GraphQL schema from your TypeScript types. All exported types from src/gqlkit/schema/ are automatically scanned and converted to GraphQL types.

Type Mapping

gqlkit maps TypeScript types to GraphQL types as follows:

TypeScriptGraphQL
stringString!
numberFloat!
booleanBoolean!
IDString, IDNumberID!
Int (branded)Int!
Float (branded)Float!
T | nullT (nullable)
T[][T!]!
String literal unionEnum type
TypeScript enumEnum type
Union of object typesUnion type
*Input suffix typesInput Object type
Union with *Input suffix@oneOf input object
GqlInterface<T>Interface type
GqlScalar<Name, Base>Custom scalar
NoArgsIndicates resolver takes no arguments

Naming Conventions

gqlkit generates type names using predictable conventions:

For defineQuery, defineMutation, and defineField, GraphQL field names are also derived from exported variable names:

  • Default: the full export name is used as-is.
  • If the export name contains $, gqlkit uses the substring after the last $.
  • Common usage is a single prefix (for example, Query$users -> users).
  • If the export name ends with $, gqlkit reports an error.
ContextPatternExample
Object field (inline){ParentType}{Field}User.profileUserProfile
Input field (inline){ParentWithoutInput}{Field}InputCreateUserInput.addressCreateUserAddressInput
Query/Mutation arg{Resolver}{Arg}InputsearchUsers(filter)SearchUsersFilterInput
Field resolver arg{Parent}{Field}{Arg}InputUser.posts(filter)UserPostsFilterInput
Inline enumSame as parent contextUser.statusUserStatus
Payload type{Resolver}PayloadupdateUserUpdateUserPayload

For complete details on inline enum naming, see Inline Enums.

Project Layout

Default project layout:

src/ gqlkit/ schema/ # Types and resolvers co-located __generated__/ # Generated files (auto-created)

All TypeScript files (.ts, .cts, .mts) under src/gqlkit/schema/ are scanned for types and resolvers.

Last updated on