Skip to content

Commit 79c862c

Browse files
committed
Corrected @_unique. being skipped, corrected directives for field handling for input types
1 parent 6cc89c6 commit 79c862c

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

graphql-api-generator/utils/utils.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -815,8 +815,8 @@ def directive_from_interface(directive, interface_name):
815815
# The only two cases who needs special attention is @requiredForTarget and @uniqueForTarget
816816
if directive_string == 'requiredForTarget':
817817
directive_string = '_requiredForTarget_AccordingToInterface(interface: "' + interface_name + '")'
818-
#elif directive_string == 'uniqueForTarget':
819-
# directive_string = '_uniqueForTarget_AccordingToInterface(interface: "' + interface_name + '")'
818+
elif directive_string == 'uniqueForTarget':
819+
directive_string = '_uniqueForTarget_AccordingToInterface(interface: "' + interface_name + '")'
820820
else:
821821
directive_string += get_directive_arguments(directive)
822822

@@ -860,7 +860,7 @@ def get_directive_arguments(directive):
860860
return output
861861

862862

863-
def get_field_directives(field, field_name, _type, schema):
863+
def get_field_directives(field_name, _type, schema):
864864
"""
865865
Get the directives of given field, and return them as string
866866
:param field:
@@ -889,6 +889,13 @@ def get_field_directives(field, field_name, _type, schema):
889889
else:
890890
return ''
891891

892+
# We got type without fields, just return empty
893+
if not hasattr(_type, 'fields'):
894+
return ''
895+
896+
# Get the field from the correct type
897+
field = _type.fields[field_name]
898+
892899
# Get all directives directly on field
893900
for directive in field.ast_node.directives:
894901
if not directive.name.value in directives_set:
@@ -1036,7 +1043,7 @@ def print_schema_with_directives(schema):
10361043
output += ': ' + str(field.type)
10371044

10381045
# Add directives
1039-
output += get_field_directives(field, field_name, _type, schema)
1046+
output += get_field_directives(field_name, _type, schema)
10401047

10411048
output += '\n'
10421049

0 commit comments

Comments
 (0)