Skip to content

Commit

Permalink
#233 added reviewThreads and comments for each mergeRequest
Browse files Browse the repository at this point in the history
  • Loading branch information
maerzman committed Jul 25, 2024
1 parent e6dcf7f commit 7970830
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions foxx/types/mergeRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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();
},
},
};
},
});

0 comments on commit 7970830

Please sign in to comment.