-
Notifications
You must be signed in to change notification settings - Fork 765
Fix ManyToMany schema mapping #181
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
Fix ManyToMany schema mapping #181
Conversation
It appears that Django 1.8 does not have the |
Another option might be to add logic to |
That did the trick locally, and is passing all the tests. I'll update the PR description with the new solution. |
a. @spockNinja you are amazing Considering how bleeding edge GraphQL is, my recommendation would be if 1.8 doesn't have the fields needed the focus on 1.9 and above. LTS is a stability release, and one of the downsides to that is not having every new piece of tech. But I'm not a maintainer of this repo, so I'm not sure what weight that advice holds here. |
I have changed the solution to not use the "new" |
@syrusakbary I believe this PR is ready for review. I have tested it with our data, added automatic tests, and all tests are passing. Let me know if there is anything I need to improve to get this merged. Thanks! 😄 |
Great PR, and great analysis on how to make it in a compatible way. |
In case anyone needs it now, I left a workaround for graphql m2m connections in #172 |
Issues
closes #155
closes #157
closes #172
The Problem
ManyToMany fields were not mapping correctly and required some less than ideal workarounds.
This was because the
get_reverse_fields
did not differentiate between the original instantiation of theManyToMany
and the automaticreverse
version. There was then two copies of the field coming back fromget_model_fields
, the one at the end being incorrect.The Solution
Unfortunately, the
reverse
flag on the "reverse" fields has not always been around. To maintain backwards compatibility,get_reverse_fields
is doing the best it can.Instead, we can make sure that local fields are not overridden by reverse fields. So a few lines in
get_model_fields
limitsget_reverse_fields
to skip local fields.Tests
Before fix:

After fix:

Example
Before fix:

After fix:
