Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 7d77e98

Browse files
committed
Add support for @OneOf directives in print_schema
Replicates graphql/graphql-js@0b7590f
1 parent cd2d6a8 commit 7d77e98

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

‎src/graphql/utilities/print_schema.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,12 @@ def print_input_object(type_: GraphQLInputObjectType) -> str:
214214
print_description(field, " ", not i) + " " + print_input_value(name, field)
215215
for i, (name, field) in enumerate(type_.fields.items())
216216
]
217-
return print_description(type_) + f"input {type_.name}" + print_block(fields)
217+
return (
218+
print_description(type_)
219+
+ f"input {type_.name}"
220+
+ (" @oneOf" if type_.is_one_of else "")
221+
+ print_block(fields)
222+
)
218223

219224

220225
def print_fields(type_: GraphQLObjectType | GraphQLInterfaceType) -> str:

‎tests/utilities/test_print_schema.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,22 @@ def prints_input_type():
514514
"""
515515
)
516516

517+
def prints_input_type_with_one_of_directive():
518+
input_type = GraphQLInputObjectType(
519+
name="InputType",
520+
fields={"int": GraphQLInputField(GraphQLInt)},
521+
is_one_of=True,
522+
)
523+
524+
schema = GraphQLSchema(types=[input_type])
525+
assert expect_printed_schema(schema) == dedent(
526+
"""
527+
input InputType @oneOf {
528+
int: Int
529+
}
530+
"""
531+
)
532+
517533
def prints_custom_scalar():
518534
odd_type = GraphQLScalarType(name="Odd")
519535

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /