-
Notifications
You must be signed in to change notification settings - Fork 0
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
Optimization Hints #5
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you're apparently applying Black to the project, could you add/update the pyproject.toml
file so the files stay formatted?
graphene_django_extras/hints.py
Outdated
class OptimizationHints(object): | ||
def __init__(self, model_field=None, select_related=None, prefetch_related=None, only=None): | ||
self.model_field = model_field | ||
self.prefetch_related = prefetch_related if prefetch_related else [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should be set
objects.
self.prefetch_related = set(prefetch_related) if prefetch_related else set()
self.select_related = set(select_related) if select_related else set()
self.only = set(only) if only else set()
graphene_django_extras/utils.py
Outdated
|
||
optimization_hints = getattr(field_def.resolver, "optimization_hints", None) | ||
if optimization_hints: | ||
[ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using a list comprehension only for its side effects is considered bad style. I see that it's doing this a few lines up as well, but that should be fixed.
If you work with set
objects, you can skip the explicit loop entirely and express the intent of merging in the new entries directly:
select_related = sorted(set(select_related) | optimization_hints.select_related)
The sorted()
call is only necessary because the rest of the library doesn't pass those fields around as set
s like it should.
graphene_django_extras/utils.py
Outdated
for x in optimization_hints.select_related | ||
if x not in select_related | ||
] | ||
[ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for prefetch_related
here as well.
I haven't actually looked at the code here yet, but I think on forked repos we should probably follow the model of having Then this PR would probably be directed into a Once changes for nick's feedback are in, I'll take a look at the code as well |
You know, that's actually a good point. To keep this relatively up to date, we should avoid doing extra formatting changes if we can avoid it. Otherwise, we're going to forever run into merge conflicts when we merge the upstream version into our own. @FrownyFace Can you please undo the Black formatting, and pare this PR down to the core changes? |
@nickmeharry I'm pretty sure the project already uses |
Ok. My point stands though, this diff is too big to maintain in a fork if we want any hope of keeping things up to date. I guess figure out the line length this project uses and format it that way, so only meaningful changes are present here? |
@nickmeharry I agree with you. This project's |
un-formatted + nick changes incorporated @AlecRosenbaum |
Who is taking over ownership of this change/project? @VKuber Any thoughts on who will be taking over DW-11248? |
This might be resolved with |
Could you remove my review request from this PR? I don't have edit access anymore and this has been sitting in my review requests for quite some time now. I'm not sure who has access to do this still, maybe @cassiemeharry? |
usage (inside
graphql_schema/clinical_notes.py