Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slugify and Strapiv4.1.2 with GraphQL - 'admin::permission' of undefined #35

Closed
vmptk opened this issue Mar 3, 2022 · 10 comments · Fixed by #37
Closed

Slugify and Strapiv4.1.2 with GraphQL - 'admin::permission' of undefined #35

vmptk opened this issue Mar 3, 2022 · 10 comments · Fixed by #37

Comments

@vmptk
Copy link

vmptk commented Mar 3, 2022

  • Error message:
[2022-03-03 17:10:02.429] info: [slugify] graphql detected, registering queries
[2022-03-03 17:10:03.035] debug: ⛔️ Server wasn't able to start properly.
[2022-03-03 17:10:03.035] error: Cannot read property 'admin::permission' of undefined
TypeError: Cannot read property 'admin::permission' of undefined
at <folder>/node_modules/strapi-plugin-slugify/server/graphql/types.js:18:13
at <folder>/node_modules/lodash/lodash.js:4967:15
at baseForOwn (<folder>/node_modules/lodash/lodash.js:3032:24)
at <folder>/node_modules/lodash/lodash.js:4936:18
at Function.forEach (<folder>/node_modules/lodash/lodash.js:9410:14)
at getCustomTypes (<folder>/node_modules/strapi-plugin-slugify/server/graphql/types.js:17:4)
at extension (<folder>/node_modules/strapi-plugin-slugify/server/graphql/index.js:10:10)
at resolveConfig (<folder>/node_modules/@strapi/plugin-graphql/server/services/extension/extension.js:54:47)
at <folder>/node_modules/@strapi/plugin-graphql/server/services/extension/extension.js:59:74
at Array.reduce (<anonymous>)
at Object.generate (<folder>/node_modules/@strapi/plugin-graphql/server/services/extension/extension.js:58:22)
at buildMergedSchema (<folder>/node_modules/@strapi/plugin-graphql/server/services/content-api/index.js:103:55)
at Object.buildSchema (<folder>/node_modules/@strapi/plugin-graphql/server/services/content-api/index.js:54:20)
at Object.module.exports [as bootstrap] (<folder>/node_modules/@strapi/plugin-graphql/server/bootstrap.js:26:6)
at Object.bootstrap (<folder>/node_modules/@strapi/strapi/lib/core/domain/module/index.js:40:47)
at Object.bootstrap (<folder>/node_modules/@strapi/strapi/lib/core/registries/modules.js:28:19)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
  • Sample package.json
    "@strapi/plugin-graphql": "^4.1.2",
    "@strapi/plugin-i18n": "4.1.2",
    "@strapi/plugin-users-permissions": "4.1.2",
    "@strapi/strapi": "4.1.2",
    "sqlite3": "5.0.2",
    "strapi-plugin-slugify": "^2.1.1"
  • No additional plugin configuration.

  • Sample repo: https://github.com/vmptk/strapi-slug

@ComfortablyCoding
Copy link
Contributor

Can you please provide the following information:

  • strapi version
  • plugin version
  • plugin configuration

If possible a reproducible example.

@chan-fullstack
Copy link

I'm also facing the same issue.

Strapi Version: v4.1.0
Plugin Version: 2.1.1
Plugin configuration: N/A As I've just installed the plugin and run the server.

Thanks!

@mikeyfe6
Copy link

mikeyfe6 commented Mar 4, 2022

Hi! Same problem over here..

Strapi Version: v4.1.2
Plugin Version: ^v2.1.1
Plugin Configuration:

(..config/plugins.js)

   slugify: {
    enabled: true,
    config: {
      contentTypes: {
        instantie: {
          field: "slug",
          references: "profiel",
        },
      },
    },
  },

Thanks in advance!

@ComfortablyCoding
Copy link
Contributor

Thank you for the information. I will investigate the issue.

I did test it on my side before release and had no issues. Very strange.

@SoftCreatR
Copy link

I can't reproduce this issue in the exact same constellation.

@ComfortablyCoding
Copy link
Contributor

ComfortablyCoding commented Mar 6, 2022

@vmptk and @chan-fullstack

This looks to be a bug on strapis end.

The only way I was able to reproduce this was to not have the plugin listed in the plugins.js file. It looks like if the plugin is not listed in that file the register file for the plugin still triggers while the bootstrap one does not. That is the cause of this issue and not something I should need to fix on my end.

At minimum to fix this issue one of the following configurations in the plugins.js file is required

slugify:{
  enabled: false
}

or

slugify:{
  enabled: true
}

I was not able to reproduce the issue with either of the above configurations.

TLDR: it looks to be a bug on strapis side. The plugin should be listed in plugins.js (which it should be) with a minimum configuration.

@ComfortablyCoding
Copy link
Contributor

ComfortablyCoding commented Mar 6, 2022

Hi! Same problem over here..

Strapi Version: v4.1.2 Plugin Version: ^v2.1.1 Plugin Configuration:

(..config/plugins.js)

   slugify: {
    enabled: true,
    config: {
      contentTypes: {
        instantie: {
          field: "slug",
          references: "profiel",
        },
      },
    },
  },

Thanks in advance!

@mikeyfe6 do you have a reproducible example? This as this case looks to be different than the original issue, when I tried this configuration the server started with no issue.

@maneroto
Copy link

maneroto commented Mar 7, 2022

Hello, I had the same problem and I found how to avoid the issue at least.
In the ./config/plugins.js file you need to make sure to list all the slugify configuration just before the graphql one, therefore, you need to have the graphql plugin config.

module.exports = ({ env }) => ({
    slugify: {
        enabled: true,
        config: {
            contentTypes: {
                modelName: {
                    field: 'slug',
                    references: 'title',
                },
            },
        },
    },
    graphql: {
        enabled: true,
        config: {
            defaultLimit: 10,
            maxLimit: 20,
            shadowCRUD: true,
            apolloServer: {
                tracing: true,
            },
        }
    },
})

P.S: If you switch the plugins config, you might reproduce the error.

@vmptk
Copy link
Author

vmptk commented Mar 7, 2022

@ComfortablyCoding with the inverted order in the plugin config it is working... definitely it is a bug in the Strapi plugin system. @maneroto thanks for the hint!!!

Updated repo: https://github.com/vmptk/strapi-slug

@ComfortablyCoding
Copy link
Contributor

At the moment it does not look like plugin order can be enforced.

I will add a note about ensuring graphql is placed before the plugin config as well as a minimal config is required.

Thanks @maneroto for finding this requirement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants