feat(gql): implemented resolvers & tests for stream commits & branch commits

This commit is contained in:
Dimitrie Stefanescu
2020-07-22 10:58:08 +01:00
parent 0fe6a0f4af
commit b14dae6829
6 changed files with 152 additions and 41 deletions
+2 -5
View File
@@ -10,7 +10,8 @@ const {
updateCommit,
deleteCommit,
getCommitsByBranchId,
getCommitsByBranchName
getCommitsByBranchName,
getCommitsTotalCountByBranchId
} = require( '../../services/commits' )
const {
@@ -42,10 +43,6 @@ module.exports = {
async author( parent, args, context, info ) {
return await getUserById( { userId: parent.authorId } )
},
async commits( parent, args, context, info ) {
throw new ApolloError( 'not implemented' )
}
},
+14 -5
View File
@@ -13,7 +13,10 @@ const {
getCommitsByBranchId,
getCommitsByBranchName,
getCommitsByUserId,
getCommitsTotalCountByUserId
getCommitsByStreamId,
getCommitsTotalCountByStreamId,
getCommitsTotalCountByUserId,
getCommitsTotalCountByBranchId
} = require( '../../services/commits' )
const {
@@ -28,6 +31,13 @@ module.exports = {
Query: {},
Stream: {
async commits( parent, args, context, info ) {
let { commits: items, cursor } = await getCommitsByStreamId( { streamId: parent.id, limit: args.limit, cursor: args.cursor } )
let totalCount = await getCommitsTotalCountByStreamId( { streamId: parent.id } )
return { items, cursor, totalCount }
},
async commit( parent, args, context, info ) {
throw new ApolloError( 'not implemented' )
}
@@ -46,13 +56,12 @@ module.exports = {
},
Branch: {
async commits( parent, args, context, info ) {
let { commits, cursor } = await getCommitsByBranchId( { branchId: parent.id, limit: args.limit, cursor: args.cursor } )
let totalCount = await getCommitsTotalCountByBranchId( { branchId: parent.id } )
throw new ApolloError( 'not implemented' )
return { items: commits, totalCount, cursor }
}
},
Mutation: {
@@ -22,12 +22,13 @@ type Commit {
referencedObject: String!
realObject: Object
message: String
author: String
authorName: String
authorId: String
createdAt: String
}
type CommitCollectionUserNode {
commitId: String!
id: String!
referencedObject: String!
realObject: Object
message: String