graphql-codegen powered by pydantic
Project description
turms
DEVELOPMENT
Inspiration
Turms is a pure python implementation of the awesome graphql-codegen library, following a simliar extensible design. It makes heavy use of pydantic and its serialization capablities and provides fully typed querys, mutations and subscriptions
Supports
- Documents
- Fragments
- Enums
- Operations
- Operation Functions
- Scalar (mapping to python equivalent)
Features
- Fully Modular (agnostic of graphql transport)
- Tries to minimise Class Generation if using Fragments
- Autocollapsing operation (if mutation or query has only one operation) functions
- Specify type mixins, baseclasses...
- Fully Support type hints for variables (Pylance)
- Compliant with graphl-config
Installation
pip install turms
Config
Usage
Open your workspace (create a virtual env), in the root folder
turms init
This creates a graphql-config compliant configuration file in the working directory, edit this to reflect your settings (see Configuration)
turms gen
Generate beautifully typed Operations, Enums,...
Why Turms
In Etruscan religion, Turms (usually written as 𐌕𐌖𐌓𐌌𐌑 Turmś in the Etruscan alphabet) was the equivalent of Roman Mercury and Greek Hermes, both gods of trade and the messenger god between people and gods.
Transport Layer
Turms does not come with a default transport layer, but by specifiyng custom queries classes you can easily incorporate your logic (look at turms.types.herre for inspiration)
Examples
This github repository also contains an example graphql.config.yaml with the public SpaceX api, as well as a sample of the generated api.
Experimental
turms watch $PROJECT_NAME
Turms watch is able to automatically monitor your graphql folder for changes and autogenerate the api on save again. Requires additional dependency for watchdog
pip install turms[watch]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.