Skip to content
Open Source · Pydantic v2 · Python 3.10+

Declarative Data Assembly

A BFF toolkit for Python. Compose complex nested APIs declaratively — zero N+1, zero boilerplate.

pip install pydantic-resolve

Solve N+1 in a few lines of code

Replace manual loops with declarative data loading.

Before — N+1 problem
# Sprint has 10 tasks, each needs owner
for task in sprint.tasks:
    task.owner = await get_user(task.owner_id)
 # 10 queries!
After — pydantic-resolve
class TaskView(BaseModel):
    owner_id: int
    owner: Optional[UserView] = None

    def resolve_owner(self, loader=Loader(user_loader)):
        return loader.load(self.owner_id)
 # 1 query!

Everything you need for data assembly

From loading related data to generating GraphQL APIs — all in one library.

Batch Loading

Auto-batch queries via DataLoader pattern. 100 lookups become 1 query.

Post Processing

Compute derived fields after all nested data is resolved. Counts, aggregates, formatting.

Cross-Layer Data Flow

ExposeAs, SendTo, Collector — pass context down or aggregate data up without traversal code.

ER Diagram + AutoLoad

Centralize relationship declarations. Reuse across models, GraphQL, and MCP services.

GraphQL Generation

Auto-generate GraphQL schema and resolvers from your ER Diagram.

MCP Service

Expose GraphQL APIs to AI agents via Model Context Protocol.

Progressive learning path

Start simple, scale as needed. Each concept builds on the last.

1 resolve_*
2 Nested Tree
3 post_*
4 Cross-Layer
5 ERD + AutoLoad
6 GraphQL / MCP

Aligns with Clean Architecture

ER Diagram doubles as entity and use-case layer, cleanly isolating your database.

Entity + Use Case

ER Diagram defines entities and their relationships — it naturally serves as both the domain model and the use-case boundary.

DB Agnostic

Loaders abstract away the data source. Swap SQLAlchemy for Django or Tortoise ORM — your models stay untouched.

Multi-Presentation

One ERD drives REST API responses, GraphQL queries, and MCP services — without duplication.

Built for your stack

Works with your existing frameworks and ORMs.

Ready to eliminate N+1 queries?

Start with a single resolve method. Scale to ER Diagram when you're ready.