Skip to content

Commit ea2fb55

Browse files
committed
Cleanup schema validation check which is now obsolete
Replicates graphql/graphql-js@1ba33fc
1 parent c320e57 commit ea2fb55

File tree

2 files changed

+5
-22
lines changed

2 files changed

+5
-22
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ a query language for APIs created by Facebook.
1313
[![Code Style](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)
1414

1515
The current version 1.0.1 of GraphQL-core-next is up-to-date with GraphQL.js version
16-
14.0.2. All parts of the API are covered by an extensive test suite of currently 1690
16+
14.0.2. All parts of the API are covered by an extensive test suite of currently 1700
1717
unit tests.
1818

1919

graphql/type/validate.py

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -239,15 +239,6 @@ def validate_fields(self, type_: Union[GraphQLObjectType, GraphQLInterfaceType])
239239
# Ensure they are named correctly.
240240
self.validate_name(field, field_name)
241241

242-
# Ensure they were defined at most once.
243-
field_nodes = get_all_field_nodes(type_, field_name)
244-
if len(field_nodes) > 1:
245-
self.report_error(
246-
f"Field {type_.name}.{field_name} can only be defined once.",
247-
field_nodes,
248-
)
249-
continue
250-
251242
# Ensure the type is an output type
252243
if not is_output_type(field.type):
253244
self.report_error(
@@ -513,19 +504,11 @@ def get_all_implements_interface_nodes(
513504
def get_field_node(
514505
type_: Union[GraphQLObjectType, GraphQLInterfaceType], field_name: str
515506
) -> Optional[FieldDefinitionNode]:
516-
nodes = get_all_field_nodes(type_, field_name)
517-
return nodes[0] if nodes else None
518-
519-
520-
def get_all_field_nodes(
521-
type_: Union[GraphQLObjectType, GraphQLInterfaceType], field_name: str
522-
) -> List[FieldDefinitionNode]:
523-
field_nodes = cast(
524-
List[FieldDefinitionNode], get_all_sub_nodes(type_, attrgetter("fields"))
507+
all_field_nodes = filter(
508+
lambda field_node: field_node.name.value == field_name,
509+
cast(List[FieldDefinitionNode], get_all_sub_nodes(type_, attrgetter("fields"))),
525510
)
526-
return [
527-
field_node for field_node in field_nodes if field_node.name.value == field_name
528-
]
511+
return next(all_field_nodes, None)
529512

530513

531514
def get_field_type_node(

0 commit comments

Comments
 (0)