Custom Subscriptions with multiple optional parameters doesn't fire
See original GitHub issueDescribe the bug After implementing the custom subscription arguments here: https://aws-amplify.github.io/docs/cli-toolchain/graphql?sdk=js#filter-subscriptions-by-model-fields-andor-relations
The next time you run amplify push or amplify api gql-compile, your subscriptions will allow an id and/or commentTodoId argument on a Comment subscription. As long as your mutation on the Comment type returns the specified argument field from its query, AppSync filters which subscription events will be pushed to your subscribed client.
I have two subscriptions that I care about, one each for adding/removing from a collection. To use the example in the documentation, I have the equivalent of this:
type Subscription {
onCreateComment(commentTodoId: String): Comment @aws_subscribe(mutations: "createComment")
onDeleteComment(id: ID, commentTodoId: String): Comment @aws_subscribe(mutations: "deleteComment")
}
The create works as expected. The delete does not.
However, if I remove the id
from the onDelete subscription and only have the second parameter, it works as expected, like so:
type Subscription {
onCreateComment(commentTodoId: String): Comment @aws_subscribe(mutations: "createComment")
onDeleteComment(commentTodoId: String): Comment @aws_subscribe(mutations: "deleteComment")
}
I’m not sure when this occurred, probably within the last one or two revisions of the CLI, but this appears to be a recent occurrence as this same part of my app has worked in the past without any recent changes on my part. The latest amplify update (either CLI or js library) has changed this behavior.
As a side note: I’m curious if this might be based on the id
key specifically - I have another subscription based solely on an update that doesn’t seem to work any longer after the recent edition of the CLI or js. This would be the equivalent of:
onUpdateComment(id: ID): Comment @aws_subscribe(mutations: "updateComment")
As in, whenever this comment updates, I want to listen to it. This does not appear to work. I would guess that if I took away ID and added some other qualifier, it would work. I will try this and report back.
To Reproduce Steps to reproduce the behavior:
- Have the following subscription:
type Subscription {
onCreateComment(commentTodoId: String): Comment @aws_subscribe(mutations: "createComment")
onDeleteComment(commentTodoId: String): Comment @aws_subscribe(mutations: "deleteComment")
}
- Implement and listen to the subscriptions. It works.
- Add the ID per the instructions at the link above:
type Subscription {
onCreateComment(commentTodoId: String): Comment @aws_subscribe(mutations: "createComment")
onDeleteComment(id:ID, commentTodoId: String): Comment @aws_subscribe(mutations: "deleteComment")
}
- onDelete no longer works.
Expected behavior Subscriptions work.
~ $ amplify -v 1.8.1
"aws-amplify": "^1.1.30",
P.S. - It would be nice for reproductions or testing if there was a codesandbox of some kind that was setup to implement most (if not all) of the CLI features, so that situations could be re-created more easily as a demo. We would be able to fork it and attempt to show reproductions of our issues…
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (6 by maintainers)
Thanks @mwarger for the clarification I’ve reproduced the issue. this appears to be a server side bug, we will update you on its fix.
This issue has been automatically locked since there hasn’t been any recent activity after it was closed. Please open a new issue for related bugs.
Looking for a help forum? We recommend joining the Amplify Community Discord server
*-help
channels for those types of questions.