Gen AI GraphQL response mocking via @mock directive.
The @mock directive specification lives in docs/mock-specification.md.
mockql lets you annotate a GraphQL operation with @mock and generate only the mocked portions with an LLM provider.
The upstream GraphQL server does not need to define the @mock directive. mockql decorates the schema with it automatically while loading it (locally or via introspection).
Depending on where @mock appears, mockql will:
- Pass the operation straight through to the upstream GraphQL server
- Generate the full response with an LLM provider
- Fetch real upstream data for non-mocked fields, then merge in generated mock data for mocked fields
crates/mockql-core: Core cratecrates/mockql-cli: CLI crate andmockqlbinarydocs/mock-specification.md:@mockdirective semanticsdocs/provider-cli.md: provider prerequisites and exact CLI integration detailsdocs/provider-http.md: provider prerequisites and exact CLI integration detailsexamples/swapi: SWAPI GraphQL examplesexamples/countries: Countries GraphQL examples
- One supported provider CLI installed and available on
PATHclaudecodexopencode
- Or an HTTP-backed provider with credentials.
github-copilot(requiresGITHUB_TOKENenv variable)
cargo build -p mockqlRun the binary with:
cargo run -p mockql-cli -- --helpOr directly after building:
./target/debug/mockql --helpExecute a single GraphQL operation and print the response to stdout.
mockql oneshot --operation <file.graphql> --graphql-url <https://example.com/graphql> [options] cli|httpstart an HTTP proxy server that listens for GraphQL requests, exposing a graphiql interface at http://localhost:<port>/graphiql.
mockql proxy --port <port> --graphql-url <https://example.com/graphql> [options] cli|httpLoad and print the decorated GraphQL schema with @mock directive
mockql schema (--schema <schema.graphql> | --graphql-url <https://example.com/graphql>) [options]cargo run -p mockql-cli -- oneshot \
--operation ./examples/swapi/partial-list-items.graphql \
--variables ./examples/swapi/partial-list-items.json \
--graphql-url https://swapi-graphql.netlify.app/graphql \
cli --provider codex --model gpt-5.4-minicargo run -p mockql-cli -- oneshot \
--operation ./examples/swapi/partial-list-items.graphql \
--variables ./examples/swapi/partial-list-items.json \
--graphql-url https://swapi-graphql.netlify.app/graphql \
cli --provider opencode --model github-copilot/gemini-3-flash-previewcargo run -p mockql-cli -- oneshot \
--operation ./examples/countries/contextual-hint.graphql \
--variables ./examples/countries/contextual-hint.json \
--graphql-url https://countries.trevorblades.com/ \
cli --provider codex --model gpt-5.4-miniFor more example commands, see: