graphql-python / graphene-django

Build powerful, efficient, and flexible GraphQL APIs with seamless Django integration.
http://docs.graphene-python.org/projects/django/en/latest/
MIT License
4.28k stars 766 forks source link

Not require explicitly set `ordering` in `DjangoConnectionField` #1518

Closed kiendang closed 4 months ago

kiendang commented 5 months ago

I'm working on fixing #1516, probably by setting ordering = ["pk"] by default in DjangoConnectionField class Meta.

However I don't find any reference of ordering in both this or Graphene's code base. Does anyone have any idea? Or is setting ordering actually not doing anything? @sjdemartini @tcleonard

gsvr commented 4 months ago

@kiendang It looks like you're getting stuck at the same place I did - there doesn't seem to be an easy way to define ordering in a Meta class somewhere. The only ordering method I could find in the docs was using an OrderingFilter, but setting a default with that doesn't look easily viable. I would suggest opening another feature issue to implement default ordering so this PR can be wrapped up :)

kiendang commented 4 months ago

@gsvr my problem is that I don't know if setting

class Meta
    ordering = ["pk"]

actually does anything because I can't seem to find any code that references ordering in this or Graphene code base.

If that is the case, we should just revert #1495.

In case that ordering actually works, setting a default ordering is doable, but even in this case I'm fine with reverting #1495 first then implementing that later.

gsvr commented 4 months ago

@kiendang Yeah, I also searched around, and I don't think setting ordering in class Meta actually does anything. I couldn't find any usage of that in the docs or the code.