@@ -403,12 +403,19 @@ def add_type_filters(schema: GraphQLSchema):
403
403
if is_list_type (field .type ):
404
404
continue
405
405
406
+ < << << << HEAD
406
407
named_type = get_named_type (f_type )
407
408
if is_enum_or_scalar (f_type ):
408
409
make += f'{ field_name } : _{ named_type .name } Filter '
409
410
make += '} '
410
411
schema = add_to_schema (schema , make )
411
412
return schema
413
+ == == == =
414
+ # TODO check this!
415
+ if is_list_type (f_type ):
416
+ # Unknown how filters would apply for lists, skip.
417
+ continue
418
+ > >> >> >> e18b9f42c901bf9f4c1ef03764c4ccfab1f83b7d
412
419
413
420
414
421
def add_object_type_filters (schema ):
@@ -447,7 +454,31 @@ def add_enum_filters(schema: GraphQLSchema):
447
454
return schema
448
455
449
456
457
+ < << << << HEAD
450
458
def add_create_mutations (schema : GraphQLSchema ):
459
+ == == == =
460
+ def add_filters_to_type_fields (_schema : GraphQLSchema ):
461
+ """
462
+ Add filters as arguments to fields for object types.
463
+ :param _schema:
464
+ :return:
465
+ """
466
+ for t in _schema .type_map .values ():
467
+ if not is_schema_defined_object_type (t ) or t .name .startswith ('_' ):
468
+ continue
469
+
470
+ # loop fields
471
+ for n , f in t .fields .items ():
472
+ field_type = get_named_type (f .type )
473
+ if not is_schema_defined_object_type (field_type ) and not is_interface_type (field_type ):
474
+ continue
475
+ _filter = _schema .type_map [f'_FilterFor{ field_type .name } ' ]
476
+ f .args ['filter' ] = GraphQLArgument (_filter )
477
+ return _schema
478
+
479
+
480
+ def add_create_mutations (_schema ):
481
+ > >> >> >> e18b9f42c901bf9f4c1ef03764c4ccfab1f83b7d
451
482
"""
452
483
Add mutations for creating object types.
453
484
:param schema:
0 commit comments