带参数的 appsync 订阅
appsync subscription with arguments
我们在使用带参数的订阅时遇到了很大的麻烦
简化问题下面是重现的步骤
创建一个简单的架构
type Mutation {
testSubMutation(param: String!): String
}
type Query {
testQuery: String
}
type Subscription {
testSubs(param: String): String
@aws_subscribe(mutations: ["testSubMutation"])
}
我将本地解析器附加到 returns 时间戳的突变。
一次window打开应用同步查询选项卡并进行订阅
subscription sub{
testSubs
}
在另一个window中进行突变
mutation mut{
testSubMutation(param:"123")
}
很有魅力
现在更改订阅以监听一个参数
subscription sub{
testSubs(param:"123")
}
不再有效。 :(
感谢任何帮助。
订阅要求您过滤的参数在突变的响应中。您可以尝试将您的突变更新为这个吗?
mutation mut{
testSubMutation(param:"123") {
param
}
}
我正在为订阅做同样的事情,但没有得到回应,它只使用一个参数 room
mutation addMessage {
addMessage(input: {
room: "45a87f5b-ef9e-41cd-9cd7-f3e2f4946d31",
receiver: "3cea9c02-1cf5-4248-8ebe-3580a7a47b8b" }) {
id
room
receiver {
id
userName
}
}
}
subscription roomMessage {
roomMessage(room: "45a87f5b-ef9e-41cd-9cd7-f3e2f4946d31",
receiver: "3cea9c02-1cf5-4248-8ebe-3580a7a47b8b") {
id
room
receiver {
id
userName
}
}
}
我们在使用带参数的订阅时遇到了很大的麻烦
简化问题下面是重现的步骤
创建一个简单的架构
type Mutation {
testSubMutation(param: String!): String
}
type Query {
testQuery: String
}
type Subscription {
testSubs(param: String): String
@aws_subscribe(mutations: ["testSubMutation"])
}
我将本地解析器附加到 returns 时间戳的突变。
一次window打开应用同步查询选项卡并进行订阅
subscription sub{
testSubs
}
在另一个window中进行突变
mutation mut{
testSubMutation(param:"123")
}
很有魅力
现在更改订阅以监听一个参数
subscription sub{
testSubs(param:"123")
}
不再有效。 :(
感谢任何帮助。
订阅要求您过滤的参数在突变的响应中。您可以尝试将您的突变更新为这个吗?
mutation mut{
testSubMutation(param:"123") {
param
}
}
我正在为订阅做同样的事情,但没有得到回应,它只使用一个参数 room
mutation addMessage {
addMessage(input: {
room: "45a87f5b-ef9e-41cd-9cd7-f3e2f4946d31",
receiver: "3cea9c02-1cf5-4248-8ebe-3580a7a47b8b" }) {
id
room
receiver {
id
userName
}
}
}
subscription roomMessage {
roomMessage(room: "45a87f5b-ef9e-41cd-9cd7-f3e2f4946d31",
receiver: "3cea9c02-1cf5-4248-8ebe-3580a7a47b8b") {
id
room
receiver {
id
userName
}
}
}