@@ -247,19 +247,20 @@ def add_input_to_create(schema: GraphQLSchema):
247
247
for _type in schema .type_map .values ():
248
248
if not is_db_schema_defined_type (_type ) or is_interface_type (_type ):
249
249
continue
250
- make += f'\n extend input _InputToCreate{ _type .name } {{ '
250
+ make += f'\n extend input _InputToCreate{ _type .name } {{'
251
251
for field_name , field in _type .fields .items ():
252
252
if field_name == 'id' or field_name [0 ] == '_' :
253
253
continue
254
254
inner_field_type = get_named_type (field .type )
255
+
255
256
if is_enum_or_scalar (inner_field_type ):
256
- make += f'{ field_name } : { field .type } '
257
+ make += f' { field_name } : { field .type } '
257
258
else :
258
259
schema = extend_connect (schema , _type , inner_field_type , field_name )
259
260
connect_name = f'_InputToConnect{ capitalize (field_name )} Of{ _type .name } '
260
261
connect = copy_wrapper_structure (schema .type_map [connect_name ], field .type )
261
262
make += f' { field_name } : { connect } '
262
- make += '} '
263
+ make += '}'
263
264
schema = add_to_schema (schema , make )
264
265
return schema
265
266
@@ -858,6 +859,39 @@ def get_directive_arguments(directive):
858
859
return output
859
860
860
861
862
+ def get_field_directives (field , field_name , _type ):
863
+ """
864
+ Get the directives of given field, and return them as string
865
+ :param schema:
866
+ :return string:
867
+ """
868
+
869
+ output = ''
870
+
871
+ # Used to make sure we don't add the same directive multiple times to the same field
872
+ directives_set = set ()
873
+
874
+ # Get all directives directly on field
875
+ for directive in field .ast_node .directives :
876
+ if not directive .name .value in directives_set :
877
+ output += ' @' + directive .name .value
878
+ directives_set .add (directive .name .value )
879
+ output += get_directive_arguments (directive )
880
+
881
+
882
+ if hasattr (_type , 'interfaces' ):
883
+ # Get all inherited directives
884
+ for interface in _type .interfaces :
885
+ if field_name in interface .fields :
886
+ for directive in interface .fields [field_name ].ast_node .directives :
887
+ directive_str = directive_from_interface (directive , interface .name )
888
+ if not directive_str in directives_set :
889
+ output += ' @' + directive_str
890
+ directives_set .add (directive_str )
891
+
892
+ return output
893
+
894
+
861
895
def printSchemaWithDirectives (schema ):
862
896
"""
863
897
Ouputs the given schema as string, in the format we want it.
@@ -883,9 +917,9 @@ def printSchemaWithDirectives(schema):
883
917
884
918
output += ' on '
885
919
for _location in _dir .locations :
886
- output += _location ._name_ + ', '
920
+ output += _location ._name_ + ' | '
887
921
888
- output = output [:- 2 ] + '\n \n '
922
+ output = output [:- 3 ] + '\n \n '
889
923
890
924
# Two special directives that should not exists in the db schema
891
925
output += 'directive @_requiredForTarget_AccordingToInterface(interface: String!) on FIELD_DEFINITION\n \n '
@@ -914,8 +948,8 @@ def printSchemaWithDirectives(schema):
914
948
if hasattr (_type , 'interfaces' ) and _type .interfaces :
915
949
output += ' implements '
916
950
for interface in _type .interfaces :
917
- output += interface .name + ', '
918
- output = output [:- 2 ]
951
+ output += interface .name + ' & '
952
+ output = output [:- 3 ]
919
953
920
954
if is_enum_type (_type ):
921
955
# For enums we can get the values directly and add them
@@ -948,27 +982,8 @@ def printSchemaWithDirectives(schema):
948
982
949
983
output += ': ' + str (field .type )
950
984
951
- # Used to make sure we don't add the same directive multiple times to the same field
952
- directives_set = set ()
953
-
954
- # Get all directives directly on field
955
- for directive in field .ast_node .directives :
956
- if not directive .name .value in directives_set :
957
- output += ' @' + directive .name .value
958
- directives_set .add (directive .name .value )
959
- output += get_directive_arguments (directive )
960
-
961
-
962
- if hasattr (_type , 'interfaces' ):
963
- # Get all inherited directives
964
- for interface in _type .interfaces :
965
- if field_name in interface .fields :
966
- for directive in interface .fields [field_name ].ast_node .directives :
967
- directive_str = directive_from_interface (directive , interface .name )
968
- if not directive_str in directives_set :
969
- output += ' @' + directive_str
970
- directives_set .add (directive_str )
971
-
985
+ # Add directives
986
+ output += get_field_directives (field , field_name , _type )
972
987
973
988
output += '\n '
974
989
0 commit comments