nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: mirumee/ariadne
Pull request #776 (2022-01-19 19:11:37)

Fix federation support for custom directives with descriptions.
See #775



Patch:
diff --git a/ariadne/contrib/federation/utils.py b/ariadne/contrib/federation/utils.py
index dfa1d8b..981bf46 100644
--- a/ariadne/contrib/federation/utils.py
+++ b/ariadne/contrib/federation/utils.py
@@ -18,9 +18,13 @@ _i_token_delimiter = r"(?:^|[\s\r\n]+|$)"
 _i_token_name = "[_A-Za-z][_0-9A-Za-z]*"
 _i_token_arguments = r"\([^)]*\)"
 _i_token_location = "[_A-Za-z][_0-9A-Za-z]*"
+_i_token_description_block_string = r"(?:\"{3}(?:[^\"]|[\s\r\n])*?\"{3})"
+_i_token_description_single_line = r"(?:\"(?:[^\"\n\r])*?\")"
 
 _r_directive_definition = re.compile(
     "("
+    f"{_i_token_delimiter}"
+    f"(?:{_i_token_description_block_string}|{_i_token_description_single_line})??"
     f"{_i_token_delimiter}directive"
     f"(?:{_i_token_delimiter})?@({_i_token_name})"
     f"(?:(?:{_i_token_delimiter})?{_i_token_arguments})?"


Test patch:
diff --git a/tests/federation/test_utils.py b/tests/federation/test_utils.py
index 140c2a0..f251b5e 100644
--- a/tests/federation/test_utils.py
+++ b/tests/federation/test_utils.py
@@ -73,6 +73,46 @@ def test_purge_directives_remove_custom_directives():
     )
 
 
+def test_purge_directives_remove_custom_directives_with_block_string_description():
+    type_defs = '''
+        """
+        Any Description
+        """
+        directive @custom on FIELD
+        
+        type Query {
+            rootField: String @custom
+        }
+    '''
+
+    assert sic(purge_schema_directives(type_defs)) == sic(
+        """
+            type Query {
+                rootField: String
+            }
+        """
+    )
+
+
+def test_purge_directives_remove_custom_directives_with_single_line_description():
+    type_defs = '''
+        "Any Description"
+        directive @custom on FIELD
+        
+        type Query {
+            rootField: String @custom
+        }
+    '''
+
+    assert sic(purge_schema_directives(type_defs)) == sic(
+        """
+            type Query {
+                rootField: String
+            }
+        """
+    )
+
+
 def test_get_entity_types_with_key_directive():
     type_defs = """
         type Query {