Skip to content

Commit f9d4ff8

Browse files
committed
Add validation that all key fields are present in the output API schema type.
1 parent eeb8ff4 commit f9d4ff8

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

graphql-api-generator/utils/utils.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,9 @@ def add_key_input_types(schema: GraphQLSchema):
223223
for key in keys[:1]:
224224
make_types += f'input _KeyFor{_type.name} '
225225
extend_fields += f'\nextend input _KeyFor{_type.name} {{ '
226+
for key_field in key:
227+
if key_field not in _type.fields:
228+
raise Exception(f'Field "{key_field}" in @key directive for {_type} is not a field of {_type}!')
226229
for field_name, field in _type.fields.items():
227230
# TODO: Modify this if we need to verify that the key fields are in the object
228231
if field_name not in key:

0 commit comments

Comments
 (0)