Skip to content

CLI Reference

Complete reference for the fraiseql command-line interface.

Terminal window
cargo install fraiseql-cli

FraiseQL ships as a single binary named fraiseql. It covers the full lifecycle in two phases:

  1. Schema authoring — compile, extract, lint, validate, and analyze your schema
  2. Runtime serving — compile and serve the GraphQL API in a single step with fraiseql run
Terminal window
fraiseql <SUBCOMMAND> [OPTIONS] [ARGUMENTS]

Compile the schema and immediately start the GraphQL server. This is the command you will use most often — it compiles the schema in-memory (no disk artifact) and starts the HTTP server. With --watch, the server hot-reloads whenever the schema file changes.

Terminal window
fraiseql run [OPTIONS] [INPUT]

Arguments:

  • INPUT — Schema file or fraiseql.toml (default: fraiseql.toml)

Options:

OptionDefaultDescription
--database <URL>$DATABASE_URLPostgreSQL connection string
--port <PORT>8080HTTP port to listen on
--bind <ADDR>0.0.0.0Bind address
--watchoffHot-reload when schema file changes
--introspectionoffEnable GraphQL introspection endpoint

Examples:

Terminal window
# Start with defaults (reads fraiseql.toml)
fraiseql run
# Specify database and config explicitly
fraiseql run fraiseql.toml --database postgres://localhost/mydb
# Development mode with hot-reload
fraiseql run --port 3000 --watch
# Enable introspection from a pre-compiled schema
fraiseql run schema.json --introspection

Expected output:

$ fraiseql run
🍓 FraiseQL v2.0.0
GraphQL endpoint: http://localhost:8080/graphql
Health check: http://localhost:8080/health
Schema: 3 types, 5 queries, 3 mutations
Database: PostgreSQL (pool: 2 connections)
Press Ctrl+C to stop

Compile the schema to schema.compiled.json. Use this when you need the compiled artifact on disk — for example, to commit it to version control or to inspect it before deployment.

Terminal window
fraiseql compile [OPTIONS] [INPUT]

Arguments:

  • INPUT — Schema file or directory (default: fraiseql.toml)

Options:

OptionDefaultDescription
-o, --output <FILE>schema.compiled.jsonOutput file path
--checkoffValidate only; do not write output
--database <URL>$DATABASE_URLValidate against live database schema
-v, --verboseoffVerbose output

Examples:

Terminal window
# Compile from fraiseql.toml
fraiseql compile
# Compile a specific schema file to a custom output path
fraiseql compile schema.json -o compiled.json
# Validate without writing (useful in CI)
fraiseql compile --check
# Validate against the database schema
fraiseql compile --check --database "$DATABASE_URL"

Expected output:

$ fraiseql compile
✓ Schema validated (3 types, 2 inputs, 5 queries, 3 mutations)
✓ SQL views verified against database
✓ Compiled to build/schema.compiled.json (0.4s)

