Search code examples
amazon-web-servicesgraphqlsubscriptionaws-appsync

appsync subscription with arguments


We are having huge troubles with subscriptions with arguments

to simplify the problem Here are the steps to reproduce

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
}

in the other window make a mutation

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

works like a charm

now change the subscription to listen to a parameter

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

Does not work any more. :(

Any help is appreciated.


Solution

  • 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
      }
    }