0

I have strawberry setup to run with fastapi. Basically, like the examples, the fastapi initialization code creates a GraphQLRouter with a Schema object and a context_getter.

Everything works great, I use __get_context to pass some Dependencies in.
What I don't know is, how do I conditionally call Dependencies?

Like I might want a Depends(UserManager) on some graphql calls and Depends(ClientManager) on others. Normally in fast api, I could use different routers to assign different dependencies. But most of the strawberry fastapi examples use a single router for a single schema. Or more rarely multiple routers across multiple schemas.

How do I break up a strawberry GraphQL Schema across multiple GraphQLRouters so I can use different Depends chains for different requests?

Mark Rogers
  • 96,497
  • 18
  • 85
  • 138

0 Answers0