Add ability to list users

This commit is contained in:
Chocobozzz
2019-03-01 11:41:28 +01:00
committed by Thomas Citharel
parent 6ee3233cc6
commit a0123459b3
7 changed files with 182 additions and 13 deletions

View File

@@ -24,6 +24,20 @@ defmodule MobilizonWeb.Resolvers.User do
{:error, "You need to be logged-in to view current user"}
end
@doc """
List instance users
"""
def list_and_count_users(
_parent,
%{page: page, limit: limit, sort: sort, direction: direction},
_resolution
) do
total = Task.async(&Actors.count_users/0)
elements = Task.async(fn -> Actors.list_users(page, limit, sort, direction) end)
{:ok, %{total: Task.await(total), elements: Task.await(elements)}}
end
@doc """
Login an user. Returns a token and the user
"""