strawberry
strawberry copied to clipboard
Move context out from info and expose it as a parameter
Being able to request info (and root) only when needed is a nice feature, but considering we haven't exposed a type for info yet, it might be nice to all to request for context as well
So, from this:
@strawberry.federation.type(extend=True)
class Query:
@strawberry.field
def strawberry(self, info) -> str:
return info.context.strawberry_repo.get_one()
to this:
@strawberry.federation.type(extend=True)
class Query:
@strawberry.field
def strawberry(self, context: MyContextType) -> str:
return context.strawberry_repo.get_one()
Upvote & Fund
- We're using Polar.sh so you can upvote and help fund this issue.
- We receive the funding once the issue is completed & confirmed by you.
- Thank you in advance for helping prioritize & fund our backlog.
Ah this would be awesome! It would also solve the problem with PyCharm not autocompleting custom contextes without the mypy plugin!
I was thinking about this today, and I think it could be interesting to create a StrawberryContext type that we can use to understand which argument is the context