Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const resolvers = {
- Query: {
- async feed(parent, { authorId }, ctx, info) {
- // build filter
- const authorFilter = authorId ? { author: { id: authorId } } : {}
- // retrieve (potentially filtered) posts
- const posts = await ctx.db.query.posts({ where: authorFilter })
- // retrieve (potentially filtered) element count
- const postsConnection = await ctx.db.query.postsConnection(
- { where: authorFilter },
- `{ aggregate { count } }`,
- )
- return {
- count: postsConnection.aggregate.count,
- posts: posts,
- }
- },
- },
- }
Add Comment
Please, Sign In to add comment