-
Notifications
You must be signed in to change notification settings - Fork 766
How would one implement totalCount or count on DjangoFilterConnectionField? #636
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
Comments
Could you subclass |
Also, look at relay connections and pagination. You might be able to get your answer there. |
@phalt, any pointers? I'm going through issues and docs across graphene and graphene-django, and there seems to be some confusion regarding a best practice approach here. This is another item I'll add to the FAQ when I get my head around, as I said, best practice. It's trivial to implement using |
@phalt, never mind. Got it. I'll add this to the wiki FAQ once editing is enabled. Turns out the trick is to subclass
This allows, in my example here, querying:
Which returns:
|
@changeling sorry I was being a bad contributor and replying on my phone. Your suggestion is great - wiki is now open :) |
No worries! I'll see about adding this as well. |
Added. |
Hi guys, [adding @changeling ]
I am using python3.7, I see tests for this in the code base. So, I am thinking that I am doing something wrong.
Thank you for your help! |
Solution so that
|
Is this an official resolution to the issue? It looks like a very clever hack around the issue. |
thx |
that was suppose to work but what if my final object is be a
how would I filter in here |
any way I can have the totalCount without using that ExtendedConnection solution. The solution works but I'd like not to have my final data object cluttered with edges and nodes everywhere. For a big nested tree it becomes very hard to read |
Is anyone aware of a clean way to include this in a subclassed |
Something like this should work: class DjangoObjectTypeSubclass(DjangoObjectType):
@classmethod
def __init_subclass_with_meta__(cls, connection_class=ExtendedConnection, **options):
super().__init_subclass_with_meta__(connection_class=connection_class, **options) |
Thank you, @ndpu. This looks like exactly what I need. I'll give it a try and follow up. |
With
Connection
, one can implement acount
onedges
like so:Given that
DjangoFilterConnectionField
won't accept aConnection
, but requires aDjangoObjectType
, how would one implement an equivalentcount
?The text was updated successfully, but these errors were encountered: