1 |
|
-module(mongoose_graphql_domain_admin_query). |
2 |
|
-behaviour(mongoose_graphql). |
3 |
|
|
4 |
|
-export([execute/4]). |
5 |
|
|
6 |
|
-ignore_xref([execute/4]). |
7 |
|
|
8 |
|
-import(mongoose_graphql_helper, [format_result/2]). |
9 |
|
|
10 |
|
-include("../mongoose_graphql_types.hrl"). |
11 |
|
|
12 |
|
execute(_Ctx, admin, <<"domainsByHostType">>, #{<<"hostType">> := HostType}) -> |
13 |
:-( |
case mongoose_domain_api:check_host_type_and_get_domains(HostType) of |
14 |
|
{ok, Domains} -> |
15 |
:-( |
Domains2 = lists:map(fun(D) -> {ok, D} end, Domains), |
16 |
:-( |
{ok, Domains2}; |
17 |
|
Error -> |
18 |
:-( |
format_result(Error, #{hostType => HostType}) |
19 |
|
end; |
20 |
|
execute(_Ctx, admin, <<"domainDetails">>, #{<<"domain">> := Domain}) -> |
21 |
:-( |
format_result(mongoose_domain_api:get_domain_details(Domain), #{domain => Domain}). |