We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
亮点:概念简单, API简洁,不需要引入复杂的 graphql 框架,却能生成比graphql 更精准的视图数据
示例代码:(可选)
class Comment(BaseModel): id: int content: str class Blog(BaseModel): id: int title: str comments: list[Comment] = [] def resolve_comments(self, loader=LoaderDepend(blog_to_comments_loader)): return loader.load(self.id) comment_count: int = 0 def post_comment_count(self): return len(self.comments) class MyBlogSite(BaseModel): blogs: list[Blog] name: str comment_count: int = 0 def post_comment_count(self): return sum([b.comment_count for b in self.blogs]) async def main(): my_blog_site = MyBlogSite( name: "tangkikodo's blog" blogs = [ Blog(id=1, title='what is pydantic-resolve'), Blog(id=2, title='what is composition oriented development pattarn'), ] ) my_blog_site = await Resolver().resolve(my_blog_site)
output
{ "name": "tangkikodo's blog", "blogs": [ { "id": 1, "title": "what is pydantic-resolve", "comments": [ { "id": 1, "content": "its interesting" }, { "id": 2, "content": "i dont understand" } ], "comment_count": 2 }, { "id": 2, "title": "what is composition oriented development pattarn", "comments": [ { "id": 3, "content": "why? how?" }, { "id": 4, "content": "wow!" } ], "comment_count": 2 } ], "comment_count": 4 }
截图:
后续更新计划:
The text was updated successfully, but these errors were encountered:
No branches or pull requests
推荐项目
亮点:概念简单, API简洁,不需要引入复杂的 graphql 框架,却能生成比graphql 更精准的视图数据
示例代码:(可选)
output
截图:
后续更新计划:
The text was updated successfully, but these errors were encountered: