Comments (6)
Possibly you can explicitly invoke Strawberry's field resolution (it's been a while since I've taken a look, but hopefully it's in the docs, otherwise you can dig into the source), but I'd personally just typing.cast()
it.
from strawberry-sqlalchemy.
My problem isn't with the type checker but with the actual runtime (don't want to have to call StrawberryType.my_field(obj)
everywhere, would much rather do obj.my_field()
), so typing.cast
won't do it.
I can do an absolutely hideous
result.__class__ = StrawberryType
but I find that a little scary
from strawberry-sqlalchemy.
Also, it seems like the autogenerated relationship resolver returns the model class instead of the strawberry class. Would love if it would return the strawberry class instead
from strawberry-sqlalchemy.
I got working locally a version of strawberry-sqlalchemy-mapper that generates a from_row classmethod and returns strawberry types instead of sqlalchemy types from each resolver. The resolvers can also handle a model being passed in as self for backwards compatibility, but I think the documentation should encourage returning strawberry types (else the static methods get confusing fast).
If I sent you a PR, do you think you could help me with some of the finer details? Namely, I don't know what a mapped interface is (as opposed to a type) and wouldn't be surprised if this fails for that case. I wouldn't be surprised if there are some other edge cases I missed.
from strawberry-sqlalchemy.
Hey @mattalbr -- sorry, been fairly busy recently. I'm not entirely certain what you're trying to achieve, but I believe a PR would help communicate that more effectively, so go for it.
from strawberry-sqlalchemy.
Sure thing! Sent the pull request, with a bunch of my thoughts in the description. Please take a look when you get a chance, and we can discuss/iterate over there.
from strawberry-sqlalchemy.
Related Issues (14)
- The unique() method must be invoked on this Result, as it contains results that include joined eager loads against collections HOT 1
- Input type? HOT 3
- Could not resolve the type of 'node'. Check that the class is accessible from the global module scope. HOT 3
- SQLAlchemy Relationships fail when using secondary Table HOT 8
- Not all items in a relationship are loaded HOT 5
- Relationship fails when attribute name != column name HOT 3
- Unsupported column type: `JSON` HOT 3
- Support relay-style pagination (e.g. via sqlakeyset) HOT 7
- Flask, SQLAlchemy, Mapper: Event Loop error when querrying relationships HOT 4
- Mapping fails after a session.commit(), Instance not bound to session HOT 1
- What is the rational for wrapping relationships into a Connection? HOT 1
- Package doesn't sucessfully build when installing on Windows 11 HOT 3
- Can't get relationships to work. Unexpected type ForwardRef? HOT 15
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from strawberry-sqlalchemy.