@@ -815,8 +815,8 @@ def directive_from_interface(directive, interface_name):
815
815
# The only two cases who needs special attention is @requiredForTarget and @uniqueForTarget
816
816
if directive_string == 'requiredForTarget' :
817
817
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 + '")'
820
820
else :
821
821
directive_string += get_directive_arguments (directive )
822
822
@@ -860,7 +860,7 @@ def get_directive_arguments(directive):
860
860
return output
861
861
862
862
863
- def get_field_directives (field , field_name , _type , schema ):
863
+ def get_field_directives (field_name , _type , schema ):
864
864
"""
865
865
Get the directives of given field, and return them as string
866
866
:param field:
@@ -889,6 +889,13 @@ def get_field_directives(field, field_name, _type, schema):
889
889
else :
890
890
return ''
891
891
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
+
892
899
# Get all directives directly on field
893
900
for directive in field .ast_node .directives :
894
901
if not directive .name .value in directives_set :
@@ -1036,7 +1043,7 @@ def print_schema_with_directives(schema):
1036
1043
output += ': ' + str (field .type )
1037
1044
1038
1045
# Add directives
1039
- output += get_field_directives (field , field_name , _type , schema )
1046
+ output += get_field_directives (field_name , _type , schema )
1040
1047
1041
1048
output += '\n '
1042
1049
0 commit comments