Skip to content

Commit 3d03915

Browse files
committed
feat: add add_federation_defs argument to make_schema
1 parent bdce1cc commit 3d03915

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

gql/schema.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ def make_schema(
3232
no_location: bool = False,
3333
experimental_fragment_variables: bool = False,
3434
federation: bool = False,
35+
add_federation_defs: bool = True,
3536
directives: Dict[str, Type[SchemaDirectiveVisitor]] = None,
3637
) -> GraphQLSchema:
3738
if isinstance(type_defs, list):
@@ -44,7 +45,8 @@ def make_schema(
4445
# remove subscription because Apollo Federation not support subscription yet.
4546
# type_defs = remove_subscription(type_defs)
4647

47-
type_defs = join_type_defs([type_defs, federation_service_type_defs])
48+
if add_federation_defs:
49+
type_defs = join_type_defs([type_defs, federation_service_type_defs])
4850
schema = build_schema(
4951
type_defs, assume_valid, assume_valid_sdl, no_location, experimental_fragment_variables
5052
)
@@ -89,6 +91,7 @@ def make_schema_from_file(
8991
no_location: bool = False,
9092
experimental_fragment_variables: bool = False,
9193
federation: bool = False,
94+
add_federation_defs: bool = True,
9295
directives: Dict[str, Type[SchemaDirectiveVisitor]] = None,
9396
) -> GraphQLSchema:
9497
with open(file, 'r') as f:
@@ -99,6 +102,7 @@ def make_schema_from_file(
99102
no_location,
100103
experimental_fragment_variables,
101104
federation,
105+
add_federation_defs,
102106
directives,
103107
)
104108
return schema
@@ -124,6 +128,7 @@ def make_schema_from_path(
124128
no_location: bool = False,
125129
experimental_fragment_variables: bool = False,
126130
federation: bool = False,
131+
add_federation_defs: bool = True,
127132
directives: Dict[str, Type[SchemaDirectiveVisitor]] = None,
128133
):
129134
p = Path(path)
@@ -143,5 +148,6 @@ def make_schema_from_path(
143148
no_location,
144149
experimental_fragment_variables,
145150
federation,
151+
add_federation_defs,
146152
directives,
147-
)
153+
)

0 commit comments

Comments
 (0)