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

to use an ORM? #222

Open
SamuelDudley opened this issue Mar 21, 2020 · 3 comments
Open

to use an ORM? #222

SamuelDudley opened this issue Mar 21, 2020 · 3 comments

Comments

@SamuelDudley
Copy link
Member

SamuelDudley commented Mar 21, 2020

Thinking longer term:

It's likely that we will need a reflection in the graphql schema to a database.... There are options out there such as https://github.com/graphql-python/graphene-sqlalchemy however:

  1. the ORM does not support async DB operations
  2. the ORM drives the graphql schema (uses graphene https://graphene-python.org/)

When last rewriting -api (years ago now :S ) graphene was lagging quite a way behind graphql-core-next and so -api was written without the use of graphene. Today graphene uses graphql-core-next and offers some nice convenience functions and a clear way to build graphql queries from an ORM.

Things to think about:

  • Do we want to drive the graphql query generation using an ORM (as per graphene-sqlalchemy) or do we want to drive the ORM generation from the graphql schema? Personally I prefer the latter option (which goes against convention) as it means that if I can generate a graphql schema for something like mavlink we get the database models for free. Additionally, we can also choose not to have an ORM for some of the qraphql schema. If we drive the schema with the ORM we commit to needing a database entry for everything. This would make sense for 99% of CRUD web applications, but I don't think it makes sense for -api.
  • Something like tortoise-orm (https://github.com/tortoise/tortoise-orm) can be used to resolve the async DB operations issue noted above, but there is no out of the box support for graphql
  • I don't think it will be too hard to make a graphql schema -> tortoise-orm mapper if we do indeed go this way
  • Perhaps I need to rethink how I am representing the graphql schema in -api?
  • Will the adoption of something like graphene make on boarding developers simpler in the future when they want to write their own -api modules? Yes... but what are the technical trade offs?

Lots of questions and not a lot of answers at this stage...

@SamuelDudley
Copy link
Member Author

For the moment I will add tortoise-orm with the sqlite backend and use that for a user database and other info we wish to persist. Not buying into this as a solution, but I wont know what the problems are unless I try.

@SamuelDudley
Copy link
Member Author

Async mongo odm https://github.com/Scille/umongo

@SamuelDudley
Copy link
Member Author

https://edgedb.com/docs <- graphql support, async, nosql, built on postgres

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

No branches or pull requests

1 participant