This repository was archived by the owner on Sep 16, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +19
-11
lines changed Expand file tree Collapse file tree 2 files changed +19
-11
lines changed Original file line number Diff line number Diff line change 2727 },
2828 "dependencies" : {
2929 "@sindresorhus/slugify" : " 1.1.0" ,
30- "lodash" : " ^4.17.21" ,
31- "yup" : " ^0.32.9" ,
3230 "@strapi/strapi" : " ^4.14.0" ,
33- "@strapi/utils" : " ^4.14.0"
31+ "@strapi/utils" : " ^4.14.0" ,
32+ "lodash" : " ^4.17.21" ,
33+ "yup" : " ^0.32.9"
3434 },
3535 "devDependencies" : {
3636 "eslint" : " ^8.53.0" ,
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ const { getPluginService } = require('../utils/getPluginService');
33const { isValidFindSlugParams } = require ( '../utils/isValidFindSlugParams' ) ;
44const { hasRequiredModelScopes } = require ( '../utils/hasRequiredModelScopes' ) ;
55const { sanitizeOutput } = require ( '../utils/sanitizeOutput' ) ;
6+ const { ForbiddenError, ValidationError } = require ( '@strapi/utils' ) . errors ;
67
78const getCustomTypes = ( strapi , nexus ) => {
89 const { naming } = getPluginService ( 'utils' , 'graphql' ) ;
@@ -54,16 +55,23 @@ const getCustomTypes = (strapi, nexus) => {
5455 const { modelName, slug, publicationState } = args ;
5556 const { auth } = ctx . state ;
5657
57- isValidFindSlugParams ( {
58- modelName,
59- slug,
60- modelsByName,
61- publicationState,
62- } ) ;
63-
58+ try {
59+ isValidFindSlugParams ( {
60+ modelName,
61+ slug,
62+ modelsByName,
63+ publicationState,
64+ } ) ;
65+ } catch ( error ) {
66+ throw new ValidationError ( error . message ) ;
67+ }
6468 const { uid, field, contentType } = modelsByName [ modelName ] ;
6569
66- await hasRequiredModelScopes ( strapi , uid , auth ) ;
70+ try {
71+ await hasRequiredModelScopes ( strapi , uid , auth ) ;
72+ } catch ( error ) {
73+ throw new ForbiddenError ( ) ;
74+ }
6775
6876 // build query
6977 let query = {
You can’t perform that action at this time.
0 commit comments