AWS AppSync Subscription Arguments Not Working

Viewed 124

I'm going crazy over subscriptions with AWS AppSync. My problem is that I can't figure out how to get a filtered subscription. When I pass any arguments into the subscriber, I get nothing in return.

What am I missing?


In schema.graphql my mutation looks like this

  testMutation(
    id: String!,
    val: String!
  ): TestItem!

My "catch all" subscriber looks like this

  subscribeToAllTestMutations: TestItem!
  @aws_subscribe(mutations: ["testMutation"])

The problematic subscriber looks like this:

  subscribeToTestMutation(id: String!): TestItem!
  @aws_subscribe(mutations: ["testMutation"])

When I run this mutation:

mutation {
  testMutation(
    id: "123-test",
    val:"Hey man"
  ) {
    id
    val
  }
}

I get this response:

{
  "data": {
    "testMutation": {
      "id": "123-test",
      "val": "Hey man",
      "__typename": "TestItem"
    }
  }
}

I get the same when I run this:

 subscription {
   subscribeToAllTestMutations {
     id
     val
   }
 }

But when I pass the ID I get nothing, which turns me crazy:

subscription {
  subscribeToTestMutation(
    id: "123-test"
  ) {
    id
    val
  }
}

I figured it might have something to do with my mapping templates, but i cannot figure out how to solve it.

I currently, for test purposes, just pass the data through like this with my request mapping template:

{
  "version": "2017-02-28",
  "payload": $utils.toJson($context.arguments)
}

And, as for resolver mapping template, I just do this:

$utils.toJson($context.result)

Please, if anyone can help me you will save my sanity

0 Answers
Related