0

I am implementing a function to delete a record from the database with graphql but it is giving me headaches now. I am using hygraph/graphcms on which the query is running perfectly fine but its not working in the code.

Here is the query -

const deleteLikeNotificationQuery = gql`
  mutation DeleteLikeNotification(
    $actorId: ID!
    $notifierId: ID!
    $postId: ID!
  ) {
    deleteManyNotificationsConnection(
      first: 1
      where: {
        actor: { id: $actorId }
        notifier: { id: $notifierId }
        notifyType: liked
        post: { id: $postId }
      }
    ) {
      aggregate {
        count
      }
    }
  }
`
async function thisFunction() {
 const result: deleteSpecificNotificationType = await request(
        graphqlAPI,
        deleteLikeNotificationQuery,
        {
          actorId,
          notifierId,
          postId,
        }
      )
      console.log(result.deleteManyNotificationsConnection.aggregate.count)
      return result.deleteManyNotificationsConnection.aggregate.count > 0
        ? true
        : false

}

I am passing actorId, notifierId and postId correctly as I am printing them before the query and they are perfectly fine.

Here is the screenshot of API playground in hygraph where I am testing my query -

enter image description here

Its working perfectly fine in here but the same values on the code do not working at all. The count of deleted records is coming to be zero I don't know why. Any help is much appreciated.

Here is the model on which it is happening -

enter image description here

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Kartik Thakur
  • 57
  • 1
  • 7

0 Answers0