VirtusLab-Open-Source / strapi-plugin-comments

A plugin for Strapi Headless CMS that provides end to end comments feature with their moderation panel, bad words filtering, abuse reporting and more.
MIT License
405 stars 63 forks source link

"message": "Strapi:Plugin:Comments - Not found", #102

Closed asjones-code closed 2 years ago

asjones-code commented 2 years ago

Trying to post a comment with GraphQL as a test. Not working.

This is my query: https://www.npmjs.com/package/strapi-plugin-comments#post-a-comment-1

here's my plugins.js

module.exports = ({ env }) => ({
    //...
    comments: {
        badWords: false,
        moderatorRoles: ["Authenticated"],
        approvalFlow: ['api::article.article'],
        entryLabel: {
            '*': ['Title', 'title', 'Name', 'name', 'Subject', 'subject'],
            'api::article.article': ['MyField'],
        },
        reportReasons: {
            'MY_CUSTOM_REASON': 'MY_CUSTOM_REASON',
        },
        gql: { 
          // ...
        },
    },
    //...
});

My package.json

{
  "name": "aj-91-strapi",
  "private": true,
  "version": "0.1.0",
  "description": "A Strapi application",
  "scripts": {
    "develop": "strapi develop",
    "start": "yarn develop",
    "build": "strapi build",
    "strapi": "strapi"
  },
  "devDependencies": {},
  "dependencies": {
    "@strapi/plugin-graphql": "4.0.6",
    "@strapi/plugin-i18n": "4.0.6",
    "@strapi/plugin-users-permissions": "4.0.6",
    "@strapi/strapi": "4.0.6",
    "pg": "^8.7.1",
    "pg-connection-string": "^2.5.0",
    "sqlite3": "5.0.2",
    "strapi-plugin-comments": "^2.0.0-rc.2"
  },
  "author": {
    "name": "A Strapi developer"
  },
  "strapi": {
    "uuid": "5e5d032c-0e96-4a73-9e7f-2ecdcddc289a"
  },
  "engines": {
    "node": ">=12.x.x <=16.x.x",
    "npm": ">=6.0.0"
  },
  "license": "MIT"
}
cyp3rius commented 2 years ago

What error are you getting?

cyp3rius commented 2 years ago

@asjones-code after some try and check I've been able to reproduce your error. And it's simply your payload issue :)

For query like:

mutation createComment {
  createComment(
    input: {
      relation: "api::page.page:1"
      content: "Hello World!"
      threadOf: 2
      author: { id: 1234, name: "Sample one", email: "test@test.pl" }
    }
  ) {
    id
    content
    threadOf {
      id
    }
    author {
      id
      name
    }
  }
}

Error like "message": "Strapi:Plugin:Comments - Not found", is thrown because the threadOf does not exist. If you follow documentation about Create comment (REST) (you've got a reference to it in GQL section also. You will see that threadOf:

"threadOf": 2, // id of comment we would like to start / continue the thread (Optional)

So if you don't want to answer to an existing comment you're not using it, and that's your case I guess because you want to post first comment :)

Anyway to make it easy to understand we're going to lift the error message to be more descriptive.