CLI TOOLING · UPDATED NOV 29, 2026

CLI Codegen: Generating Typed GraphQL Schemas

Because GQless derives GraphQL queries from property accesses at runtime, the client needs a lightweight runtime schema map alongside TypeScript interfaces. The CLI inspects your GraphQL server via standard GraphQL Introspection and writes both files in one pass.

1. Running Code Generation

npx gqless generate
# or watch local .graphql SDL files during development
npx gqless generate --watch

2. Generated File Layout

FilePurposeCommitted to Git?
schema.generated.tsTypeScript interfaces, enums, input types, and compact runtime field metadataYes (recommended for CI)
index.tsPre-wired createClient() instance and custom queryFetcherYes (user-editable)
Custom headers & auth tokens: If your staging GraphQL endpoint requires an API key or bearer header during introspection, define them in gqless.config.cjs rather than hard-coding secrets in npm scripts.

3. Keeping Bundles Small

The emitted generatedSchema object stores only field type pointers and argument signatures—stripping descriptions and deprecation notes by default. Once generated, pass the schema directly into your core client instance and tune caching behavior via ClientOptions.