Closed jheld closed 3 years ago
Thanks! Cool about the Django newsletter, I didn't know that.
I'm not sure how Django-RestQL works with Serializers? If it uses the "regular" DRF serializers, then it seems like a pretty good match. I don't have too much capacity to work on adapting it, if it uses a different serializer format though.
I have actually considered another approach to tracking the changes, that would mean it could work with anything. It will work like this:
with track_qs(my_queryset)
or equivalent)proxy model
- the proxy model acts just like a regular model, except it tracks all field accesses - this means that we can track all field accesses that require an extra database lookupfirst_model.other_model_from_db.third_model_from_db
- each of these field accesses are tracked.I'm hoping an approach like that could work in many environments, even ones that aren't as statically analyzable as most serializers.
This looks really cool.
My team has been using and contributing to RestQL for several months and we built the majority of the implementation around auto eager loading/mapping definitions, from the view level.
We definitely considered trying to do auto eager in the way you have but certainly ran into the issue of SerializerMethodField and for that reason we opted not to implement that.
All that said, having the option to have this mixin potentially play well with django-restql may be advantageous for projects that don't have as many complex serializers, don't want to manage the mapping definition for those serializers (it's explicit but needs to be maintained by the team), but still want the option of GraphQL-like data fetching (and other niceties provided by RestQL).
I haven't used this library: it was listed on the most recent Django newsletter (congrats!). But it seems like these two projects have a lot in common (again, at this time I haven't tried out this project or looked at its source), and either combining or testing out integrating them could be very advantageous.
Curious for your thoughts!