ChilliCream / graphql-platform

Welcome to the home of the Hot Chocolate GraphQL server for .NET, the Strawberry Shake GraphQL client for .NET and Banana Cake Pop the awesome Monaco based GraphQL IDE.
https://chillicream.com
MIT License
5.28k stars 748 forks source link

Option to register StrawberryShake client as scoped service #3871

Closed MariaCobretti closed 2 years ago

MariaCobretti commented 3 years ago

can we get an option to register StrawberryShake clients as scoped services? I have an issue with blazor where I want to add an AuthorizationMessageHandler to the strawberry http client which uses an IAccessTokenProvider thats gets registered by the blazor sdk as a scoped service. for blazor wasm there is no difference between singleton and scoped and for the hosted model, the http client should in fact be registered as scoped.

https://docs.microsoft.com/en-us/aspnet/core/blazor/fundamentals/dependency-injection?view=aspnetcore-3.1&pivots=webassembly#service-lifetime

michaelstaib commented 3 years ago

@PascalSenn this should be a fairly easy thing. Can we get that in for 11.3.2 or 11.4.0?

michaelstaib commented 3 years ago

Alternatively we could get this into the 12 previews since we are close to jump to 12.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

gunr2171 commented 1 year ago

I'd like this functionality as well, please consider reopening. For my Blazor Server app, the authentication details are in scoped services, which are unreachable with everything being registered as singletons.

rawdenhoff commented 2 months ago

I would too please. Surely this is needed for a sharded multi-tenant app?

ecrocombe commented 1 month ago

+1 = me tooooooo

Use case:

  1. Connecting to server outside of client control.
  2. Server operators have asked for 1 websocket connection per 1 scope (customer) for load balancing reasons.
  3. The endpoint does not change between scopes
  4. Running a single dotnet console application.

Following the above rules, it is not currently possible to use this library.