|
|
|
|
|
by juliennakache
2224 days ago
|
|
Quick plug: we've made good progress on solving this very problem for the SQLAlchemy ORM in Python. Our approach is a bit like Join-Monster but more flexible because: - we introspect your SQLAlchemy models and generate Dataloader-based resolvers that emit small independent SQL queries. This way this optimization composes naturally with other GraphQL types in your schema.
- we are thin wrapper on top of Graphene, the main GraphQL Python library. It makes it very easy to extend your type if needed. We also added ways to rename and modify the type of a column / field.
- for the SQL query generation we currently lean on SQLAlchemy to do the heavy lifting. It can emit efficient in IN() JOIN queries for us.
So far, it's been working quite nicely for us. We were able to generate decently performant schemas with very boilerplate on top of our existing SQLAlchemy models. And each time we've run into a case that the library did not optimize well for us, we were able to easily override its behavior by writing our SQLAlchemy queries.There is still room for performance improvements but I'm confident we'll get there eventually (though I expect the optimizations to only work for DBs that support LATERAL JOINs). My main focus at the moment is to come up with an API that it possible to create performant types that aggregate multiple tables. Links
- https://github.com/graphql-python/graphene-sqlalchemy
- https://github.com/graphql-python/graphene-sqlalchemy/pull/2... EDIT: formatting |
|