1 |
|
-module(mongoose_graphql_directive_helper). |
2 |
|
|
3 |
|
-export([name/1, get_arg/2, op_name/1]). |
4 |
|
|
5 |
|
op_name(undefined) -> |
6 |
27628 |
<<"ROOT">>; |
7 |
|
op_name(Name) -> |
8 |
:-( |
Name. |
9 |
|
|
10 |
|
name({name, _, N}) -> |
11 |
2402794 |
N; |
12 |
|
name(N) when is_binary(N) -> |
13 |
:-( |
N. |
14 |
|
|
15 |
|
get_arg(Name, Args) when is_binary(Name) -> |
16 |
1278 |
Path = binary:split(Name, <<".">>, [global]), |
17 |
1278 |
get_arg(Path, Args); |
18 |
|
get_arg([], Value) -> |
19 |
1286 |
Value; |
20 |
|
get_arg(_, undefined) -> |
21 |
:-( |
undefined; |
22 |
|
get_arg(Path, List) when is_list(List) -> |
23 |
4 |
[get_arg(Path, ArgsMap) || ArgsMap <- List]; |
24 |
|
get_arg([Name | Path], ArgsMap) -> |
25 |
1294 |
get_arg(Path, maps:get(Name, ArgsMap, undefined)). |