strawberry-graphql / strawberry

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

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

Open axiomofjoy opened 1 week ago

axiomofjoy commented 1 week 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 1 week 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.