@@ -49,18 +49,6 @@ def cmd(args):
49
49
50
50
51
51
def run (schema : GraphQLSchema , config : dict ):
52
- #Avoid some weird config combinations
53
- config .get ('generation' )['generate_datetime' ] = config .get ('generation' ).get ('generate_datetime' ) or config .get ('generation' ).get ('field_for_creation_date' ) or config .get ('generation' ).get ('field_for_last_update_date' )
54
-
55
- # TODO: Remove this when we scrap the Date scalar
56
- # check if Date exists, or should be added
57
- # If it already exists (in the expected way, we handle it as if we added it
58
- config .get ('generation' )['generate_date' ] = date_control (schema , config .get ('generation' ).get ('generate_date' ))
59
-
60
- # check if DateTime exists, or should be added
61
- if config .get ('generation' ).get ('generate_datetime' ):
62
- datetime_control (schema )
63
-
64
52
# validate
65
53
if config .get ('validate' ):
66
54
validate_names (schema , config .get ('validate' ))
@@ -80,6 +68,15 @@ def run(schema: GraphQLSchema, config: dict):
80
68
if config .get ('generation' ).get ('field_for_id' ):
81
69
schema = add_id_to_types (schema )
82
70
71
+ # check if DateTime exists, or should be added
72
+ if config .get ('generation' ).get ('generate_datetime' ):
73
+ datetime_control (schema )
74
+
75
+ # TODO: Remove this when we scrap the Date scalar
76
+ # check if Date exists, or should be added
77
+ if config .get ('generation' ).get ('generate_date' ):
78
+ date_control (schema )
79
+
83
80
# add creationDate
84
81
if config .get ('generation' ).get ('field_for_creation_date' ):
85
82
schema = add_creation_date_to_types (schema )
@@ -282,17 +279,16 @@ def datetime_control(schema):
282
279
283
280
284
281
# TODO: Remove this when we scrap the Date scalar
285
- def date_control (schema , config : dict ):
282
+ def date_control (schema ):
286
283
type_names = set (schema .type_map .keys ())
287
284
if 'Date' in type_names :
288
285
if not is_scalar_type (schema .type_map ['Date' ]):
289
286
raise Exception ('Date exists but is not scalar type: ' + schema .type_map ['Date' ])
290
- return True
291
- elif config .get ('generation' ).get ('generate_date' ):
287
+ else :
292
288
schema .type_map ['Date' ] = GraphQLScalarType ('Date' )
293
289
if not is_scalar_type (schema .type_map ['Date' ]):
294
290
raise Exception ('Date could not be added as scalar!' )
295
- return True
291
+
296
292
return False
297
293
298
294
0 commit comments