Skip to content

Calling a query inside a mutation #2929

Answered by zackshen
spidertwin2 asked this question in Q&A
Discussion options

You must be logged in to vote

hi @spidertwin2 , the code like below,

import getBlogs from './getBlogs'

export default resolver.pipe(resolver.authorize(), async (userIds: string[], ctx) => {
  try {
     const userBlogs = await Promise.all(userIds.map((userId) => getBlogs(userId).then(blogs => ({ userId, blogs}))))
     return userBlogs
  } catch (error) {
    console.log("Error updating users: ", error)
  }
})

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@spidertwin2
Comment options

Answer selected by spidertwin2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants