Skip to content

Commit

Permalink
fix: @sharable is applied multiple times on PageInfo in multithreaded…
Browse files Browse the repository at this point in the history
… environments
  • Loading branch information
mak626 committed Apr 22, 2024
1 parent bee1ded commit 9fc3391
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions graphene_federation/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,15 @@ def _add_sharable_to_page_info_type(
"""
Add @sharable directive to PageInfo type
"""
if PageInfo.__name__ in schema.graphql_schema.type_map:

if page_info := schema.graphql_schema.type_map.get(PageInfo.__name__):
try:
# PageInfo needs @sharable directive
sharable = get_directive_from_name("shareable", federation_version)
types.append(
directive_decorator(target_directive=sharable)(field=None)(PageInfo)
directive_decorator(target_directive=sharable)(field=None)(
page_info.graphene_type
)
)
except ValueError:
# Federation Version does not support @sharable
Expand Down

0 comments on commit 9fc3391

Please sign in to comment.