-
Notifications
You must be signed in to change notification settings - Fork 426
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separate admin and user api in schema and resources
- Loading branch information
Showing
8 changed files
with
112 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
-module(mongoose_graphql_admin_mutation). | ||
|
||
-export([execute/4]). | ||
|
||
-ignore_xref([execute/4]). | ||
|
||
-include("mongoose_graphql_types.hrl"). | ||
|
||
execute(_Ctx, admin, <<"addDomain">>, #{<<"domain">> := Domain, <<"hostType">> := HostType}) -> | ||
case mongoose_domain_api:insert_domain(Domain, HostType) of | ||
ok -> | ||
{ok, #domain{domain = Domain, host_type = HostType}}; | ||
{error, _} = Err -> | ||
Err | ||
end; | ||
execute(_Ctx, admin, <<"removeDomain">>, #{<<"domain">> := Domain, <<"hostType">> := HostType}) -> | ||
case mongoose_domain_api:delete_domain(Domain, HostType) of | ||
ok -> | ||
DomainObj = #domain{domain = Domain, host_type = HostType}, | ||
{ok, #{<<"domain">> => DomainObj, <<"msg">> => <<"Domain removed!">>}}; | ||
{error, _} = Err -> | ||
Err | ||
end; | ||
execute(_Ctx, admin, <<"enableDomain">>, #{<<"domain">> := Domain}) -> | ||
case mongoose_domain_api:enable_domain(Domain) of | ||
ok -> | ||
{ok, #domain{enabled = true, domain = Domain}}; | ||
{error, _} = Err -> | ||
Err | ||
end; | ||
execute(_Ctx, admin, <<"disableDomain">>, #{<<"domain">> := Domain}) -> | ||
case mongoose_domain_api:disable_domain(Domain) of | ||
ok -> | ||
{ok, #domain{enabled = false, domain = Domain}}; | ||
{error, _} = Err -> | ||
Err | ||
end. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
-module(mongoose_graphql_admin_query). | ||
|
||
-export([execute/4]). | ||
|
||
-ignore_xref([execute/4]). | ||
|
||
-include("mongoose_graphql_types.hrl"). | ||
|
||
execute(_Ctx, admin, <<"domainsByHostType">>, #{<<"hostType">> := HostType}) -> | ||
Domains = mongoose_domain_api:get_domains_by_host_type(HostType), | ||
Domains2 = lists:map(fun(D) -> {ok, D} end, Domains), | ||
{ok, Domains2}; | ||
execute(_Ctx, admin, <<"domainDetails">>, #{<<"domain">> := Domain}) -> | ||
case mongoose_domain_sql:select_domain(Domain) of | ||
{ok, #{host_type := HostType, enabled := Enabled}} -> | ||
{ok, #domain{host_type = HostType, domain = Domain, | ||
enabled = Enabled}}; | ||
{error, not_found} -> | ||
{error, not_found} | ||
end. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
-module(mongoose_graphql_user_mutation). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
-module(mongoose_graphql_user_query). |