-
Notifications
You must be signed in to change notification settings - Fork 13
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
Reverse relations input in mutations update #14
Conversation
… creation. Added possibility to turn off auto related-name generation for mutations
…elation-fields-generation-option Reverse relations input in mutations update
@bellini666 @gghildyal created a PR for our previous discussion, just can't link issue. Feel free to comment. |
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.
Hi @justinask7 . Just made some comments and after resolving them I can merge the PR and do a new release!
Codecov Report
@@ Coverage Diff @@
## master #14 +/- ##
==========================================
+ Coverage 76.97% 77.14% +0.16%
==========================================
Files 7 7
Lines 556 560 +4
==========================================
+ Hits 428 432 +4
Misses 128 128
Continue to review full report at Codecov.
|
@@ -133,6 +134,11 @@ def _get_fields(model, only_fields, exclude_fields, required_fields): | |||
description=field.help_text, | |||
) | |||
elif isinstance(field, (ManyToOneRel, ManyToManyRel)): | |||
reverse_rel_include = graphene_django_plus_settings.MUTATIONS_INCLUDE_REVERSE_RELATIONS | |||
# Checking whether it was globally configured to not include reverse relations | |||
if isinstance(field, ManyToOneRel) and not reverse_rel_include and not only_fields: |
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.
@justinask7 Adding 'unless the field is in only_fields' to the comment certainly makes the reading easier.
@@ -94,7 +95,7 @@ def _get_fields(model, only_fields, exclude_fields, required_fields): | |||
# can be set to null, otherwise updates won't work. | |||
fields.extend( | |||
[ | |||
(field.related_name, field) | |||
(field.related_name or field.name + "_set", field) |
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.
This condition is used 3 times, so a utility function could be used.
modelname_set
)This PR is for resolving issue #13