~refi64/edgeql-typegen

Types generator for edgeql-queries
e6d5694c — Ryan Gonzalez 2 years ago
Update deps
50a4c428 — Ryan Gonzalez 3 years ago
Initial

refs

main
browse  log 

clone

read-only
https://git.sr.ht/~refi64/edgeql-typegen
read/write
git@git.sr.ht:~refi64/edgeql-typegen

You can also use your local clone with git send-email.

#edgeql-typegen

builds.sr.ht status

EXPERIMENTAL types generator for use with edgeql-queries.

#Installation

Add it to your project's development dependencies via Poetry:

$ poetry add -D git+https://git.sr.ht/~refi64/edgeql-typegen

or just add it to your venv:

$ pip install git+https://git.sr.ht/~refi64/edgeql-typegen

#Usage

$ edgeql-typegen queries.edgeql queries.py

(Using - for the input or output will use stdin/stdout, respectively.)

This will generate a module with a Queries type inside it that can be used to run async queries:

import query_types
queries: query_types.Queries = edgeql_queries.from_path('input-queries.edgeql')

You can use --format-command COMMAND to send the generated file to the given command's stdin, then save the command's stdout, i.e. "piping" the output through your formatter. For example:

# Format via black & arrange imports via isort
$ edgeql-typegen --format-command 'black -q - | isort -' queries.edgeql query_types.py

#Contributing

#Submitting Patches

Please see the guide for submitting patches on git.sr.ht. (If you choose to use git send-email, the patches should be sent to ~refi64/edgeql-typegen-devel@lists.sr.ht.)

#Local Development

Install Poetry, then poetry install to install all the dependencies.

#Code Style and Testing

# An updated fork of blue (https://github.com/grantjenks/blue) used for formatting:
$ poetry run blue
# Run linting:
$ poetry run poe flake8
# Run type checking:
$ poetry run poe mypy
# Run unit tests:
$ poetry run poe test
# Run all of the above:
$ poetry run poe check

.vscode/ contains a pre-configured VSCode workspace with all settings set properly for this project.

#Major TODOs

  • Support non-async queries
  • Maybe generate the query-running code ourselves?
  • Contribute better stubs to EdgeDB & use those in the generated types
    • Related: better enum support (more Literal support somewhere?)
  • Make sure pyright works (and stays working)
Do not follow this link