mirror of
https://github.com/ComfortablyCoding/strapi-plugin-slugify.git
synced 2025-12-18 00:02:40 -05:00
fix(graphql): errors should not result in internal error
This commit is contained in:
parent
68ea256e5b
commit
e51752e11c
@ -27,10 +27,10 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@sindresorhus/slugify": "1.1.0",
|
||||
"lodash": "^4.17.21",
|
||||
"yup": "^0.32.9",
|
||||
"@strapi/strapi": "^4.14.0",
|
||||
"@strapi/utils": "^4.14.0"
|
||||
"@strapi/utils": "^4.14.0",
|
||||
"lodash": "^4.17.21",
|
||||
"yup": "^0.32.9"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "^8.53.0",
|
||||
|
||||
@ -3,6 +3,7 @@ const { getPluginService } = require('../utils/getPluginService');
|
||||
const { isValidFindSlugParams } = require('../utils/isValidFindSlugParams');
|
||||
const { hasRequiredModelScopes } = require('../utils/hasRequiredModelScopes');
|
||||
const { sanitizeOutput } = require('../utils/sanitizeOutput');
|
||||
const { ForbiddenError, ValidationError } = require('@strapi/utils').errors;
|
||||
|
||||
const getCustomTypes = (strapi, nexus) => {
|
||||
const { naming } = getPluginService('utils', 'graphql');
|
||||
@ -54,16 +55,23 @@ const getCustomTypes = (strapi, nexus) => {
|
||||
const { modelName, slug, publicationState } = args;
|
||||
const { auth } = ctx.state;
|
||||
|
||||
try {
|
||||
isValidFindSlugParams({
|
||||
modelName,
|
||||
slug,
|
||||
modelsByName,
|
||||
publicationState,
|
||||
});
|
||||
|
||||
} catch (error) {
|
||||
throw new ValidationError(error.message);
|
||||
}
|
||||
const { uid, field, contentType } = modelsByName[modelName];
|
||||
|
||||
try {
|
||||
await hasRequiredModelScopes(strapi, uid, auth);
|
||||
} catch (error) {
|
||||
throw new ForbiddenError();
|
||||
}
|
||||
|
||||
// build query
|
||||
let query = {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user