-
Notifications
You must be signed in to change notification settings - Fork 428
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stanza api for graphql #3483
Stanza api for graphql #3483
Conversation
This comment has been minimized.
This comment has been minimized.
Codecov Report
@@ Coverage Diff @@
## feature/graphql #3483 +/- ##
===================================================
+ Coverage 80.82% 80.88% +0.06%
===================================================
Files 427 433 +6
Lines 32578 32653 +75
===================================================
+ Hits 26330 26412 +82
+ Misses 6248 6241 -7
Continue to review full report at Codecov.
|
2778c9b
to
9113508
Compare
This comment has been minimized.
This comment has been minimized.
Update graphql_helper with new helpers Put tests into graphql_stanza_SUITE Add new types StanzaAdminMutation and StanzaAdminQuery
9113508
to
6a6a587
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me :D I have only minor suggestions. I noticed that in this PR only the admin API was implemented, so we need to implement the user API in another PR.
src/mongoose_graphql/admin/mongoose_graphql_admin_stanza_mutation.erl
Outdated
Show resolved
Hide resolved
src/mongoose_graphql/admin/mongoose_graphql_admin_stanza_mutation.erl
Outdated
Show resolved
Hide resolved
Please wait with the merge for my review, I will finish no later than tomorrow morning. |
small_tests_24 / small_tests / 136e370 small_tests_23 / small_tests / 136e370 dynamic_domains_pgsql_mnesia_23 / pgsql_mnesia / 136e370 dynamic_domains_pgsql_mnesia_24 / pgsql_mnesia / 136e370 dynamic_domains_mysql_redis_24 / mysql_redis / 136e370 dynamic_domains_mssql_mnesia_24 / odbc_mssql_mnesia / 136e370 ldap_mnesia_23 / ldap_mnesia / 136e370 rest_client_SUITE:messages:msg_is_sent_and_delivered_over_sse{error,{{badmap,{error,timeout}},
[{erlang,map_get,[data,{error,timeout}],[]},
{rest_client_SUITE,msg_is_sent_and_delivered_over_sse,1,
[{file,"/home/circleci/project/big_tests/tests/rest_client_SUITE.erl"},
{line,217}]},
{test_server,ts_tc,3,[{file,"test_server.erl"},{line,1754}]},
{test_server,run_test_case_eval1,6,
[{file,"test_server.erl"},{line,1263}]},
{test_server,run_test_case_eval,9,
[{file,"test_server.erl"},{line,1195}]}]}} ldap_mnesia_24 / ldap_mnesia / 136e370 internal_mnesia_24 / internal_mnesia / 136e370 pgsql_mnesia_24 / pgsql_mnesia / 136e370 pgsql_mnesia_23 / pgsql_mnesia / 136e370 elasticsearch_and_cassandra_24 / elasticsearch_and_cassandra_mnesia / 136e370 mysql_redis_24 / mysql_redis / 136e370 mssql_mnesia_24 / odbc_mssql_mnesia / 136e370 riak_mnesia_24 / riak_mnesia / 136e370 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code looks good, I like how we avoid calling modules from the old API like mod_commands
. I have a few minor comments.
src/mongoose_graphql/admin/mongoose_graphql_admin_stanza_mutation.erl
Outdated
Show resolved
Hide resolved
src/mongoose_graphql/admin/mongoose_graphql_admin_stanza_query.erl
Outdated
Show resolved
Hide resolved
src/mongoose_graphql/admin/mongoose_graphql_admin_stanza_mutation.erl
Outdated
Show resolved
Hide resolved
Set default limit to 50 in schema
136e370
to
1fccf9c
Compare
small_tests_23 / small_tests / 1fccf9c small_tests_24 / small_tests / 1fccf9c dynamic_domains_mysql_redis_24 / mysql_redis / 1fccf9c graphql_stanza_SUITE:admin_stanza_category:get_last_messages_for_unknown_user{error,{{assertEqual,[{module,graphql_stanza_SUITE},
{line,214},
{expression,"ErrMsg"},
{expected,<<"#{jid => <<\"maybemaybebutnot@localhost\">>,what => non_existing_user}">>},
{value,<<"#{jid => <<\"[email protected]\">>,what => non_existing_user}">>}]},
[{graphql_stanza_SUITE,get_last_messages_for_unknown_user,1,
[{file,"/home/circleci/project/big_tests/tests/graphql_stanza_SUITE.erl"},
{line,214}]},
{test_server,ts_tc,3,[{file,"test_server.erl"},{line,1783}]},
{test_server,run_test_case_eval1,6,
[{file,"test_server.erl"},{line,1292}]},
{test_server,run_test_case_eval,9,
[{file,"test_server.erl"},{line,1224}]}]}} dynamic_domains_pgsql_mnesia_23 / pgsql_mnesia / 1fccf9c graphql_stanza_SUITE:admin_stanza_category:get_last_messages_for_unknown_user{error,{{assertEqual,[{module,graphql_stanza_SUITE},
{line,214},
{expression,"ErrMsg"},
{expected,<<"#{jid => <<\"maybemaybebutnot@localhost\">>,what => non_existing_user}">>},
{value,<<"#{jid => <<\"[email protected]\">>,what => non_existing_user}">>}]},
[{graphql_stanza_SUITE,'-get_last_messages_for_unknown_user/1-fun-1-',
1,
[{file,"/home/circleci/project/big_tests/tests/graphql_stanza_SUITE.erl"},
{line,214}]},
{test_server,ts_tc,3,[{file,"test_server.erl"},{line,1754}]},
{test_server,run_test_case_eval1,6,
[{file,"test_server.erl"},{line,1263}]},
{test_server,run_test_case_eval,9,
[{file,"test_server.erl"},{line,1195}]}]}} dynamic_domains_mssql_mnesia_24 / odbc_mssql_mnesia / 1fccf9c graphql_stanza_SUITE:admin_stanza_category:get_last_messages_for_unknown_user{error,{{assertEqual,[{module,graphql_stanza_SUITE},
{line,214},
{expression,"ErrMsg"},
{expected,<<"#{jid => <<\"maybemaybebutnot@localhost\">>,what => non_existing_user}">>},
{value,<<"#{jid => <<\"[email protected]\">>,what => non_existing_user}">>}]},
[{graphql_stanza_SUITE,get_last_messages_for_unknown_user,1,
[{file,"/home/circleci/project/big_tests/tests/graphql_stanza_SUITE.erl"},
{line,214}]},
{test_server,ts_tc,3,[{file,"test_server.erl"},{line,1783}]},
{test_server,run_test_case_eval1,6,
[{file,"test_server.erl"},{line,1292}]},
{test_server,run_test_case_eval,9,
[{file,"test_server.erl"},{line,1224}]}]}} ldap_mnesia_24 / ldap_mnesia / 1fccf9c ldap_mnesia_23 / ldap_mnesia / 1fccf9c sm_SUITE:parallel_manual_ack_freq_1:resume_session_state_stop_c2s{error,{thrown,{timeout,msg}}} dynamic_domains_pgsql_mnesia_24 / pgsql_mnesia / 1fccf9c graphql_stanza_SUITE:admin_stanza_category:get_last_messages_for_unknown_user{error,{{assertEqual,[{module,graphql_stanza_SUITE},
{line,214},
{expression,"ErrMsg"},
{expected,<<"#{jid => <<\"maybemaybebutnot@localhost\">>,what => non_existing_user}">>},
{value,<<"#{jid => <<\"[email protected]\">>,what => non_existing_user}">>}]},
[{graphql_stanza_SUITE,get_last_messages_for_unknown_user,1,
[{file,"/home/circleci/project/big_tests/tests/graphql_stanza_SUITE.erl"},
{line,214}]},
{test_server,ts_tc,3,[{file,"test_server.erl"},{line,1783}]},
{test_server,run_test_case_eval1,6,
[{file,"test_server.erl"},{line,1292}]},
{test_server,run_test_case_eval,9,
[{file,"test_server.erl"},{line,1224}]}]}} internal_mnesia_24 / internal_mnesia / 1fccf9c pgsql_mnesia_23 / pgsql_mnesia / 1fccf9c mysql_redis_24 / mysql_redis / 1fccf9c elasticsearch_and_cassandra_24 / elasticsearch_and_cassandra_mnesia / 1fccf9c mssql_mnesia_24 / odbc_mssql_mnesia / 1fccf9c riak_mnesia_24 / riak_mnesia / 1fccf9c sm_SUITE:parallel_manual_ack_freq_1:resume_session_state_send_message{error,
{{assertion_failed,assert_many,true,
[#Fun<sm_SUITE.22.68776247>,#Fun<sm_SUITE.22.68776247>,
#Fun<sm_SUITE.22.68776247>],
[{xmlel,<<"presence">>,
[{<<"from">>,
<<"alicE_resume_session_state_send_message_1659@localhost/escalus-default-resource">>},
{<<"to">>,
<<"alice_resume_session_state_send_message_1659@localhost/escalus-default-resource">>},
{<<"xml:lang">>,<<"en">>}],
[]},
{xmlel,<<"message">>,
[{<<"from">>,
<<"bOb_resume_session_state_send_message_1652@localhost/escalus-default-resource">>},
{<<"to">>,
<<"alicE_resume_session_state_send_message_1659@localhost">>},
{<<"xml:lang">>,<<"en">>},
{<<"type">>,<<"chat">>}],
[{xmlel,<<"body">>,[],[{xmlcdata,<<"msg-1">>}]},
{xmlel,<<"delay">>,
[{<<"xmlns">>,<<"urn:xmpp:delay">>},
{<<"stamp">>,<<"2022-01-10T20:49:59.155762Z">>},
{<<"from">>,<<"localhost">>}],
[{xmlcdata,<<"SM Storage">>}]}]},
{xmlel,<<"message">>,
[{<<"from">>,
<<"bOb_resume_session_state_send_message_1652@localhost/escalus-default-resource">>},
{<<"to">>,
<<"alicE_resume_session_state_send_message_1659@localhost">>},
{<<"xml:lang">>,<<"en">>},
{<<"type">>,<<"chat">>}],
[{xmlel,<<"body">>,[],[{xmlcdata,<<"msg-2">>}]},
{xmlel,<<"delay">>,
[{<<"xmlns">>,<<"urn:xmpp:delay">>},
{<<"stamp... |
1fccf9c
to
b483730
Compare
small_tests_24 / small_tests / b483730 small_tests_23 / small_tests / b483730 dynamic_domains_pgsql_mnesia_23 / pgsql_mnesia / b483730 dynamic_domains_mssql_mnesia_24 / odbc_mssql_mnesia / b483730 dynamic_domains_mysql_redis_24 / mysql_redis / b483730 ldap_mnesia_23 / ldap_mnesia / b483730 ldap_mnesia_24 / ldap_mnesia / b483730 dynamic_domains_pgsql_mnesia_24 / pgsql_mnesia / b483730 sm_SUITE:parallel:messages_are_properly_flushed_during_resumption_p1_fsm_old{error,
{{badmatch,
{error,
{connection_step_failed,
{#Fun<sm_SUITE.11.68776247>,
{client,
<<"alicE_messages_are_properly_flushed_during_resumption_p1_fsm_old_1933@domain.example.com">>,
escalus_tcp,<0.32526.1>,undefined,
[{username,
<<"alicE_messages_are_properly_flushed_during_resumption_p1_fsm_old_1933">>},
{server,<<"domain.example.com">>},
{host,<<"localhost">>},
{password,<<"matygrysa">>},
{stream_management,true},
{stream_id,<<"931769b3b9ded6f9">>}]},
[{compression,[<<"zlib">>]},
{starttls,true},
{stream_management,true},
{advanced_message_processing,true},
{client_state_indication,false},
{sasl_mechanisms,[<<"SCRAM-SHA-256">>,<<"PLAIN">>]},
{caps,undefined}]},
{timeout,get_resumed}}}},
[{sm_SUITE,
'-messages_are_properly_flushed_during_resumption_p1_fsm_old/1-fun-1-',
3,
[{file,"/home/circleci/project/big_tests/tests/sm_SUITE.erl"},
{line,1270}]},
{escalus_story,story,4,
[{file,
"/home/circleci/project/big_tests/_build/default/lib/escalus/src/escalus_story.erl"},
{line,72}]},
{test_server,ts_tc,3,[{file,"test_server.erl"},{line,1783}]},
{test_server,run_test_case_eval1,6,
[{file,"test_server.erl"},{line,1292}]},
{test_server,run_test_case_eval,9,
[{file,"test_se... internal_mnesia_24 / internal_mnesia / b483730 elasticsearch_and_cassandra_24 / elasticsearch_and_cassandra_mnesia / b483730 mysql_redis_24 / mysql_redis / b483730 pgsql_mnesia_23 / pgsql_mnesia / b483730 pgsql_mnesia_24 / pgsql_mnesia / b483730 mssql_mnesia_24 / odbc_mssql_mnesia / b483730 riak_mnesia_24 / riak_mnesia / b483730 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks good in general, but I'd like to see the type specs which are missing from the new modules.
true -> | ||
{ok, HostType}; | ||
false -> | ||
{error, #{what => non_existing_user, jid => jid:to_binary(Jid)}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{error, #{what => non_existing_user, jid => jid:to_binary(Jid)}} | |
{error, #{what => non_existing_user, jid => jid:to_binary(Jid)}} |
-include("jlib.hrl"). | ||
-include("mongoose_rsm.hrl"). | ||
|
||
lookup_recent_messages(_, _, _, Limit) when Limit > 500 -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add type specs to this module
{ok, #{<<"stanzas">> => Maps, <<"limit">> => Limit2}}. | ||
|
||
maybe_datetime_to_seconds(null) -> undefined; | ||
maybe_datetime_to_seconds(Microseconds) -> Microseconds / 1000000. %% Could be float |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we convert it to float instead of just passing Microseconds
? We divide by 1M just to multiply by 1M later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to be compatible with mod_commands way of calling actually (it passes before as seconds)
small_tests_23 / small_tests / 1f146ab small_tests_24 / small_tests / 1f146ab dynamic_domains_mysql_redis_24 / mysql_redis / 1f146ab dynamic_domains_pgsql_mnesia_24 / pgsql_mnesia / 1f146ab dynamic_domains_pgsql_mnesia_23 / pgsql_mnesia / 1f146ab ldap_mnesia_24 / ldap_mnesia / 1f146ab ldap_mnesia_23 / ldap_mnesia / 1f146ab internal_mnesia_24 / internal_mnesia / 1f146ab sm_SUITE:parallel_manual_ack_freq_1:resume_session_state_send_message{error,
{{assertion_failed,assert_many,true,
[#Fun<sm_SUITE.22.68776247>,#Fun<sm_SUITE.22.68776247>,
#Fun<sm_SUITE.22.68776247>],
[{xmlel,<<"presence">>,
[{<<"from">>,
<<"alicE_resume_session_state_send_message_1459@localhost/escalus-default-resource">>},
{<<"to">>,
<<"alice_resume_session_state_send_message_1459@localhost/escalus-default-resource">>},
{<<"xml:lang">>,<<"en">>}],
[]},
{xmlel,<<"message">>,
[{<<"from">>,
<<"bOb_resume_session_state_send_message_1451@localhost/escalus-default-resource">>},
{<<"to">>,
<<"alicE_resume_session_state_send_message_1459@localhost">>},
{<<"xml:lang">>,<<"en">>},
{<<"type">>,<<"chat">>}],
[{xmlel,<<"body">>,[],[{xmlcdata,<<"msg-1">>}]},
{xmlel,<<"delay">>,
[{<<"xmlns">>,<<"urn:xmpp:delay">>},
{<<"stamp">>,<<"2022-01-11T12:22:25.374611Z">>},
{<<"from">>,<<"localhost">>}],
[{xmlcdata,<<"SM Storage">>}]}]},
{xmlel,<<"message">>,
[{<<"from">>,
<<"bOb_resume_session_state_send_message_1451@localhost/escalus-default-resource">>},
{<<"to">>,
<<"alicE_resume_session_state_send_message_1459@localhost">>},
{<<"xml:lang">>,<<"en">>},
{<<"type">>,<<"chat">>}],
[{xmlel,<<"body">>,[],[{xmlcdata,<<"msg-2">>}]},
{xmlel,<<"delay">>,
[{<<"xmlns">>,<<"urn:xmpp:delay">>},
{<<"stamp... pgsql_mnesia_23 / pgsql_mnesia / 1f146ab elasticsearch_and_cassandra_24 / elasticsearch_and_cassandra_mnesia / 1f146ab pgsql_mnesia_24 / pgsql_mnesia / 1f146ab mysql_redis_24 / mysql_redis / 1f146ab mssql_mnesia_24 / odbc_mssql_mnesia / 1f146ab riak_mnesia_24 / riak_mnesia / 1f146ab |
2524bc2
to
d21a51c
Compare
small_tests_24 / small_tests / d21a51c small_tests_23 / small_tests / d21a51c dynamic_domains_pgsql_mnesia_23 / pgsql_mnesia / d21a51c dynamic_domains_mysql_redis_24 / mysql_redis / d21a51c dynamic_domains_pgsql_mnesia_24 / pgsql_mnesia / d21a51c dynamic_domains_mssql_mnesia_24 / odbc_mssql_mnesia / d21a51c ldap_mnesia_23 / ldap_mnesia / d21a51c ldap_mnesia_24 / ldap_mnesia / d21a51c rest_client_SUITE:messages:msg_is_sent_and_delivered_over_sse{error,{{badmap,{error,timeout}},
[{erlang,map_get,
[data,{error,timeout}],
[{error_info,#{module => erl_erts_errors}}]},
{rest_client_SUITE,msg_is_sent_and_delivered_over_sse,1,
[{file,"/home/circleci/project/big_tests/tests/rest_client_SUITE.erl"},
{line,217}]},
{test_server,ts_tc,3,[{file,"test_server.erl"},{line,1783}]},
{test_server,run_test_case_eval1,6,
[{file,"test_server.erl"},{line,1292}]},
{test_server,run_test_case_eval,9,
[{file,"test_server.erl"},{line,1224}]}]}} sm_SUITE:parallel:messages_are_properly_flushed_during_resumption_p1_fsm_old{error,
{{badmatch,
{error,
{connection_step_failed,
{#Fun<sm_SUITE.11.68776247>,
{client,
<<"alicE_messages_are_properly_flushed_during_resumption_p1_fsm_old_1402@localhost">>,
escalus_tcp,<0.18692.1>,undefined,
[{username,
<<"alicE_messages_are_properly_flushed_during_resumption_p1_fsm_old_1402">>},
{server,<<"localhost">>},
{password,<<"matygrysa">>},
{stream_management,true},
{host,<<"localhost">>},
{stream_id,<<"0c81371690928f18">>}]},
[{compression,[<<"zlib">>]},
{starttls,true},
{stream_management,true},
{advanced_message_processing,true},
{client_state_indication,false},
{sasl_mechanisms,[<<"PLAIN">>]},
{caps,undefined}]},
{timeout,get_resumed}}}},
[{sm_SUITE,
'-messages_are_properly_flushed_during_resumption_p1_fsm_old/1-fun-1-',
3,
[{file,"/home/circleci/project/big_tests/tests/sm_SUITE.erl"},
{line,1270}]},
{escalus_story,story,4,
[{file,
"/home/circleci/project/big_tests/_build/default/lib/escalus/src/escalus_story.erl"},
{line,72}]},
{test_server,ts_tc,3,[{file,"test_server.erl"},{line,1783}]},
{test_server,run_test_case_eval1,6,
[{file,"test_server.erl"},{line,1292}]},
{test_server,run_test_case_eval,9,
[{file,"test_server.erl"},{line,1224}]}]}} internal_mnesia_24 / internal_mnesia / d21a51c pgsql_mnesia_23 / pgsql_mnesia / d21a51c elasticsearch_and_cassandra_24 / elasticsearch_and_cassandra_mnesia / d21a51c mysql_redis_24 / mysql_redis / d21a51c pgsql_mnesia_24 / pgsql_mnesia / d21a51c mssql_mnesia_24 / odbc_mssql_mnesia / d21a51c muc_SUITE:register:user_submits_registration_form{error,
{{assertion_failed,assert,is_iq_result,
[{xmlel,<<"iq">>,
[{<<"type">>,<<"set">>},
{<<"id">>,<<"8976c3941963f7ff8d22dd789086f6ed">>},
{<<"to">>,<<"muc.localhost">>}],
[{xmlel,<<"query">>,
[{<<"xmlns">>,<<"jabber:iq:register">>}],
[{xmlel,<<"x">>,
[{<<"xmlns">>,<<"jabber:x:data">>},
{<<"type">>,<<"submit">>}],
[{xmlel,<<"field">>,
[{<<"type">>,<<"hidden">>},
{<<"var">>,<<"FORM_TYPE">>}],
[{xmlel,<<"value">>,[],
[{xmlcdata,<<"jabber:iq:register">>}]}]},
{xmlel,<<"field">>,
[{<<"type">>,<<"text-single">>},
{<<"var">>,<<"nick">>}],
[{xmlel,<<"value">>,[],
[{xmlcdata,
<<"thirdwitchroom-c3b9fc8e0f">>}]}]}]}]}]}],
{xmlel,<<"iq">>,
[{<<"from">>,<<"muc.localhost">>},
{<<"to">>,
<<"alicE_user_submits_registration_form_1805@localhost/res1">>},
{<<"type">>,<<"error">>},
{<<"xml:lang">>,<<"en">>},
{<<"id">>,<<"8976c3941963f7ff8d22dd789086f6ed">>}],
[{xmlel,<<"query">>,
[{<<"xmlns">>,<<"jabber:iq:register">>}],
[{xmlel,<<"x">>,
[{<<"xmlns">>,<<"jabber:x:data">>},
{<<"type">>,<<"submit">>}],
[{xmlel,<<"field">>,
[{<<"type">>,<<"hidden">>},
{<<"var">>,<<"FORM_TYPE">>}],
... riak_mnesia_24 / riak_mnesia / d21a51c |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
This PR addresses MIM-1572
Proposed changes include: