> ## Documentation Index
> Fetch the complete documentation index at: https://fastql.vachagan.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# CLI

> Load and serve a FastQL schema from a Python module.

The CLI loads a schema target in `module:attribute` form.

```bash theme={null}
python -m fastql serve examples.app:schema \
  --host 127.0.0.1 \
  --port 7691 \
  --path /graphql
```

Use `--context module:attribute` to supply a context factory. The factory can be
synchronous or asynchronous and is called once per GraphQL request.

```bash theme={null}
python -m fastql serve myapp.schema:schema \
  --context myapp.context:create_context
```

Run `python -m fastql --help` for the current argument list. Import failures and
missing attributes are reported before the server starts.

## `export-schema`

Write a built schema's SDL or introspection JSON, to a file or stdout.

```bash theme={null}
python -m fastql export-schema myapp.schema:schema                 # SDL to stdout
python -m fastql export-schema myapp.schema:schema --format json   # introspection JSON
python -m fastql export-schema myapp.schema:schema --output schema.graphql
```

The target is a `module:attribute` path to a `Schema`. `--format` is `sdl`
(default) or `json`; `--output` writes a file instead of stdout. An unresolvable
target exits non-zero.
