Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error for nested filtered connection fields that are Sets #55

Open
qotho opened this issue Apr 16, 2021 · 1 comment
Open

Error for nested filtered connection fields that are Sets #55

qotho opened this issue Apr 16, 2021 · 1 comment

Comments

@qotho
Copy link

qotho commented Apr 16, 2021

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.

@art1415926535
Copy link
Owner

art1415926535 commented Oct 31, 2021

Nested connections are managed by graphene_sqlalchemy.

You can override FilterableFieldFactory (registry is graphene_sqlalchemy object) and set to FilterableConnectionField as factory variable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants