strawberry-graphql / strawberry-sqlalchemy

A SQLAlchemy Integration for strawberry-graphql
MIT License
91 stars 26 forks source link

Support class-style contexts in sqlalchemy mapper, a la fastapi style. #4

Closed mattalbr closed 2 years ago

mattalbr commented 2 years ago

https://strawberry.rocks/docs/integrations/fastapi shows two ways to implement contexts -- dictionary style, as is currently supported in this mapper, and class style, which is more idiomatic in fastapi and results in a "not subscritable" error in the current mapper implementation.

I much prefer modifying the mapper to support both styles, but if this is something you'd rather not add, I can in theory implement getitem on my custom context and it'll work just fine.

Re: tests, I couldn't find any existing tests that actually test the mapper end-to-end with a real postgres database and server. I would be happy to write an integration test of sorts that uses postgresql and fastapi and tests the mapper end-to-end, just let me know.