feat(gql): implemented resolvers & tests for stream commits & branch commits
This commit is contained in:
@@ -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' )
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user