You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/reference/using/python/api/codegen.rst
+56-23Lines changed: 56 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,17 +6,34 @@ Code Generation
6
6
7
7
.. py:currentmodule:: gel
8
8
9
-
The ``gel-python`` package exposes a command-line tool to generate typesafe functions from ``*.edgeql`` files, using :py:mod:`dataclasses` for objects primarily.
9
+
The ``gel-python`` package exposes a command-line tool to generate various kinds of type-safe code from EdgeQL queries and your schema:
10
+
11
+
- ``queries``: typesafe functions from ``*.edgeql`` files, using :py:mod:`dataclasses` for objects primarily.
12
+
- ``models``: a programmatic query-builder and Pydantic-based models generator.
10
13
11
14
.. code-block:: bash
12
15
13
-
$ gel-py
16
+
$ uvx gel generate py/queries
17
+
$ uvx gel generate py/models
14
18
15
-
Or alternatively:
19
+
The :gelcmd:`generate` commands supports the same set of :ref:`connection options <ref_cli_gel_connopts>` as the ``gel`` CLI.
$ gel generate py/queries --target async # generate async function (default)
72
+
$ gel generate py/queries --target blocking # generate blocking code
56
73
57
74
The names of the generated files will differ accordingly: ``{query_filename}_{target}_edgeql.py``.
58
75
@@ -63,26 +80,42 @@ It may be preferable to generate a single file containing all the generated func
63
80
64
81
.. code-block:: bash
65
82
66
-
$ gel-py --file
83
+
$ gel generate py/queries --file
67
84
68
85
This generates a single file called ``generated_{target}_edgeql.py`` in the root of your project.
69
86
70
-
Connection
71
-
~~~~~~~~~~
87
+
Models
88
+
======
72
89
73
-
The ``gel-py`` command supports the same set of :ref:`connection options <ref_cli_gel_connopts>` as the ``gel`` CLI.
90
+
The ``models`` generator will generate Pydantic classes and a programmatic query builder. It reflects your full schema, as well as our standard library into functions and Pydantic classes which we've enhanced to make a truly powerful type-safe programmatic data layer.
0 commit comments