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
Fixes filtering in nested nodes. #82
Fixes filtering in nested nodes. #82
Conversation
Great PR! Could be possible to have a test too showcasing how it the filtering got fixed so we don't fall in this bug in the future? Thanks! (and happy holidays!) |
Ah, very nice. |
3 similar comments
@syrusakbary I added a test for this issue. Please, check it to ensure everything is right. Greetings. |
@drakon The problem in #80 was in the line: |
Yeah, that I got. Thanks for the hint! :) My point was that in that case the connection_resolver method still is broken (not an issue that is new with your PR). Assuming it returns a list, default_manager never gets considered and therefore I'd argue that a test considering this would fail. Otherwise your solution is better. Mine originally was more of an easy workaround to make it work in case someone needs this functionality. So I didn't have to fork and fix the issue. Your fix seems like a better solution. //Update |
@drakon You are right, when I coded the fix I realized it won't be filtered if a list is returned by resolver and I think there are no efficient way to filter the list. But this is my question: Is there a real case in which a list is returned? I think it shouldn't do it, because you need a queryset to be able to apply a filter. Maybe using lists in tests is an error. Anyway, I would like to know @syrusakbary 's opinion on this matter |
Yeah, exactly my thoughts! Maybe it is required by some GraphQL spec. Also interested in @syrusakbary 's thoughts on this. If it's really a non intended use case we could at least issue a warning that the filters get ignored when the resolver returns a list. |
In general a However this PR handles this cases perfectly and also with a good test coverage... so everything looks great! |
@syrusakbary thanks for getting this merged into master. Is there a planned release that will have this included in it? |
Also curious as to next pypi release... 1.2.1 was released on 2016-12-16. |
Hi @nickhudkins @imsickofmaps. Sorry for the delay! |
@syrusakbary This PR introduces a serious efficiency problem, I'll try to push a fix today. I hope this can be included in the next release. |
@pchinea no worries, I will wait few days and revert in case is not solved so we can release a new version. |
Just thought I would let you guys know that there's an issue with this fix, if you do something like:
It will cause an error due to the slicing with
The message says it all: Code does some combination of QuerySets after the resolver has finished it computation. This operation: I feel like slicing data inside the resolver is a reasonable operation, the code should be able to handle it. |
@antonkhelou If you want to use a custom resolver instead of the automatic resolver you should return a list to avoid further filtering, in this case:
Greetings |
@antonkhelou Anyway, I think there are no way to fix this, you can't filter a queryset after slicing. This isn't a graphene or django limitation, this is a SQL limitation (you can't use WHERE clause after LIMIT clause). In this case I'm afraid you'll need to find a way to get the final query in the resolver or using Relay to slice with the GraphQL query (with |
Fixes error filtering sub-nodes. The relationships were resolved but not filtered as it was notified in issues #21 and #30.
For example: