Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/graphql/utilities/build_client_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ def build_input_object_def(
fields=lambda: build_input_value_def_map(
input_object_introspection["inputFields"]
),
is_one_of=input_object_introspection.get("isOneOf"),
)

type_builders: dict[str, Callable[[IntrospectionType], GraphQLNamedType]] = {
Expand Down
7 changes: 4 additions & 3 deletions src/graphql/utilities/get_introspection_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
except ImportError: # Python < 3.10
from typing_extensions import TypeAlias


__all__ = [
"IntrospectionDirective",
"IntrospectionEnumType",
Expand All @@ -44,6 +43,7 @@ def get_introspection_query(
directive_is_repeatable: bool = False,
schema_description: bool = False,
input_value_deprecation: bool = False,
input_object_one_of: bool = False,
) -> str:
"""Get a query for introspection.

Expand All @@ -55,6 +55,7 @@ def get_introspection_query(
maybe_specified_by_url = "specifiedByURL" if specified_by_url else ""
maybe_directive_is_repeatable = "isRepeatable" if directive_is_repeatable else ""
maybe_schema_description = maybe_description if schema_description else ""
maybe_input_object_one_of = "isOneOf" if input_object_one_of else ""

def input_deprecation(string: str) -> str | None:
return string if input_value_deprecation else ""
Expand Down Expand Up @@ -87,6 +88,7 @@ def input_deprecation(string: str) -> str | None:
name
{maybe_description}
{maybe_specified_by_url}
{maybe_input_object_one_of}
fields(includeDeprecated: true) {{
name
{maybe_description}
Expand Down Expand Up @@ -253,6 +255,7 @@ class IntrospectionEnumType(WithName):
class IntrospectionInputObjectType(WithName):
kind: Literal["input_object"]
inputFields: list[IntrospectionInputValue]
isOneOf: bool


IntrospectionType: TypeAlias = Union[
Expand All @@ -264,7 +267,6 @@ class IntrospectionInputObjectType(WithName):
IntrospectionInputObjectType,
]


IntrospectionOutputType: TypeAlias = Union[
IntrospectionScalarType,
IntrospectionObjectType,
Expand All @@ -273,7 +275,6 @@ class IntrospectionInputObjectType(WithName):
IntrospectionEnumType,
]


IntrospectionInputType: TypeAlias = Union[
IntrospectionScalarType, IntrospectionEnumType, IntrospectionInputObjectType
]
Expand Down
2 changes: 2 additions & 0 deletions src/graphql/utilities/introspection_from_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def introspection_from_schema(
directive_is_repeatable: bool = True,
schema_description: bool = True,
input_value_deprecation: bool = True,
input_object_one_of: bool = True,
) -> IntrospectionQuery:
"""Build an IntrospectionQuery from a GraphQLSchema

Expand All @@ -37,6 +38,7 @@ def introspection_from_schema(
directive_is_repeatable,
schema_description,
input_value_deprecation,
input_object_one_of,
)
)

Expand Down
6 changes: 5 additions & 1 deletion tests/utilities/test_get_introspection_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import re
from typing import Pattern

from graphql.language import parse
from graphql.utilities import build_schema, get_introspection_query
from graphql.validation import validate
Expand Down Expand Up @@ -80,6 +79,11 @@ def includes_deprecation_reason_field_on_input_values():
"deprecationReason", 2
)

def includes_input_object_one_of_field():
ExcpectIntrospectionQuery().to_not_match("isOneOf")
ExcpectIntrospectionQuery(input_object_one_of=True).to_match("isOneOf")
ExcpectIntrospectionQuery(input_object_one_of=False).to_not_match("isOneOf")

def includes_deprecated_input_field_and_args():
ExcpectIntrospectionQuery().to_match("includeDeprecated: true", 2)
ExcpectIntrospectionQuery(input_value_deprecation=True).to_match(
Expand Down
Loading