graphene-sqlalchemy icon indicating copy to clipboard operation
graphene-sqlalchemy copied to clipboard

SQLAlchemyConnectionField sort works only for top-level query.

Open comtihon opened this issue 6 years ago • 3 comments

When I have SQLAlchemyConnectionField in top-level query, like in the example it works perfectly.

But if I have Query -> Viewer -> SomeObject -> PetConnection -> Pet sort won't work. In case of top level query UnsortedSQLAlchemyConnectionField.get_query is called, which injects sorting. In case of nested object connection resolve - gettattr already takes model object (SomeObject) with Pets array populated from the db. So getattr just takes these pet without any ordering.

Workaround here is to have custom resolver, but it would be much better to fix it on library level. Thanks!

comtihon avatar Sep 05 '18 12:09 comtihon

Hello @comtihon, have you been able to work out a custom solution? I'm having this same problem and I still can not think of something generic for the models.

igr-santos avatar Apr 10 '19 06:04 igr-santos

Possibly helpful for others: https://github.com/graphql-python/graphene-sqlalchemy/pull/164

kkinder avatar Feb 08 '20 07:02 kkinder

Would love to see an update to this!

sabard avatar Sep 30 '20 20:09 sabard