System Information
- 3.4.1:
- MacOS 11.1:
- GraphQL:
Hi all,
I’m following the documentation here to count using GraphQL, and it works fine for content types whose title is a single word (e.g. restaurant). But for content types with more than one word (e.g. ‘Blog Posts’ or ‘Blog Comments’, I get a permissions issue (despite having enabled ‘count’ for public users for these content types in Strapi).
My schema.graphql.js file:
`module.exports = {
definition:
,
query: commentsCount(where: JSON): Int!
,
resolver: {
Query: {
commentsCount: {
description: ‘Return the count of blog comments’,
resolverOf: ‘application::BlogComments.BlogComments.count’,
resolver: async (obj, options, ctx) => {
return await strapi.api.BlogComments.services.BlogComments.count(options.where || {});
},
},
},
},
};`
The error I get is as follows:
{
“errors”: [
{
“message”: “Forbidden”,
“locations”: [
{
“line”: 4,
“column”: 3
}
],
“path”: [
“commentsCount”
],
“extensions”: {
“code”: “INTERNAL_SERVER_ERROR”,
“exception”: {
“data”: null,
“isBoom”: true,
“isServer”: false,
“output”: {
“statusCode”: 403,
“payload”: {
“statusCode”: 403,
“error”: “Forbidden”,
“message”: “Forbidden”
},
“headers”: {}
},
“message”: “Forbidden”,
“stacktrace”: [
“Error: Forbidden”,
" at handleErrors (/Users/pftodd/Documents/Hercules/pt/backend/node_modules/strapi-plugin-users-permissions/config/policies/permissions.js:92:28)",
" at module.exports (/Users/pftodd/Documents/Hercules/pt/backend/node_modules/strapi-plugin-users-permissions/config/policies/permissions.js:79:12)",
" at processTicksAndRejections (internal/process/task_queues.js:97:5)",
" at async /Users/pftodd/Documents/Hercules/pt/backend/node_modules/strapi-plugin-graphql/node_modules/strapi-utils/lib/policy.js:68:5",
" at async /Users/pftodd/Documents/Hercules/pt/backend/node_modules/strapi-plugin-graphql/services/resolvers-builder.js:97:7"
]
}
}
}
],
“data”: null
}
I’d be grateful if you could let me know why this isn’t working!
Many thanks
Patrick