Comments (3)
@eamigo86 Thanks for fixing. I will continue to evaluate this and submit ideas/bugs/comments to further improve this great package!
from graphene-django-extras.
An attempt: I have changed the following (not sure if it works according to your ideas):
In fields.py
around line 227:
def list_resolver(self, manager, filterset_class, filtering_args, root, info, **kwargs):
qs = queryset_factory(manager, info.field_asts, filtering_args, **kwargs)
filter_kwargs = {k: v for k, v in kwargs.items() if k in filtering_args}
qs = manager.get_queryset()
qs = filterset_class(data=filter_kwargs, queryset=qs).qs
count = qs.count()
return DjangoListObjectBase(
count=count,
results=qs,
results_field_name=self.type._meta.results_field_name
)
In utils.py
around line 113:
def queryset_factory(manager, fields_asts=None, filtering_args=None, **kwargs):
if filtering_args is None:
filtering_args = {}
select_related = []
prefetch_related = []
filter_kwargs = {k: v for k, v in kwargs.items() if k in filtering_args}
available_related_fields = get_related_fields(manager.model)
for f in kwargs.keys():
temp = available_related_fields.get(f.split('_', 1)[0], None)
if temp:
if (temp.many_to_many or temp.one_to_many) and temp.name not in prefetch_related:
prefetch_related.append(temp.name)
else:
select_related.append(temp.name)
if fields_asts:
select_related, prefetch_related = recursive_params(fields_asts[0].selection_set, available_related_fields, select_related, prefetch_related)
if select_related and prefetch_related:
return manager.select_related(*select_related).prefetch_related(*prefetch_related)
elif not select_related and prefetch_related:
return manager.prefetch_related(*prefetch_related)
elif select_related and not prefetch_related:
return manager.select_related(*select_related)
return manager
I basically removed all filter(**kwargs)
calls from the queryset_factory
and moved them back to the list_resolver
method.
from graphene-django-extras.
Hello again @basilfx. First of all I would like to thank you very much for your comments and for your help. This bug, like the other two, are fixed in the more recent version 0.0.1b10.
from graphene-django-extras.
Related Issues (20)
- Dynamic Schema generation
- Travis rewrite to GitHub Actions HOT 2
- TODO
- Tried installing graphene-django-extras, but get errors about incompatibility HOT 3
- ImportError: cannot import name 'force_text' from 'django.utils.encoding' HOT 1
- Regarding UnionTypes
- Pagination Total Count HOT 7
- When using a model with a UUID Field as ID the update method does not provide a UUID Field HOT 1
- No type registered for model: <model>
- Getting duplicate results on a filter across multiple fields. Cannot add distinct.
- still maintained? HOT 5
- python error: can only concatenate list (not "tuple") to list in __init__.py
- Updates removing other fields if not supplied: Might not be specific to graphene-django-extras
- ImportError: cannot import name 'JSONField' from 'graphene_django.compat'
- AssertionError: Page value for PageGraphqlPagination must be a non-zero value
- Filtering on enum fields returns all results HOT 1
- Logs received not informative
- DjangoListObjectType BigInt Error
- Filter error HOT 2
- Pagination Total Count in DjangoFilterPaginateListField
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from graphene-django-extras.