I am using DjangoFilterConnectionField
in my project like this:
all_sessions = DjangoFilterConnectionField(SessionNode, filterset_class=AgendaFilter)
SessionNode
is created based on Session
model in my Django application. Now, I would like to be able to order these sessions by two fields: start_date
and start_time
.
To achieve that I've created the following filter:
class AgendaFilter(FilterSet):
class Meta:
model = Session
exclude = []
order_by = OrderingFilter(
fields=(
("start_date", "start_date"),
("start_time", "start_time")
)
)
When I filter sessions by only one field using orderBy
, the query results are ordered correctly as expected. When I try to use both fields in the filter (shown below), the results returned are not ordered according to either of them:
{
allSessions(orderBy: "[start_date, start_time]") {
edges {
node {
id
startDate
startTime
}
}
}
}
I've tried different ways of passing the two fields to orderBy
, but none of them worked for me. How can I correctly order by start_date
and then by start_time
in one query? According to the graphene documentation, this is possible:
Ordering You can use OrderFilter to define how you want your returned results to be ordered.
Extend the tuple of fields if you want to order by more than one field.
Is this is a bug in graphene or am I doing something wrong?