From 410d0438b2747081aa52672919de471136455abb Mon Sep 17 00:00:00 2001 From: Sergey Prokhorov Date: Sat, 25 Nov 2023 00:50:23 +0100 Subject: [PATCH] Fix .dot file generator; add to tests Just make sure that `dungeon` and `star_wars` schemas can be dumped. --- src/graphql_dot.erl | 3 ++- test/dungeon_SUITE.erl | 6 +++++- test/star_wars_SUITE.erl | 8 ++++++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/graphql_dot.erl b/src/graphql_dot.erl index 7a0531a..2131b15 100644 --- a/src/graphql_dot.erl +++ b/src/graphql_dot.erl @@ -150,7 +150,8 @@ id(#union_type { id = ID }) -> ID; id(#scalar_type { id = ID }) -> ID; id(#input_object_type { id = ID }) -> ID; id(#object_type { id = ID }) -> ID; -id(#root_schema { id = ID }) -> ID. +id(#root_schema { id = ID }) -> ID; +id(#directive_type{ id = ID }) -> ID. %% ---------------------------- join(_Sep, []) -> []; diff --git a/test/dungeon_SUITE.erl b/test/dungeon_SUITE.erl index c553015..a42628d 100644 --- a/test/dungeon_SUITE.erl +++ b/test/dungeon_SUITE.erl @@ -55,7 +55,8 @@ end_per_testcase(_Case, _Config) -> groups() -> Dungeon = {dungeon, [], - [ unions, + [ dump_dot, + unions, defer, union_errors, error_handling, @@ -122,6 +123,9 @@ run(Config, File, Q, Params) -> {ok, Doc} = read_doc(Config, File), th:x(Config, Doc, Q, Params). +dump_dot(_Config) -> + ok = graphql_dot:dump("./dungeon_schema.dot"). + default_query(Config) -> ID = ?config(known_goblin_id_1, Config), #{ data := #{ <<"goblin">> := #{ <<"id">> := ID, <<"name">> := <<"goblin!">>, <<"hitpoints">> := 10 }}} = diff --git a/test/star_wars_SUITE.erl b/test/star_wars_SUITE.erl index 4249b07..6dd7e2f 100644 --- a/test/star_wars_SUITE.erl +++ b/test/star_wars_SUITE.erl @@ -6,7 +6,7 @@ init_per_testcase/2, end_per_testcase/2]). -export([hero/1, friends/1, query_id_params/1, query_aliases/1, - fragments/1, typename/1]). + fragments/1, typename/1, dump_dot/1]). -export([complex/1, non_existent_field/1, fields_on_objects/1, no_fields_on_interfaces/1, no_fields_on_scalars/1, @@ -46,7 +46,8 @@ groups() -> query_id_params, query_aliases, fragments, - typename + typename, + dump_dot ]}, Validation = {validation, [shuffle, parallel], @@ -235,6 +236,9 @@ typename(Config) -> Expected = th:x(Config, Q1), ok. +dump_dot(_Config) -> + ok = graphql_dot:dump("./star_wars_schema.dot"). + %% -- STAR WARS™ VALIDATION ------------------------------ complex(Config) ->