Skip to content
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

Merged
merged 8 commits into from
Jul 29, 2020

Conversation

justinask7
Copy link
Contributor

  • Added global settings.
  • Fixed relation without related_name ObjectType creation (will be added as modelname_set)
  • Added possibility to turn off auto related-name generation for mutations through global setting

This PR is for resolving issue #13

… creation. Added possibility to turn off auto related-name generation for mutations
…elation-fields-generation-option

Reverse relations input in mutations update
@justinask7
Copy link
Contributor Author

justinask7 commented Jul 29, 2020

@bellini666 @gghildyal created a PR for our previous discussion, just can't link issue. Feel free to comment.
Also - it can be squash-merged after approval

Copy link
Member

@bellini666 bellini666 left a 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!

graphene_django_plus/settings.py Outdated Show resolved Hide resolved
graphene_django_plus/settings.py Outdated Show resolved Hide resolved
graphene_django_plus/settings.py Outdated Show resolved Hide resolved
tests/test_mutations.py Outdated Show resolved Hide resolved
tests/test_mutations.py Outdated Show resolved Hide resolved
@bellini666 bellini666 linked an issue Jul 29, 2020 that may be closed by this pull request
@justinask7 justinask7 requested a review from bellini666 July 29, 2020 12:43
@codecov
Copy link

codecov bot commented Jul 29, 2020

Codecov Report

Merging #14 into master will increase coverage by 0.16%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            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              
Impacted Files Coverage Δ
graphene_django_plus/mutations.py 85.85% <100.00%> (+0.18%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7c05908...124fa02. Read the comment docs.

@bellini666 bellini666 merged commit 7135351 into 0soft:master Jul 29, 2020
@@ -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:

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)

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Issues with new 2.3 release
3 participants