./ct_report/coverage/mongoose_graphql_roster_admin_query.COVER.html

1 -module(mongoose_graphql_roster_admin_query).
2 -behaviour(mongoose_graphql).
3
4 -export([execute/4]).
5
6 -ignore_xref([execute/4]).
7
8 -include("../mongoose_graphql_types.hrl").
9
10 -import(mongoose_graphql_helper, [make_error/2, format_result/2]).
11
12 execute(_Ctx, _Obj, <<"listContacts">>, Args) ->
13
:-(
list_contacts(Args);
14 execute(_Ctx, _Obj, <<"getContact">>, Args) ->
15
:-(
get_contact(Args).
16
17 -spec list_contacts(mongoose_graphql:args()) ->
18 {ok, mongoose_graphql_roster:contact_list()} | {error, resolver_error()}.
19 list_contacts(#{<<"user">> := UserJID}) ->
20
:-(
case mod_roster_api:list_contacts(UserJID) of
21 {ok, Contacts} ->
22
:-(
{ok, [mongoose_graphql_roster:make_ok_roster(C) || C <- Contacts]};
23 Error ->
24
:-(
make_error(Error, #{user => jid:to_binary(UserJID)})
25 end.
26
27 -spec get_contact(mongoose_graphql:args()) ->
28 {ok, mongoose_graphql_roster:contact()} | {error, resolver_error()}.
29 get_contact(#{<<"user">> := UserJID, <<"contact">> := ContactJID}) ->
30
:-(
case mod_roster_api:get_contact(UserJID, ContactJID) of
31 {ok, Contact} ->
32
:-(
mongoose_graphql_roster:make_ok_roster(Contact);
33 Error ->
34
:-(
make_error(Error, #{contact => jid:to_binary(ContactJID),
35 user => jid:to_binary(UserJID)})
36 end.
Line Hits Source