【发布时间】:2019-12-13 08:40:13
【问题描述】:
我正在学习如何使用 Amplify 部署 AWS 应用程序。
我对使用 graphql 的关系有疑问。我只是按照文档的教程进行操作。我在这里生成了关于博客和帖子的示例模式:https://aws-amplify.github.io/docs/cli-toolchain/graphql?sdk=angular
我想知道如何进行比“查找全部”更复杂的查询。
具体来说:我可以像这样找到所有帖子:
import { APIService } from '../API.service';
export class BlogComponent implements OnInit {
constructor(private apiService: APIService) { }
@Input()
blog: any;
posts: any;
ngOnInit() {
this.apiService.ListPosts().then((evt) => {
this.posts = evt.items;
});
}
}
ngOnInit() 函数中的代码可以很好地列出所有帖子。但是如何通过博客 ID 找到帖子?
graphhql 架构如下,这只是上面发布的链接中教程的一部分:
type Blog @model {
id: ID!
name: String!
posts: [Post] @connection(name: "BlogPosts")
}
type Post @model {
id: ID!
title: String!
blog: Blog @connection(name: "BlogPosts")
comments: [Comment] @connection(name: "PostComments")
}
在生成的代码中,我看到了这些的 crud 操作,但没有看到“连接”。如何找到特定博客的所有帖子?
【问题讨论】:
标签: angular amazon-web-services graphql