带参数的 appsync 订阅 [英] appsync subscription with arguments

查看:22
本文介绍了带参数的 appsync 订阅的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在使用参数订阅时遇到了巨大的麻烦

We are having huge troubles with subscriptions with arguments

为了简化问题这里是重现的步骤

to simplify the problem Here are the steps to reproduce

创建一个简单的Schema

create a simpleSchema

type Mutation {
    testSubMutation(param: String!): String
}

type Query {
    testQuery: String
}

type Subscription {
    testSubs(param: String): String
        @aws_subscribe(mutations: ["testSubMutation"])
}

我将本地解析器附加到返回时间戳的突变.

I attached a local resolver to the mutation which returns the timestamp.

在一个窗口中打开应用同步查询选项卡并进行订阅

in one window open the app sync query tab and make the subscription

subscription sub{
  testSubs
}

在另一个窗口进行修改

mutation mut{
  testSubMutation(param:"123")
}

就像一个魅力

现在更改订阅以监听参数

now change the subscription to listen to a parameter

subscription sub{
  testSubs(param:"123")
}

不再起作用.:(

感谢任何帮助.

推荐答案

订阅要求您过滤的参数在突变的响应中.您可以尝试将您的突变更新为这个吗?

Subscriptions require the parameter you're filtering on to be in the response of the mutation. Could you try updating your mutation to this?

mutation mut{
  testSubMutation(param:"123") {
    param
  }
}

这篇关于带参数的 appsync 订阅的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