From 7970830de22418a278490db51c57a6e9030bc33f Mon Sep 17 00:00:00 2001 From: maerzman <20152088@atn.ac.at> Date: Thu, 25 Jul 2024 10:54:20 +0200 Subject: [PATCH] #233 added reviewThreads and comments for each mergeRequest --- foxx/types/mergeRequest.js | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/foxx/types/mergeRequest.js b/foxx/types/mergeRequest.js index f3e3d9d5..cff326a2 100644 --- a/foxx/types/mergeRequest.js +++ b/foxx/types/mergeRequest.js @@ -2,6 +2,9 @@ const gql = require('graphql-sync'); const Timestamp = require('./Timestamp'); +const arangodb = require('@arangodb'); +const db = arangodb.db; +const aql = arangodb.aql; module.exports = new gql.GraphQLObjectType({ name: 'mergeRequest', @@ -61,6 +64,40 @@ module.exports = new gql.GraphQLObjectType({ type: new gql.GraphQLList(require('./gitlabNote.js')), description: 'Notes attached to the Merge Request', }, + comments: { + type: new gql.GraphQLList(require('./comment.js')), + description: 'The comments belonging to the mergeRequest', + resolve(mergeRequest) { + return db + ._query( + aql` + FOR mrc IN \`mergeRequests-comments\` + FILTER mrc._from == ${mergeRequest._id} + FOR comment IN comments + FILTER mrc._to == comment._id + RETURN comment + `, + ) + .toArray(); + }, + }, + reviewThreads: { + type: new gql.GraphQLList(require('./reviewThread.js')), + description: 'The review threads belonging to this mergeRequest', + resolve(reviewThread) { + return db + ._query( + aql` + FOR mrr IN \`mergeRequests-reviewThreads\` + FILTER mrr._from == ${reviewThread._id} + FOR reviewThread IN reviewThreads + FILTER reviewThread._id == mrr._to + RETURN reviewThread + `, + ) + .toArray(); + }, + }, }; }, });