Kysoql

Introduction

Generate schema-aware Kysoql types from Salesforce Describe metadata.

@kysoql/codegen reads Salesforce metadata and generates the TypeScript schema Kysoql uses to validate queries.

That schema reflects your org. Custom fields, relationship names, field capabilities, picklist values, and supported object features can all affect what TypeScript allows you to build.

Install

For the usual CLI workflow, keep codegen as a development dependency and core as an application dependency:

pnpm add @kysoql/core
pnpm add -D @kysoql/codegen

Install @kysoql/codegen as a normal dependency only when your runtime code calls its library API.

Configure generation

A small config is enough to choose the objects you want:

kysoql.config.ts
import { defineConfig } from "@kysoql/codegen";

export default defineConfig({
  objects: ["Account", "Contact", "User"],
  schemaName: "SalesforceSchema",
});

The generator also needs a Salesforce session provider through config auth or the --auth CLI option. See configuration for a complete example.

Run:

pnpm exec kysoql generate

If the project has a src directory, the default output is src/kysoql/salesforce.generated.ts. Otherwise the generated file is written to kysoql/salesforce.generated.ts.

Keep the schema focused when you need to

By default, selected objects keep all described fields. For very large objects, field filtering lets you generate an exact include or exclude set without pretending that the omitted fields no longer exist in Salesforce.

Continue with schema generation for CLI and library workflows.

On this page