@@ -18,6 +18,16 @@ def uppercase(string: str):
18
18
return string .upper ()
19
19
20
20
21
+ def is_meta_field (field ):
22
+ """
23
+ Returns true if a field should be recognized as a system defined meta data field.
24
+ :param field:
25
+ :return:
26
+ """
27
+ meta_fields = ['_creationDate' , '_lastUpdateDate' ]
28
+ return field in meta_fields
29
+
30
+
21
31
def capitalize (string : str ):
22
32
"""
23
33
Make the first letter of string upper case.
@@ -487,8 +497,9 @@ def add_scalar_filters(schema: GraphQLSchema, config: dict):
487
497
' _neq: Boolean ' \
488
498
'} '
489
499
490
- # DateTime (behaves like a integer)
491
- if config .get ('generation' ).get ('generate_datetime' ):
500
+ # If DateTime is defined as a scalar then create filter (behaves like an integer)
501
+ date_time = schema .type_map .get ("DateTime" )
502
+ if is_scalar_type (date_time ):
492
503
manually_handled_scalars .append ('DateTime' )
493
504
make += 'input _DateTimeFilter {' \
494
505
' _eq: DateTime ' \
@@ -518,7 +529,7 @@ def add_scalar_filters(schema: GraphQLSchema, config: dict):
518
529
return schema
519
530
520
531
521
- def add_type_filters (schema : GraphQLSchema , field_for_creation_date , field_for_last_update_date ):
532
+ def add_type_filters (schema : GraphQLSchema ):
522
533
"""
523
534
Add filter types (Hasura-style filters).
524
535
:param schema: schema
@@ -535,8 +546,7 @@ def add_type_filters(schema: GraphQLSchema, field_for_creation_date, field_for_l
535
546
f' _not: _FilterFor{ _type .name } '
536
547
537
548
for field_name , field in _type .fields .items ():
538
- # This is a bit questionable
539
- if field_name [0 ] == '_' and not (field_for_creation_date and field_name == '_creationDate' ) and not (field_for_last_update_date and field_name == '_lastUpdateDate' ):
549
+ if field_name [0 ] == '_' and not is_meta_field (field_name ):
540
550
continue
541
551
542
552
# remove outer required
0 commit comments