Skip to content
Snippets Groups Projects
Commit f1dab50d authored by Grigor Malo's avatar Grigor Malo
Browse files

feat(models): enable query users by their data

parent 8d65cce9
No related branches found
No related tags found
3 merge requests!52Docx,!26Paginate users query result,!17Graphql api
This commit is part of merge request !26. Comments created here will be created in the context of that merge request.
......@@ -83,7 +83,7 @@ const getUser = async (id, options = {}) => {
const getDisplayName = async user => user.getDisplayName()
const getUsers = async (options = {}) => {
const getUsers = async (data = {}, options = {}) => {
try {
const { trx, ...restOptions } = options
return useTransaction(
......@@ -91,7 +91,7 @@ const getUsers = async (options = {}) => {
logger.info(
`${USER_CONTROLLER} getUsers: fetching all users based on provided options ${restOptions}`,
)
return User.find({}, { trx: tr, ...restOptions })
return User.find(data, { trx: tr, ...restOptions })
},
{ trx, passedTrxOnly: true },
)
......
......@@ -68,9 +68,13 @@ input UpdatePasswordInput {
newPassword: String!
}
input UsersQueryOptions {
isActive: Boolean
}
extend type Query {
user(id: ID): User
users(options: PageInput): Users!
users(data: UsersQueryOptions, options: PageInput): Users!
currentUser: User!
}
......
......@@ -38,10 +38,10 @@ const userResolver = async (_, { id }, ctx) => {
}
}
const usersResolver = async (_, { options }, ctx) => {
const usersResolver = async (_, { data, options }, ctx) => {
try {
logger.error(`${USER_RESOLVER} users`)
return getUsers(options)
return getUsers(data, options)
} catch (e) {
logger.error(`${USER_RESOLVER} users: ${e.message}`)
throw new Error(e)
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment