Skip to content

Commit

Permalink
Updating the documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Janusz Jakubiec authored and Janusz Jakubiec committed Nov 9, 2022
1 parent 4d4a0e0 commit f188f9d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
4 changes: 2 additions & 2 deletions big_tests/tests/graphql_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ common_tests() ->
categories_disabled_tests() ->
[category_disabled_error_test,
admin_checks_auth,
category_does_not_exists_error,
category_does_not_exist_error,
listener_reply_with_validation_error,
multiple_categories_query_test].

Expand Down Expand Up @@ -165,7 +165,7 @@ category_disabled_error_test(Config) ->
?assertEqual(<<"category_disabled">>, get_value([extensions, code], Msg)),
?assertEqual([<<"server">>], get_value([path], Msg)).

category_does_not_exists_error(Config) ->
category_does_not_exist_error(Config) ->
Ep = ?config(schema_endpoint, Config),
Status = execute(Ep, #{<<"query">> => <<"{ field ">>}, undefined),
get_bad_request(Status),
Expand Down
9 changes: 8 additions & 1 deletion doc/configuration/listen.md
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,13 @@ When set, enables authentication for the admin API, otherwise it is disabled. Re
* **Default:** not set
* **Example:** `password = "secret"`

Required to enable authentication for the admin API.
#### `listen.http.handlers.mongoose_graphql_cowboy_handler.allowed_categories`
* **Syntax:** non-empty array of strings. Allowed values: `"checkAuth", "account", "domain", "last", "muc", "muc_light", "session", "stanza", "roster", "vcard", "private", "metric", "stat", "gdpr", "mnesia", "server", "inbox", "http_upload", "offline", "token"`
* **Default:** all graphQL categories enabled
* **Example:** `allowed_categories = ["domain", "last"]`

By default, when the option is not included, all graphQL categories are enabled, so you don't need to add this option.
When this option is added, only listed graphQL categories will be processed. For others, the error "category disabled" will be returned.

### Handler types: REST API - Admin - `mongoose_admin_api`

Expand Down Expand Up @@ -653,6 +659,7 @@ GraphQL API for administration, the listener is bound to 127.0.0.1 for increased
schema_endpoint = "admin"
username = "admin"
password = "secret"
allowed_categories = ["server", "last", "vcard"]
```

#### Example 3. Domain Admin GraphQL API
Expand Down
10 changes: 5 additions & 5 deletions src/graphql/mongoose_graphql_check_categories.erl
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@ process_ast(#document{definitions = Definitions} = Document, Categories) ->
end.

parse_schema(#object_type{fields = Fields} = Schema, Op, Categories) ->
Fields2 = lists:foldl(fun({Key, Value}, Acc) ->
Fields2 = maps:map(fun(Key, Value) ->
case lists:member(Key, Categories) of
true -> maps:put(Key, Value, Acc);
true -> Value;
false ->
case Value of
#schema_field{resolve = undefined} ->
Fun = category_disabled_fun(Key),
maps:put(Key, Value#schema_field{resolve = Fun}, Acc);
Value#schema_field{resolve = Fun};
_ ->
maps:put(Key, Value, Acc)
Value
end
end
end, #{}, maps:to_list(Fields)),
end, Fields),
Schema2 = Schema#object_type{fields = Fields2},
Op#op{schema = Schema2};
parse_schema(_, Op, _) ->
Expand Down

0 comments on commit f188f9d

Please sign in to comment.