From 6b2ea4039f7fa50de47ab96ed6f5a302ad73d71a Mon Sep 17 00:00:00 2001 From: Convly Date: Wed, 24 Nov 2021 16:19:50 +0100 Subject: [PATCH 1/2] Fix image querying in graphql relations --- packages/core/upload/server/graphql.js | 2 -- packages/plugins/graphql/server/services/builders/type.js | 6 ------ 2 files changed, 8 deletions(-) diff --git a/packages/core/upload/server/graphql.js b/packages/core/upload/server/graphql.js index 09df6e9162..a4caeeb2d9 100644 --- a/packages/core/upload/server/graphql.js +++ b/packages/core/upload/server/graphql.js @@ -188,8 +188,6 @@ module.exports = ({ strapi }) => { types: [fileInfoInputType, mutations], resolversConfig: { // Use custom scopes for the upload file CRUD operations - ['Query.uploadFiles']: { auth: { scope: 'plugin::upload.content-api.find' } }, - ['Query.uploadFile']: { auth: { scope: 'plugin::upload.content-api.findOne' } }, ['Mutation.createUploadFile']: { auth: { scope: 'plugin::upload.content-api.upload' } }, ['Mutation.updateUploadFile']: { auth: { scope: 'plugin::upload.content-api.upload' } }, ['Mutation.deleteUploadFile']: { auth: { scope: 'plugin::upload.content-api.destroy' } }, diff --git a/packages/plugins/graphql/server/services/builders/type.js b/packages/plugins/graphql/server/services/builders/type.js index b0022118ab..b3119404f6 100644 --- a/packages/plugins/graphql/server/services/builders/type.js +++ b/packages/plugins/graphql/server/services/builders/type.js @@ -150,12 +150,6 @@ module.exports = context => { const type = attribute.multiple ? naming.getRelationResponseCollectionName(fileContentType) : naming.getEntityResponseName(fileContentType); - const resolverPath = `${naming.getTypeName(contentType)}.${attributeName}`; - const resolverAuthScope = `${fileUID}.find`; - - extension.use({ - resolversConfig: { [resolverPath]: { auth: { scope: [resolverAuthScope] } } }, - }); builder.field(attributeName, { type, resolve, args }); }; From 76fd36acffde20460422ddf926d1c52a4ca23e54 Mon Sep 17 00:00:00 2001 From: Convly Date: Wed, 24 Nov 2021 17:03:24 +0100 Subject: [PATCH 2/2] Reintroduce custom scope for find & findOne upload files --- packages/core/upload/server/graphql.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/core/upload/server/graphql.js b/packages/core/upload/server/graphql.js index a4caeeb2d9..09df6e9162 100644 --- a/packages/core/upload/server/graphql.js +++ b/packages/core/upload/server/graphql.js @@ -188,6 +188,8 @@ module.exports = ({ strapi }) => { types: [fileInfoInputType, mutations], resolversConfig: { // Use custom scopes for the upload file CRUD operations + ['Query.uploadFiles']: { auth: { scope: 'plugin::upload.content-api.find' } }, + ['Query.uploadFile']: { auth: { scope: 'plugin::upload.content-api.findOne' } }, ['Mutation.createUploadFile']: { auth: { scope: 'plugin::upload.content-api.upload' } }, ['Mutation.updateUploadFile']: { auth: { scope: 'plugin::upload.content-api.upload' } }, ['Mutation.deleteUploadFile']: { auth: { scope: 'plugin::upload.content-api.destroy' } },