-
Notifications
You must be signed in to change notification settings - Fork 765
only_fields() not honored #250
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
At the moment, This sounds like a reasonable assumption, however, and in cases of large text columns and such, could lead to a noticeable performance improvement. I think the change would need to be made somewhere around this section of code to check for |
Agreed, this could have some positive performance benefits. I'm going to adjust the labels here to get some momentum going for a PR. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
So after spending quite some time on trying to implement this I've come to the conclusion that always applying class Person(DjangoObjectType):
class Meta:
model = PersonModel
fields = ("age")
name = String()
def resolve_name(person, info):
return f"{person.first_name} {person.last_name}" In this example using I think the prefered way for developers to achieve performance improvements by only fetching fields that are used has to be on a case by case basis and is best done by overriding the class Person(DjangoObjectType):
class Meta:
model = PersonModel
fields = ("age")
name = String()
def resolve_name(person, info):
return f"{person.first_name} {person.last_name}"
@classmethod
def get_queryset(cls, queryset, info):
return queryset.only('age', 'first_name', 'last_name') Be warned that this will negate any benefits of using I'm going to close this issue now because I don't think there is anymore to do here. |
I have
In a schema:
However, query
will show that all table fields are being fetched, not just id & title.
THere's a workaround - a resolver with
.only('id', 'title')
will give the desired result, but from what I understand 'only_fields` should be enough.Any help is appreciated!
D.
My requirements:
Django==1.10.4
git+https://github.com/graphql-python/graphene-django.git#egg=graphene-django
django-filter==1.0.4
The text was updated successfully, but these errors were encountered: