是否可以在AWS AppSync中订阅自定义过滤逻辑?
据我所知,目前的行为是:例如,我的架构如下所示
type Mutation {
createEvent(userId: ID!, event: Event!): Event!
}
type Subscription {
onEvent(userId: ID!): Event!
@aws_subscribe(mutations: ["createEvent"])
}
Run Code Online (Sandbox Code Playgroud)
AppSync的当前行为是,当我触发createEvent时,AppSync承诺如果userId相等,则Subscription的订阅者会收到Event.即AppSync的过滤逻辑就像
if (Muatation.userId == Subscription.userId) {
// forward to subscriber
}
Run Code Online (Sandbox Code Playgroud)
但是,如果我想要不同的过滤逻辑呢?例如,我想订阅除了由我触发的所有其他事件?即
if (Muatation.userId != Subscription.userId) {
// forward to subscriber
}
Run Code Online (Sandbox Code Playgroud)
那么,是否可以在AppSync中使用自定义过滤逻辑?
一些背景信息:我的设置是 browser -> api gateway -> ec2 (using spring mvc).
我想返回 200 以外的 http 状态。在谷歌搜索了很多之后,我知道我在 api 网关上做了一些配置。以下是我的配置:
Method Response,添加http状态400Integration Response->HTTP status regex,添加.*httpStatus":400.* {
"errorMessage": "{\"errorType\":\"Bad Request\",\"requestId\":\"12345\",\"httpStatus\":400,\"message\":\"you got错误\"}"
}
但是,当我测试 api(使用 api 网关中的“测试”按钮)时,它仍然返回 http 状态 200。(我希望它应该是 400)
当我将正则表达式更改为 时.*400.*,它按预期返回 http 状态 400。
当我将正则表达式更改为 时.*httpStatus.*,它返回 http 状态 200。(我希望它应该是 400)
为什么正则表达式不能.*httpStatus":400.*识别我的 json?即使我将正则表达式简化为.*httpStatus.*.
但是正则表达式.*400.*可以识别 int …