def node_factory(custom_connection_field, model: DeclarativeMeta, custom_schemas_path: str = None) -> SQLAlchemyObjectType: node_name = model.__name__ + "Node" model_description = _get_table_args_key(model, "comment") if hasattr(model, "id"): model.db_id = model.id try: # import our nodes if exists model_node_class = getattr(import_module(custom_schemas_path), node_name) except AttributeError: logging.debug("Can't get {} from {} - auto generate".format( node_name, custom_schemas_path)) meta = type( "Meta", (object, ), { "model": model, "interfaces": (Node, ), "connection_field_factory": custom_connection_field.factory, "description": model_description, }, ) model_node_class = type( node_name, (SQLAlchemyObjectType, ), { "db_id": Int(description="Real ID from DB"), "Meta": meta }, ) return model_node_class