-
Notifications
You must be signed in to change notification settings - Fork 428
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Janusz Jakubiec
authored and
Janusz Jakubiec
committed
May 9, 2022
1 parent
574f1bb
commit c807c9a
Showing
12 changed files
with
298 additions
and
175 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,13 @@ | ||
""" | ||
Allow user to set its vcard | ||
""" | ||
type VcardUserMutation @protected{ | ||
setVcard(vcard: VcardInput!): Vcard | ||
} | ||
|
||
""" | ||
Allow user to get its vcard | ||
""" | ||
type VcardUserQuery @protected{ | ||
getVcard: Vcard | ||
} |
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
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
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,23 @@ | ||
-module(mongoose_graphql_vcard_user_mutation). | ||
-behaviour(mongoose_graphql). | ||
|
||
-include("mod_vcard.hrl"). | ||
|
||
-export([execute/4]). | ||
|
||
-import(mongoose_graphql_helper, [make_error/2, format_result/2, null_to_default/2]). | ||
|
||
-ignore_xref([execute/4]). | ||
|
||
-include("../mongoose_graphql_types.hrl"). | ||
-include("mongoose.hrl"). | ||
-include("jlib.hrl"). | ||
|
||
execute(#{user := CallerJID}, vcard, <<"setVcard">>, #{<<"vcard">> := VCARD}) -> | ||
case mod_vcard_api:set_vcard(CallerJID, VCARD) of | ||
{ok, _} = Vcard -> Vcard; | ||
{error, not_found} -> | ||
make_error({error, "User does not exist"}, #{user => CallerJID}); | ||
_ -> | ||
make_error({error, "Internal server error"}, #{user => CallerJID}) | ||
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,21 @@ | ||
-module(mongoose_graphql_vcard_user_query). | ||
-behaviour(mongoose_graphql). | ||
|
||
-export([execute/4]). | ||
|
||
-import(mongoose_graphql_helper, [make_error/2, format_result/2, null_to_default/2]). | ||
|
||
-ignore_xref([execute/4]). | ||
|
||
-include("../mongoose_graphql_types.hrl"). | ||
-include("mongoose.hrl"). | ||
-include("jlib.hrl"). | ||
|
||
execute(#{user := CallerJID}, vcard, <<"getVcard">>, _) -> | ||
case mod_vcard_api:get_vcard(CallerJID) of | ||
{ok, _} = Vcard -> Vcard; | ||
{error, not_found} -> | ||
make_error({error, "User does not exist"}, #{user => CallerJID}); | ||
_ -> | ||
make_error({error, "Internal server error"}, #{user => CallerJID}) | ||
end. |