fraiseql compile --watch monitors schema files and recompiles on change:

  • Watches: schema files, fraiseql.toml, db/schema/*.sql
  • On file change: recompiles and reports errors without exiting
  • Useful during development alongside fraiseql run --watch
Terminal window
# Recompile on every schema change
fraiseql compile --watch
# Serve with hot-reload (run handles watch internally)
fraiseql run --watch

Extract a FraiseQL schema from annotated source files. Supports Python, TypeScript, Go, and other languages that use FraiseQL annotations.

Terminal window
fraiseql extract [OPTIONS] [INPUT]

Arguments:

  • INPUT — Source file or directory to scan for annotations

Options:

OptionDescription
-o, --output <FILE>Output schema file
--format <FMT>Output format

Example:

Terminal window
# Extract schema from an annotated Python module
fraiseql extract src/models.py -o schema.json

Show the SQL execution plan that FraiseQL generates for a given GraphQL query. Useful for understanding and optimizing query behavior.

Terminal window
fraiseql explain [OPTIONS] <QUERY>

Arguments:

  • QUERY — GraphQL query string or path to a .graphql file

Options:

OptionDescription
--schema <FILE>Compiled schema (default: schema.compiled.json)
--variables <JSON>Query variables as a JSON string
--format <FMT>Output format: sql, plan, json

Examples:

Terminal window
# Show the generated SQL for a simple query
fraiseql explain "{ users { id name } }"
# With variables
fraiseql explain "query(\$id: ID!) { user(id: \$id) { name } }" \
--variables '{"id": "123"}'
# Show the full execution plan from a query file
fraiseql explain query.graphql --format plan

Calculate the complexity score for a GraphQL query. Use this in CI to enforce query cost limits before deployment.

Terminal window
fraiseql cost [OPTIONS] <QUERY>

Arguments:

  • QUERY — GraphQL query string or path to a .graphql file

Options:

OptionDescription
--schema <FILE>Compiled schema
--max-cost <N>Exit with a non-zero code if cost exceeds N
--jsonMachine-readable JSON output

Examples:

Terminal window
# Check cost of a deeply nested query
fraiseql cost "{ users { posts { comments { id } } } }"
# Enforce a cost budget in CI
fraiseql cost query.graphql --max-cost 100

Analyze the schema for optimization opportunities across performance, security, federation, complexity, caching, and indexing categories.

Terminal window
fraiseql analyze [OPTIONS] [SCHEMA]

Arguments:

  • SCHEMA — Compiled schema file (default: schema.compiled.json)

Options:

OptionDescription
--category <CAT>Filter: performance, security, federation, complexity, caching, indexing
--jsonMachine-readable JSON output
--verboseInclude detailed recommendations

Examples:

Terminal window
# Full analysis with recommendations
fraiseql analyze schema.compiled.json
# Security-focused analysis
fraiseql analyze --category security --verbose

Visualize the type dependency graph of a compiled schema. Output can be piped into Graphviz, Mermaid, or D2 for rendering.

Terminal window
fraiseql dependency-graph [OPTIONS] [SCHEMA]

Arguments:

  • SCHEMA — Compiled schema file (default: schema.compiled.json)

Options:

OptionDescription
--format <FMT>Output format: json, dot, mermaid, d2, console
--output <FILE>Write output to file instead of stdout
--show-cyclesHighlight circular dependencies
--unusedInclude unused types in the graph

Examples:

Terminal window
# Quick console view
fraiseql dependency-graph
# Graphviz DOT for rendering as a PNG
fraiseql dependency-graph --format dot -o deps.dot
dot -Tpng deps.dot -o deps.png
# Mermaid diagram (paste into Markdown)
fraiseql dependency-graph --format mermaid

Check the schema for design issues. Audits cover federation, cost, caching, authorization, and compilation correctness.

Terminal window
fraiseql lint [OPTIONS] [SCHEMA]

Arguments:

  • SCHEMA — Schema file (default: fraiseql.toml or schema.compiled.json)

Options:

OptionDescription
--audit <AUDIT>Audit category: federation, cost, cache, auth, compilation
--fail-on <LEVEL>Exit non-zero on: critical, warning, all
--fixAuto-fix issues where possible
--jsonMachine-readable JSON output

Examples:

Terminal window
# Run all lint checks
fraiseql lint
# Auth audit only, fail on any warning
fraiseql lint --audit auth --fail-on warning
# Auto-fix and verify in CI
fraiseql lint --fix --fail-on critical

Validate the structural correctness of a schema file. Optionally connects to the database to cross-check table and column references.

Terminal window
fraiseql validate [OPTIONS] [SCHEMA]

Arguments:

  • SCHEMA — Schema file to validate

Options:

OptionDescription
--strictTreat warnings as errors
--database <URL>Validate against a live database
--jsonMachine-readable JSON output

Examples:

Terminal window
# Basic structural validation
fraiseql validate schema.json
# Strict mode with database cross-check
fraiseql validate --strict --database "$DATABASE_URL"

Expected output:

$ fraiseql validate
✓ fraiseql.toml is valid
✓ Database connection successful
✓ Schema compiles without errors
✓ All views exist in database

Generate SQL DDL statements for Arrow views derived from the compiled schema.

Terminal window
fraiseql generate-views [OPTIONS] [SCHEMA]

Arguments:

  • SCHEMA — Compiled schema file

Options:

OptionDescription
-o, --output <FILE>Output SQL file
--refresh <STRATEGY>Refresh strategy: trigger, scheduled
--include <PATTERNS>Include only views matching a pattern (e.g. va_*, tv_*)

Examples:

Terminal window
# Generate all views to a SQL file
fraiseql generate-views -o views.sql
# Arrow views only, with trigger-based refresh
fraiseql generate-views --include "va_*" --refresh trigger -o arrow_views.sql

Connect to a PostgreSQL database and discover fact tables, then emit a schema stub.

Terminal window
fraiseql introspect [OPTIONS]

Options:

OptionDescription
--database <URL>PostgreSQL connection string
--output <FORMAT>Output format: python, json
--tables <PATTERN>Table name pattern (default: tf_*)

Examples:

Terminal window
# Discover all fact tables in the database
fraiseql introspect --database "$DATABASE_URL"
# Emit a Python schema stub
fraiseql introspect --database "$DATABASE_URL" --output python > facts.py

Generate source files (client types, SDK stubs) from a compiled schema.

Terminal window
fraiseql generate [OPTIONS] [SCHEMA]

Arguments:

  • SCHEMA — Compiled schema file

Options:

OptionDescription
--language <LANG>Target language for generated code
--output <DIR>Output directory
--types-onlyGenerate type definitions only, no resolvers

Scaffold a new FraiseQL project with a starter fraiseql.toml, schema stub, and migration directory.

Terminal window
fraiseql init [OPTIONS] [NAME]

Arguments:

  • NAME — Project name (default: current directory name)

Options:

OptionDescription
--template <TPL>Starter template
--database <URL>Pre-fill database URL in config
--sdk <SDK>Include SDK for a specific language

Example:

Terminal window
fraiseql init my-api --database postgres://localhost/mydb

Manage database migrations via the bundled confiture migration tool.

Terminal window
fraiseql migrate <SUBCOMMAND> [OPTIONS]

Subcommands:

SubcommandDescription
upApply pending migrations
downRoll back the last migration
statusShow applied and pending migrations
create <NAME>Create a new migration file

Examples:

Terminal window
# Apply all pending migrations
fraiseql migrate up
# Check migration status
fraiseql migrate status
# Create a new migration
fraiseql migrate create add_user_table

Generate a Software Bill of Materials for the schema, listing all types, fields, and their data lineage.

Terminal window
fraiseql sbom [OPTIONS] [SCHEMA]

Arguments:

  • SCHEMA — Compiled schema file

Validate a trusted documents manifest — checks that the file is well-formed JSON and that every key is a valid SHA-256 hex string matching its query body hash.

Terminal window
fraiseql validate-documents <MANIFEST>

Arguments:

  • MANIFEST — Path to the trusted documents manifest JSON file

Examples:

Terminal window
# Validate the manifest before deploying
fraiseql validate-documents trusted-documents.json
# Use in CI to catch manifest errors early
fraiseql validate-documents ./manifests/trusted-documents.json && echo "Manifest OK"

Exit codes:

  • 0 — Manifest is valid
  • 1 — Manifest has structural errors or hash mismatches
  • 2 — File not found or not valid JSON

See Trusted Documents for the manifest format.


All commands support the following options:

OptionDescription
-h, --helpShow help for the command
-V, --versionPrint the fraiseql version

CodeMeaning
0Success
1Validation or compilation error
2Configuration error
3Database connection error

VariableDescription
DATABASE_URLPostgreSQL connection string (overrides [database] url)
FRAISEQL_REQUIRE_REDIS=1Refuse to start if PKCE state or rate limiting is using in-memory storage. Recommended for Kubernetes and other multi-replica deployments — catches misconfiguration at startup rather than at request time.
FRAISEQL_MCP_STDIO=1Start the MCP (Model Context Protocol) server in stdio transport mode instead of HTTP. Used for Claude Desktop and other local MCP clients. Requires the server to be compiled with --features mcp.

Most commands read fraiseql.toml when no explicit input is provided. A minimal configuration:

[project]
name = "my-api"
version = "1.0.0"
[database]
url = "${DATABASE_URL}"
[server]
host = "0.0.0.0"
port = 8080

Pass the path explicitly to any command that accepts [INPUT] or [SCHEMA] if your config file is not named fraiseql.toml.

TaskCommand
Start development serverfraiseql run --watch
Compile for productionfraiseql compile --check
Validate schemafraiseql validate --strict
Check query costfraiseql cost query.graphql --max-cost 100
Analyze performancefraiseql analyze --category performance
Generate client typesfraiseql generate --language typescript
Run migrationsfraiseql migrate up
Terminal window
# Typical CI pipeline
fraiseql validate # Validate configuration
fraiseql compile --check # Compile and validate schema
fraiseql lint --fail-on warning # Run all audits
fraiseql test # Run tests (if configured)
fraiseql migrate up # Apply migrations
fraiseql run # Start server
  1. Check CLI is installed:

    Terminal window
    fraiseql --version

    Expected output:

    fraiseql 2.0.0
  2. Validate a configuration file:

    Terminal window
    fraiseql validate

    Expected output:

    ✓ fraiseql.toml is valid
    ✓ Database connection successful
    ✓ Schema compiles without errors
  3. Compile a schema:

    Terminal window
    fraiseql compile --check

    Expected output:

    ✓ Schema validated (3 types, 2 inputs, 5 queries, 3 mutations)
    ✓ SQL views verified against database
    ✓ Compilation successful
  4. Test explain command:

    Terminal window
    fraiseql explain "{ __typename }" --format sql

    Expected output:

    -- Generated SQL for query
    SELECT 'Query' as typename;
  5. Start the server:

    Terminal window
    fraiseql run &
    # Test the health endpoint
    curl http://localhost:8080/health

    Expected response:

    {"status": "ok"}
  6. Run a lint check:

    Terminal window
    fraiseql lint --fail-on warning

    Expected output:

    ✓ Federation audit passed
    ✓ Cost audit passed
    ✓ Cache audit passed
    ✓ Auth audit passed
    ✓ Compilation audit passed
Terminal window
$ fraiseql
-bash: fraiseql: command not found

Solutions:

  1. Ensure binary is in PATH: export PATH="$HOME/.cargo/bin:$PATH"
  2. Reinstall: cargo install fraiseql-cli
  3. Use full path: ~/.cargo/bin/fraiseql
Terminal window
$ fraiseql compile
Error: Schema compilation failed

Check:

  1. Schema syntax is valid
  2. All referenced types exist
  3. Database connection is working (if using --database)
  4. SQL views exist in database
Terminal window
$ fraiseql run
Error: Cannot connect to database

Solutions:

  1. Verify DATABASE_URL is set correctly
  2. Check database is running: pg_isready -d $DATABASE_URL
  3. Test connection manually: psql $DATABASE_URL -c "SELECT 1"
Terminal window
$ fraiseql run
Error: Address already in use (os error 48)

Solutions:

  1. Use a different port: fraiseql run --port 8081
  2. Find and kill the process using the port
  3. Check what’s listening: lsof -i :8080