Skip to content

Commit 65ecd11

Browse files
committed
total count
1 parent b4fb468 commit 65ecd11

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

server/resolvers/post.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,15 @@ const postDelete = async (parent, args, { req }) => {
108108
return deletedPost;
109109
};
110110

111+
const totalPosts = async (parent, args, { req }) =>
112+
await Post.find().estimatedDocumentCount().exec();
113+
111114
module.exports = {
112115
Query: {
113116
allPosts,
114117
postsByUser,
115118
singlePost,
119+
totalPosts,
116120
},
117121
Mutation: {
118122
postCreate,

server/typedefs/post.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ module.exports = gql`
2424
allPosts: [Post!]!
2525
postsByUser: [Post!]!
2626
singlePost(postId: String): Post!
27+
totalPosts: Int!
2728
}
2829
2930
# Mutations

0 commit comments

Comments
 (0)