question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to subscribe Create and Delete with <Connect />

See original GitHub issue

** 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.

<Connect
    query={graphqlOperation(queries.listTodos)}
    subscription={graphqlOperation(subscriptions.onCreateTodo)}
    onSubscriptionMsg={(prev, { onCreateTodo }) => {
        console.log ( onCreateTodo );
        return prev; 
    }}
>

Anyone know how to subscribe create and delete at the same time with <Connect />?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:16

github_iconTop GitHub Comments

5reactions
wizawuzacommented, Feb 20, 2019

I just realized I misread your post (sorry, busy day). So my other post may not answer your question, but maybe this will: you’ll have to use a custom subscription. For example, amplify probably creates something like this in a subscriptions.js file:

export const onCreatePost = `subscription OnCreatePost {
  onCreatePost {
    id
    field1
    field2
  }
}
`;
export const onDeletePost = `subscription OnDeletePost {
  onDeletePost {
    id
    field1
    field2
  }
}
`;

And then you can only select onCreatePost OR onDeletePost

But you could create a new subscription in a custom file:

export const onCreateOrDeletePost = `subscription onCreateOrDeletePost {
  onCreatePost {
    id
    field1
    field2
  },
  onDeletePost {
    id
    field1
    field2
  }
}
`;

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.

0reactions
github-actions[bot]commented, Jun 11, 2021

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 or Discussions for those types of questions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Delete a Pull Subscription - SQL Server - Microsoft Learn
Right-click the subscription, and then click Delete. In the confirmation dialog box, select whether to connect to the Subscriber to delete ...
Read more >
How to delete and create a new path in a workflow - ServiceNow
Clicking the "delete" completely removes the link node (see the "Notification" stage below). Deep K's answer is what I was looking for. What ......
Read more >
How do I delete or remove a calendar subscriber?
On the calendar page, scroll down to the subscriber's section. Locate the "All subscribers" button on the bottom right and click the button....
Read more >
Deleting an Amazon SNS subscription and topic
On the Subscriptions page, select a subscription with a Status of Confirmed, and then choose Delete. In the Delete subscription dialog box, choose...
Read more >
Delete an account – curl - Stripe API reference
Delete an account. With Connect, you can delete accounts you manage. Accounts created using test-mode keys can be deleted at any time.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found