Pydantic-resolve is a Pydantic based approach to construct complex data declaratively and progressively, without writing any imperative glue code. Its best use case is building complex API data, especially in UI integration scenarios, it can be used as a replacement for GraphQL, reusing most of the code while offering better performance and maintainability. It introduces resolve methods for on-demand data fetching, and post methods for post process requirements. It also provides the capability for cross-layer node data transmission. Starting from pydantic-resolve v2, ErDiagram is supported, we can use it to declare application level Entity Relationship to better maintain the core business models. With the support of ERD, the constructed data will have better maintainability, being easy to write and read. It could be seamlessly integrated with modern Python web frameworks including FastAPI, Litestar, and Django-ninja. For FastAPI developers, we can visualize the dependencies of schemas by installing fastapi-voyager, visit live demo Installation # latest v1 pip install pydantic-resolve==1.13.5 # v2 pip install pydantic-resolve Starting from pydantic-resolve v1.11.0, both pydantic v1 and v2 are supported. Starting from pydantic-resolve v2.0.0, it only supports pydantic v2, pydantic v1 and dataclass are dropped, anything else are backward compatible. Basic Usage In this part, we will introduce some fundamental features that allow us to freely combine data just like a GraphQL query. Pick fields from source class DefineSubset can pick wanted fields and generate a new pydantic class. from pdyantic_resolve import DefineSubset import app . team . schema as team_schema class Team ( DefineSubset ) __subset__ = ( team_schema . Team , ( 'id' , 'name' )) @ route . get ( '/teams' , response_model = List [ Team ]) async def get_teams ( session : AsyncSession = Depends ( db . get_session )): teams = await tmq . get_teams ( session ) return teams Attach related data use resolve_{fiel...
First seen: 2026-01-01 22:12
Last seen: 2026-01-02 01:13