From 957bee1f6af9780dfbbd9dae2133bb9019e341b9 Mon Sep 17 00:00:00 2001 From: Thomas Parisot Date: Thu, 19 Dec 2024 10:34:52 +0100 Subject: [PATCH] =?UTF-8?q?fix(workspace):=20r=C3=A9utilise=20une=20requ?= =?UTF-8?q?=C3=AAte=20existante=20pour=20filter=20les=20articles?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On garantit un fonctionnement similaire à d'autres endroits de l'application, avec un code plus facile à lire. --- graphql/resolvers/workspaceResolver.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/graphql/resolvers/workspaceResolver.js b/graphql/resolvers/workspaceResolver.js index 20685d2d0..8128177ad 100644 --- a/graphql/resolvers/workspaceResolver.js +++ b/graphql/resolvers/workspaceResolver.js @@ -118,11 +118,11 @@ module.exports = { * @param {{ loaders: { articles } }} context * @returns {Promise<*>} */ - async articles (workspace, _args, context) { - const articles = (await Promise.all(workspace.articles.map((articleId) => context.loaders.articles.load(articleId)))) - .filter((a) => a !== undefined) // remove deleted articles - articles.sort((a, b) => a.createdAt > b.createdAt ? -1 : 1) - return Article.complete(articles, context.loaders) + async articles(workspace, _args, context) { + return Article.getArticles({ + filter: { _id: { $in: workspace.articles } }, + loaders: context.loaders, + }) }, async corpus(workspace) {