./ct_report/coverage/mongoose_graphql_roster_user_query.COVER.html

1 -module(mongoose_graphql_roster_user_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(Ctx, Args);
14 execute(Ctx, _Obj, <<"getContact">>, Args) ->
15
:-(
get_contact(Ctx, Args).
16
17 -spec list_contacts(mongoose_graphql:context(), mongoose_graphql:args()) ->
18 {ok, mongoose_graphql_roster:contact_list()} | {error, resolver_error()}.
19 list_contacts(#{user := UserJID}, #{}) ->
20
:-(
{ok, Contacts} = mod_roster_api:list_contacts(UserJID),
21
:-(
{ok, [mongoose_graphql_roster:make_ok_roster(C) || C <- Contacts]}.
22
23 -spec get_contact(mongoose_graphql:context(), mongoose_graphql:args()) ->
24 {ok, mongoose_graphql_roster:contact()} | {error, resolver_error()}.
25 get_contact(#{user := UserJID}, #{<<"contact">> := ContactJID}) ->
26
:-(
case mod_roster_api:get_contact(UserJID, ContactJID) of
27 {ok, Contact} ->
28
:-(
mongoose_graphql_roster:make_ok_roster(Contact);
29 Error ->
30
:-(
make_error(Error, #{contact => jid:to_binary(ContactJID)})
31 end.
Line Hits Source