edgedb / edgedb-python

The official Python client library for EdgeDB
https://edgedb.com
Apache License 2.0
369 stars 45 forks source link

[PoC] Codegen #360

Closed fantix closed 2 years ago

fantix commented 2 years ago

Put *.edgeql files under project directory, and run:

python -m edgedb.codegen

Generated code would require #359 to run properly in FastAPI.

This PR generates JSON Schema from Parse response as an intermediate result, using codec instructs copied from the EdgeDB server, so that we could easily migrate to a future codegen frontend. The JSON Schema looks like this (example from #359):

{"$schema": "https://json-schema.org/draft/2020-12/schema",
 "definitions": {"role": {"properties": {"id": {"type": "std::uuid"},
                                         "name": {"type": "string"}},
                          "type": "object"},
                 "user": {"properties": {"id": {"type": "std::uuid"},
                                         "name": {"type": "string"},
                                         "role": {"$ref": "#/definitions/role"}},
                          "type": "object"}},
 "properties": {"input": {"type": "null"},
                "output": {"items": {"$ref": "#/definitions/user"},
                           "type": "array"}},
 "type": "object"}
fantix commented 2 years ago

Close in favor of #363