How to pass query parameters from Graphql Playground?

Viewed 131

Here is my arrow function:

getUsers: async (
        _,  
        { offset = 0, limit = 10 },
        { req: { baseUserId } },     // How to pass this parameter from graphql playground
    ) => {
        console.log(baseUserId);
        return await tryCatch(async () => {
            const baseUser = await auth(baseUserId)  
            if (baseUser.userType !== 0) throw new Error('Error Found')

            const users = await User.find({})
                .populate('baseUser')
                .sort({ createdAt: 'desc' })
                .skip(offset)
                .limit(limit)
                .exec()  
            const result = users.filter((user) => user && user.baseUser)
            return users
        })
    },

Here is my graphql playground query:

query Read{
  getUsers(offset: 0, limit: 3) {
   _id
   createdAt
   updatedAt
   otherOccupations
 }
}

I don't know how to pass { req: { baseUserId } }, this parameter from query.

If any one knows please help.

Thanks in advance.

0 Answers
Related