小编Vin*_*ang的帖子

AWS AppSync中的订阅自定义筛选

是否可以在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中使用自定义过滤逻辑?

amazon-web-services aws-appsync appsync-apollo-client

13
推荐指数
1
解决办法
908
查看次数

AWS API Gateway,“集成响应”中的“HTTP 状态正则表达式”无法匹配任何字符串

一些背景信息:我的设置是 browser -> api gateway -> ec2 (using spring mvc).
我想返回 200 以外的 http 状态。在谷歌搜索了很多之后,我知道我在 api 网关上做了一些配置。以下是我的配置:

  1. Method Response,添加http状态400
  2. Integration Response->HTTP status regex,添加.*httpStatus":400.*
  3. 在 ec2(使用 spring mvc)中,我总是返回 http 状态 400 并使用以下 json 作为响应主体(用于测试)

    {
    "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 …

amazon-web-services aws-api-gateway

4
推荐指数
1
解决办法
4003
查看次数