GraphQL deleteManyConnection not able to delete a record

GraphQL deleteManyConnection not able to delete a record


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 –

GraphQL deleteManyConnection not able to delete a record

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 –

GraphQL deleteManyConnection not able to delete a record

Share


Load 4 more related questions


Show fewer related questions

0

Reset to default



Browse other questions tagged

or ask your own question.

Leave a Reply

Your email address will not be published. Required fields are marked *