graphql-python / graphql-python/graphene-sqlalchemy

SQLAlchemyConnectionField sort works only for top-level query.

Open
#163 3 comments 15 reactions 0 assignees View on GitHub
enhancement
Dominant language
Python
Stars
985
Forks
223
PR merge metrics
No merged PRs in 30d

Description

When I have SQLAlchemyConnectionField in top-level query, like in the [example](http://docs.graphene-python.org/projects/sqlalchemy/en/latest/tips/#sorting) 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!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.