File tree Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -82,7 +82,7 @@ def run(schema: GraphQLSchema, config: dict):
82
82
83
83
# add edge types
84
84
if config .get ('generation' ).get ('edge_types' ) or config .get ('generation' ).get ('create_edge_objects' ):
85
- schema = add_edge_objects (schema )
85
+ schema = add_edge_objects (schema , config . get ( 'generation' ). get ( 'field_for_creation_date' ), config . get ( 'generation' ). get ( 'field_for_last_update_date' ) )
86
86
if config .get ('generation' ).get ('fields_for_edge_types' ):
87
87
raise UnsupportedOperation ('{0} is currently not supported' .format ('fields_for_edge_types' ))
88
88
Original file line number Diff line number Diff line change @@ -560,8 +560,14 @@ def get_field_annotations(field: GraphQLField):
560
560
return " " .join (annotation_fields )
561
561
562
562
563
- def add_edge_objects (schema : GraphQLSchema ):
563
+ def add_edge_objects (schema : GraphQLSchema , field_for_creation_date , field_for_last_update_date ):
564
564
make = ''
565
+ creation_date_string = ''
566
+ last_update_date_string = ''
567
+ if field_for_creation_date :
568
+ creation_date_string = '_creationDate: Date!'
569
+ if field_for_last_update_date :
570
+ last_update_date_string = '_lastUpdateDate: Date'
565
571
for _type in schema .type_map .values ():
566
572
if not is_schema_defined_type (_type ) or is_interface_type (_type ):
567
573
continue
@@ -573,7 +579,7 @@ def add_edge_objects(schema: GraphQLSchema):
573
579
for t in connected_types :
574
580
edge_from = f'{ capitalize (field_name )} EdgeFrom{ t .name } '
575
581
annotations = get_field_annotations (field )
576
- make += f'type _{ edge_from } {{id:ID! source: { t .name } ! target: { inner_field_type } ! { annotations } }}\n '
582
+ make += f'type _{ edge_from } {{id:ID! source: { t .name } ! target: { inner_field_type } ! { creation_date_string } { last_update_date_string } { annotations } }}\n '
577
583
578
584
schema = add_to_schema (schema , make )
579
585
return schema
You can’t perform that action at this time.
0 commit comments