News for hackers. Stuff that matters.
Re:On GraphQL-to-SQL by chrstphrhrt on Friday May 22, 2020 @10:26AM (#23272409)
I'm working on a project that depends on Graphene and Django (not my choice). Any ideas off hand about doing the same thing there? IIRC Django can also use SQLAlchemy but it didn't used to be very nice back in the day.
Re:On GraphQL-to-SQL by juliennakache on Friday May 22, 2020 @11:47AM (#23273326)
I haven't looked into the Django ORM recently but last time I checked I think it would have been a lot more challenging to implement something similar. SQLAlchemy is a lot more flexible, very well designed and actively maintained. My recommendation would be to try using SQLAlchemy with Django. It should work without any problems but you might lose the ability to use some of the Django plugins that assume the Django ORM.
Re:On GraphQL-to-SQL by ris on Friday May 22, 2020 @01:27PM (#23274634)
> IIRC Django can also use SQLAlchemy

It's possible to use sqlalchemy with django, but you're basically on your own (don't expect to be able to use django-admin and other pluggable apps etc.)

> it didn't used to be very nice back in the day

Having used both django and sqlalchemy ORMs very heavily, I've got to say that django does what it does extremely well and intuitively. For what the vast majority of webapps need to do, the "obvious" way of constructing the query causes django to do more or less the right thing. sqlalchemy on the other hand I love for other reasons, but am frequently annoyed at how much faffing is required to do the simple things in a concise way.

Re:On GraphQL-to-SQL by true_religion on Friday May 22, 2020 @07:00PM (#23278049)
One thing you can do is use SQL alchemy, by duplicating code so you will have Django code to handle things you want to do in Django.... typically anything that touches the admin or model forms, but use SQL Alchemy for everything else.
Re:On GraphQL-to-SQL by ris on Saturday May 23, 2020 @08:19AM (#23282320)
Yyyyeah, but you do end up duplicating potentially quite a lot of code, especially if you're following the (IMHO nice) "fat models" approach.

I think a few people have thrown around the idea of creating a frontend to sqlalchemy to allow it to understand django model definitions and QuerySet semantics but I don't think anything's come of it.