'enhanced subscription filtering connection error when using amplify-cli generated GraphQL mutations

I am using amplify-cli with angular front-end.

I have the following schema (schema.graphql):

type CardDeck @model @key(name: "byBoard", fields: "boardId", queryField: "cardDeckByBoardId") { id: ID! type: String! properties: PropertyOrderTwo boardId: ID! }

type Subscription { onUpdateCardDeckByBoardId(boardId: ID!): CardDeck @aws_subscribe(mutations: "updateCardDeck")

I added the following response mapping template to the subscription in the appSync console.

Response Mapping Template - onUpdateCardDeckByBoardId subscription

$extensions.setSubscriptionFilter(
{ "filterGroup": [
     { "filters" :
        { "fieldName" : "boardId",
          "operator" : "eq",
          "value" : "**** -> a valid board id" }
    }
  ]
})

$util.toJson($context.result)

This results in the following connection error when subscribing to the listener in my app:

Connection failed: {"errors":{"message":"Cannot return null for non-nullable type: 'ID' within parent 'CardDeck' (/onUpdateCardDeckByBoardId/id)"},{"message":"Cannot return null for non-nullable type: 'String' within parent 'CardDeck' (/onUpdateCardDeckByBoardId/type)"},{"message":"Cannot return null for non-nullable type: 'ID' within parent 'CardDeck' (/onUpdateCardDeckByBoardId/boardId)"},{"message":"Cannot return null for non-nullable type: 'AWSDateTime' within parent 'CardDeck' (/onUpdateCardDeckByBoardId/createdAt)"},{"message":"Cannot return null for non-nullable type: 'AWSDateTime' within parent 'CardDeck' (/onUpdateCardDeckByBoardId/updatedAt)"}}

What am I doing wrong?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source