Add filters support for connections.
FilterableConnectionField will create InputFilter object with filters for every Connection's Node's property. The date type will be the same as in Node object. Currenly enums and comlex objects (not scalars) are not supported.
I've added this filter operations:
Multiple filters will always work like AND.
1 similar comment
I think my criticisms are stylistic and personal preference. There's some typos and I personally wouldn't leave TODO comments in a contribution.
I also think that some of your function names as well the use of
However, I don't dispute that this works. I borrowed and adapted it for my own needs and it helped me to understand how arguments are constructed.
Honestly, I'm really not sure what the stance graphql-python has on contributions. If you look across their projects, there are so many ignored questions and contributions in addition to tutorials and examples that don't even work correctly. Either way, I support adding filtering to this similar to how it is done in the graphene-django implementation.
Here is the relevant part of my implementation for comparison:
In the code, you reference a series of aggregations & custom exceptions - what code are you referencing here?
Hey there is a lot to like here but there's also a lot of problems that should be glaringly obvious.
You have obviously never tried your implementation without required fields or you would have run into the first glaring bug in your initializer where you would run into an exception for attempting to iterate over None:
Later on you also use the required fields in a list comp that blows up if it's None
Also I'm not sure why but you can't just pass this custom ConnectionField a regular SQLAlchemyObjectType that implements Node like you can with the standard SQLAlchemyConnectionField. Seems bizarre but probably stuff in your field generators does something after the normal constructor creates Edges on the object. (Honestly Graphene in general is one of the worst documented APIs I have ever used and I'm only about a week into it so I have no idea how anything really works yet)
And lastly SQLAlchemy adds anonymous BindParameters to models as columns in more complex ORM use cases (or something, see https://docs.sqlalchemy.org/en/13/core/sqlelement.html) which then blows up code as it generates Fields for every column when you introspect the Model class. In these cases, there will be a filter named "'%(4539858784 anon)s" and the code will throw an Exception that something like "Field names must match (the regexp below) but the field name is "'%(4539858784 anon)s". So I had to go and change your create_filter_argument method like so: