graphene-sqlalchemy-filter
graphene-sqlalchemy-filter copied to clipboard
Error for nested filtered connection fields that are Sets
The UnsortedSQLAlchemyConnectionField.resolve_connection function throws the following error when it tries to resolve relationship fields that are Sets instead of lists (defined using SQLAlchemy's "collection_class=set" on the relationship).
ERROR: Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/promise/promise.py", line 87, in try_catch
return (handler(*args, **kwargs), None)
File "/usr/local/lib/python3.8/site-packages/graphene_sqlalchemy/fields.py", line 56, in resolve_connection
connection = connection_from_list_slice(
File "/usr/local/lib/python3.8/site-packages/graphql_relay/connection/arrayconnection.py", line 79, in connection_from_list_slice
_slice = list_slice[
graphql.error.located_error.GraphQLLocatedError: 'InstrumentedSet' object is not subscriptable
This can be worked around for fields in the GraphQL model classes by adding a resolver function that converts the sets to lists, but nested filtered connection fields use the UnsortedSQLAlchemyConnectionField.resolve_connection function by default, which doesn't seem to be easy to override.
Nested connections are managed by graphene_sqlalchemy.
You can override FilterableFieldFactory
(registry is graphene_sqlalchemy object) and set to FilterableConnectionField
as factory
variable.