Giter VIP home page Giter VIP logo

Comments (6)

TimDumol avatar TimDumol commented on August 28, 2024

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.

mattalbr avatar mattalbr commented on August 28, 2024

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.

mattalbr avatar mattalbr commented on August 28, 2024

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.

mattalbr avatar mattalbr commented on August 28, 2024

@TimDumol

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.

TimDumol avatar TimDumol commented on August 28, 2024

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.

mattalbr avatar mattalbr commented on August 28, 2024

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.

#16

from strawberry-sqlalchemy.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.