notum-cz/strapi-plugin-content-versioning

TypeError: Cannot read properties of undefined (reading 'length')

Closed this issue · 5 comments

Right after installation any content creation using GraphQL causes error:

"extensions": {
        "code": "INTERNAL_SERVER_ERROR",
        "exception": {
          "stacktrace": [
            "TypeError: Cannot read properties of undefined (reading 'length')",
            "    at Object.create (/Users/seleckis/Sites/pivo/pivo-reporting-strapi/node_modules/@notum-cz/strapi-plugin-content-versioning/server/services/entity-service-decorator.js:102:43)",
            "    at Object.create (/Users/seleckis/Sites/pivo/pivo-reporting-strapi/node_modules/@strapi/plugin-i18n/server/services/entity-service-decorator.js:130:40)",
            "    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)",
            "    at async resolve (/Users/seleckis/Sites/pivo/pivo-reporting-strapi/node_modules/@strapi/plugin-graphql/server/services/builders/mutations/collection-type.js:52:23)"
          ]
        }
      }

Steps to reproduce the behavior

  1. Install plugin.
  2. Configure as described in readme: select content versioning support in content type and allow permissions.
  3. Go to GraphQL playground.
  4. Write mutation like this:
mutation ($title: String!) {
  createPage(data: { title: $title }) {
    data {
      id
    }
  }
}

adopt for your schema.
5. See error

Expected behavior

Content should be created as usual.

System

  • Node.js version: 18.12.1
  • NPM version: 9.2.0
  • Strapi version: 4.15.4
  • Database: SQLite
  • Operating system: MacOS

Hey @seleckis, I assume you are trying to create a new version of content through graphQL API. Creating new versions is supported only in Strapi admin right now. Please, refer to #49. If i did not understand your problem correctly, please feel free to reopen.

No I'm not trying to create a new version of content. I'm creating a record itself, just fresh content item. This plugin breaks a regular content item creation using common method. This should not work like this. Please reopen.

@seleckis I asked a developer who created this plugin and he said that it does not support GraphQL at all so you would probably run into another issues with it. I am sorry for this information. I will put it Readme and possibly even to roadmap.

This is really sad. So you have to write in Readme not just "this plugin does not support GraphQL", but "This plugin conflicts with GraphQL plugin", because even just installing Content Versioning plugin and not using it, it breaks regular GraphQL plugin functionality. Or if the plugin breaks regular content creation api and requires to use you custom api, then this should also be mentioned in Readme. But I don't know what is the real reason.

Good point. Unfortunately, to remove the need to patch strapi admin package we had to use entity service decorator (strapis internal api) which is probably why the GraphQL content creation is broken. There are always tradeoffs. So sorry again but this would require complete rework of the plugin.