Natural language to any query language, starting with GraphQL
Maintained. Last release 3 months ago, commits in 3 of the last 26 weeks. Weaker on commit activity and contributor spread.
pip install text2qltext2ql
Natural-language to query-language toolkit for GraphQL and SQL.
text2ql is built for practical usage: deterministic generation, LLM-assisted generation, schema/mapping normalization, evaluation utilities, and benchmark adapters (Spider/BIRD).
Current first-class targets are GraphQL and SQL; planned future targets include JSONata, jq-style queries, Cypher, and dialect-focused SQL paths (PostgreSQL, MySQL, and more).
Why teams use it
- Fast path from text -> query for GraphQL and SQL.
- Three generation modes:
deterministic,llm,function_calling. - Schema + mapping aware generation with validation and confidence scoring.
- Built-in dataset ingestion, synthetic rewrites, and evaluation hooks.
- Built-in Spider/BIRD benchmark loaders and runner.
Install
Python: >=3.10
pip install text2ql
Optional extras:
# Streamlit playground
pip install "text2ql[app]"
# SQL execution backend support (SQLAlchemy)
pip install "text2ql[sql]"
# Local development tools
pip install -e ".[dev]"
Quick Start (CLI)
- Deterministic GraphQL:
text2ql "show top 5 client records with mail state enabled" \
--target graphql \
--schema '{"entities":["customers"],"fields":{"customers":["id","email","status"]}}' \
--mapping '{"entities":{"client":"customers"},"fields":{"mail":"email"},"filters":{"state":"status"},"filter_values":{"status":{"enabled":"active"}}}'
- Deterministic SQL:
text2ql "show customers highest total first 5 offset 10" \
--target sql \
--schema '{"entities":["customers"],"fields":{"customers":["id","total","status"]}}'
- LLM mode:
export OPENAI_API_KEY=...
text2ql "show latest 5 orders with status active" \
--target sql \
--mode llm \
--llm-model gpt-4o-mini \
--schema '{"entities":["orders"],"fields":{"orders":["id","status","createdAt"]}}'
- Function-calling / structured output mode: