From 08108c883db6aec0bb8e6e371919baa80c6f528f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Pito=C5=84?= Date: Tue, 16 Apr 2024 15:45:01 +0200 Subject: [PATCH] Test schema subset copy enum directives --- tests/test_copy_schema_subset.py | 58 ++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/tests/test_copy_schema_subset.py b/tests/test_copy_schema_subset.py index 4fd39bc..a546af4 100644 --- a/tests/test_copy_schema_subset.py +++ b/tests/test_copy_schema_subset.py @@ -771,3 +771,61 @@ def test_copy_schema_subset_excludes_directive_arg_and_type(gql): directives = {d.name: d for d in copied_schema.directives} assert not directives["custom"].args + + +def test_copy_schema_subset_includes_enum_directive(gql): + schema_str = gql( + """ + directive @custom on ENUM + + enum Role @custom { + USER + ADMIN + } + + type Query { + lorem: Role! + ipsum: Int! + dolor: Int! + met: Int! + } + """ + ) + schema = build_ast_schema(parse(schema_str)) + + copied_schema = copy_schema( + schema, + queries=["lorem", "dolor"], + exclude_directives=["custom"], + ) + assert "Role" in copied_schema.type_map + assert_directive_doesnt_exist(copied_schema, "custom") + + +def test_copy_schema_subset_includes_enum_value_directive(gql): + schema_str = gql( + """ + directive @custom on ENUM_VALUE + + enum Role { + USER + ADMIN @custom + } + + type Query { + lorem: Role! + ipsum: Int! + dolor: Int! + met: Int! + } + """ + ) + schema = build_ast_schema(parse(schema_str)) + + copied_schema = copy_schema( + schema, + queries=["lorem", "dolor"], + exclude_directives=["custom"], + ) + assert "Role" in copied_schema.type_map + assert_directive_doesnt_exist(copied_schema, "custom")