Possible to subscribe to DELETE events when using graphql-yoga?


I’m using the subscription example from the prisma/prisma-examples repo and changed the subscribe function to also fire when a post is deleted.

  Subscription: {
    posts: {
      subscribe: async (parent, args, context) => {
        return context.prisma.$subscribe
      resolve: payload => {
        return payload

Now when a post is deleted the subscription fires, but the payload is null so the client only gets null and thus can’t determine which post was deleted.

Is there a way to be able to return the deleted post? Or any best practices for dealing with this kind of situation where the client needs to know when a specific post was deleted?

Thanks in advance!


You can specify you want the previous data (which in your case will be the deleted data).

subscription {
 posts {
  previousValues {


Didn’t now about this, will give it a try.
Thank you!


This topic was automatically closed 45 days after the last reply. New replies are no longer allowed.