Generate typed clients from your live Hasura schema in TypeScript, Dart, Swift, Kotlin, and Python.
# Generate TypeScript types into ./src/generated/
nself generate --lang typescript --out ./src/generated
# Generate Dart types for a Flutter app
nself generate --lang dart --out ./lib/generated
# Generate all languages at once
nself generate --lang all --out ./generatednself generate [FLAGS]nself generate introspects the live Hasura GraphQL schema and generates fully-typed client code for every language your stack uses. Generated types cover all tables, relationships, insert/update inputs, and subscription types that Hasura exposes. Hooks (React Query, SWR) are generated alongside TypeScript types.
The command connects to the Hasura instance in the active environment. It uses the Hasura admin secret from your environment configuration — no extra credentials required. The generated output is deterministic: running generate twice against the same schema produces byte-identical output.
--watch mode keeps the process running and re-generates whenever the Hasura schema changes. This is useful during development when you are adding tables or updating column types.
--operations also generates typed operation documents (queries, mutations, subscriptions) from any .graphql files found in the output directory.
| Flag | Type | Default | Description |
|---|---|---|---|
--lang | string | typescript | Target language(s): typescript, dart, swift, kotlin, python, all |
--out | string | ./generated | Output directory. For --lang all, a subdirectory per language is created |
--env | string | active | Hasura source environment: local, staging, prod |
--watch | bool | false | Re-generate on schema change (polls Hasura every 2 seconds) |
--operations | bool | false | Also generate typed operation documents from .graphql files in --out |
--no-hooks | bool | false | Skip React Query / SWR hook generation (TypeScript only) |
--pydantic | bool | false | Generate Pydantic v2 models instead of plain dataclasses (Python only) |
generated/
types.ts # All table types, input types, enums
operations.ts # Typed query/mutation/subscription documents (--operations)
hooks.ts # React Query / SWR hooks (unless --no-hooks)generated/
models.dart # Dart classes with fromJson / toJson
queries.dart # GraphQL operation strings as Dart constantsgenerated/
Models.swift # Swift structs conforming to Codable
Operations.swift # Apollo-compatible operation definitionsgenerated/
Models.kt # Kotlin data classes with kotlinx.serialization annotations
Operations.kt # Apollo-compatible operation definitionsgenerated/
models.py # Pydantic v2 models (--pydantic) or plain dataclasses
operations.py # Typed operation helpersnself generate --lang typescript --out ./src/lib/generated
# Produces types.ts and hooks.ts ready for importnself generate --lang dart --out ./lib/generated
# Add generated/ to .gitignore — regenerate on schema changenself generate --lang all --out ./clients
# clients/typescript/, clients/dart/, clients/swift/, etc.nself generate --lang typescript --out ./src/generated --watch
# Re-generates automatically as you add tables or columns in Hasura# Place your .graphql operation files in ./src/generated/
nself generate --lang typescript --out ./src/generated --operationsnself generate --lang typescript --env staging --out ./src/generated-stagingnself generate --lang python --pydantic --out ./app/modelsnself generate --lang typescript --no-hooks --out ./src/generatedNSELF_ENV — default source environment when --env is not specifiedHASURA_GRAPHQL_ADMIN_SECRET — used to authenticate the introspection query; loaded from the active env file automaticallyHASURA_GRAPHQL_ENDPOINT — override the Hasura endpoint URL0 — success1 — generic error (Hasura unreachable, schema introspection failed)2 — invalid arguments or unsupported language