-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to subscribe Create and Delete with <Connect /> #2713
Comments
Hey I'm also struck by this question, this would be a fantastic feature to have on |
You can also extend the connect component, which is what I did. See here: #2527 |
wizawuza, could you give an example of how that would look?
How can you extend the component to listen for multiple events (create,update,delete) if only one subscription can be bound to |
I just realized I misread your post (sorry, busy day).
And then you can only select onCreatePost OR onDeletePost But you could create a new subscription in a custom file:
I think that'll work, worth a quick try at least. There may be a more elegant way of doing this without doing a custom subscription.js file, but I don't know it. |
wizawuza that worked! Also this solution is way cleaner then dealing with an array of subscriptions like in my PR. I'll take the trade off of having to manage a separate subscription file. |
You can create Listeners on componentDidMount! I am creating this code later this arvo and will post ASAP. Please create a question on stackoverflow too and post the link here. That may help ppl in the future too!! Talk to you soon! |
Thanks for posting @wizawuza . I am able to subscribe to a create, update, and delete successfully by batching the subscriptions. My question is how can I know which mutation ran? I am trying to update a table and would need to either update, add, or remove entries based on what happens. I would also like to leverage the connect component. I could also try and refetch the connect query, but am not sure how to do this. Any thoughts? Thanks! |
@sadnub that one's easy thankfully.
You'll notice from the console.log, it'll output something like: OR updatedQuery.onDeletePost So, what you would do is either use an if/then/else if block or switch/case:
|
Thank you that worked great! Here is my final product to help anyone else. I am saving the table item in operationIndex so I can modify the internal connect list.
|
@wizawuza is this way work with mutations? and how to marge two mutations? |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This issue has been automatically closed because of inactivity. Please open a new issue if are still encountering problems. |
In the graphql subscriptions file I see the following the top That is a bit of a concern no? |
This solution doesn't work for me. Looks like an update to AppSync disabled this ability as descibed in more detail on this issue: https://github.com/aws-amplify/amplify-js/issues/4813 |
@wizawuza solution did not work for me, doesn't even console something Subscription
My Connect
|
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 |
** Which Category is your question related to? **
API / GraphQL
** What AWS Services are you utilizing? **
AWS AppSync
** Provide additional details e.g. code snippets **
Hello all,
I'm trying to subscribe any updates including create, delete and update in my GraphQL backend using
<Connect />
, but all I could find from Amplify API doc was just an example which is subscribing Create events only like following.Anyone know how to subscribe create and delete at the same time with
<Connect />
?The text was updated successfully, but these errors were encountered: