Skip to content

Commit

Permalink
Fix federation support for directives without surrounding whitespace (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
danring authored Mar 23, 2023
1 parent 9474c8f commit aae5ba3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- Added support for passing `Enum` types directly to `make_executable_schema`
- Added `convert_names_case` option to `make_federated_schema`.
- Added support for the `@interfaceObject` directive in Apollo Federation.
- Fixed federation support for directives without surrounding whitespace.


## 0.18.1 (2023-02-22)
Expand Down
5 changes: 3 additions & 2 deletions ariadne/contrib/federation/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@

_r_directive_definition = re.compile(
"("
f"{_i_token_delimiter}"
f"(?:{_i_token_description_block_string}|{_i_token_description_single_line})??"
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})?"
Expand Down
6 changes: 6 additions & 0 deletions tests/federation/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@ def test_purge_directives_remove_custom_directives_with_single_line_description(
)


def test_purge_directives_without_leading_whitespace():
type_defs = "#\ndirective @custom on FIELD"

assert sic(purge_schema_directives(type_defs)) == ""


def test_get_entity_types_with_key_directive():
type_defs = """
type Query {
Expand Down

0 comments on commit aae5ba3

Please sign in to comment.