strawberry-graphql / strawberry

A GraphQL library for Python that leverages type annotations 🍓
https://strawberry.rocks
MIT License
4.02k stars 533 forks source link

make it automatic to include types implementing an interface in the graphql schema #3684

Open axiomofjoy opened 3 weeks ago

axiomofjoy commented 3 weeks ago

In order to use interfaces as a return type, I have to explicitly include all of the types implementing the interface via the types argument in strawberry.Schema in order for those types to be included in the schema. This is inconvenient. I would like for strawberry to automatically detect these types for me (e.g., by looking for __subclasses__ of the implementing type), or at least have utilities that make this easier.

Upvote & Fund

Fund with Polar

erikwrede commented 3 weeks ago

Interesting idea! I built a quick PoC in #3686. However, it won't be as easy as depicted there to implement this. Taking the discussion to discord.