我正在使用放大器自动生成查询,突变和订阅.我有这样的类型:
type Message @model {
id: ID!
author: User @connection(name: "UserMessages")
content: String
}如何使用authorID生成的模式将添加到新消息的订阅中?
发布于 2018-11-12 07:36:19
您可以添加您自己的订阅字段,不管您喜欢什么都可以参数化。
尝尝这个
# Add the authorId explicitly and turn off the generated subscriptions.
type Message @model(subscriptions: null) {
id: ID!
author: User @connection(name: "UserMessages")
authorId: String
content: String
}
type Subscription {
onCreateMessage(authorId: String!): Message @aws_subscribe(mutations: "createMessage")
}订阅的客户端只获得订阅查询中提供的authorId消息:
subscription SubscribeToNewMessages($id: String!) {
onCreateMessage(authorId: $id) {
id
authorId
content
}
}https://stackoverflow.com/questions/53255380
复制相似问题