-
-
Notifications
You must be signed in to change notification settings - Fork 721
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IHttpClientFactory returns the wrong type, making it impossible to implement a custom IHttpConnection #6647
Comments
We initially designed strawberry shake as a client for blazor and nothing else :) At some point we will do a redesign and abstract in more... at the moment our focus is on other things. |
But you can go ahead and do a PR if you like. |
@michaelstaib are you aware of anyone working on a Unity-compatible version, aside from #4066? I have successfully implemented an |
As I said, we are fully open to this ... do a PR and we will help you get it in. |
@zaneclaes did you happen to find a solution for it? I see that your PR is still in draft. But I'm not sure if what you described is the actual cause of my runtime error. |
@Vingator full support for Unity is MUCH trickier than just this piece, but yes, I have it working in our project, including WebGL. Your error is a runtime problem, and unrelated to this thread. Specifically, you need to statically link all the necessary HotChocolate/StrawberryShake runtime DLLs compiled for the |
@zaneclaes thanks for the quick answer! I have the app working in the editor and even on iOS/Android, but I get this exception on WebGL at the point I'm querying data, that's why I supposed it was the same issue you were facing |
Is there an existing issue for this?
Product
Strawberry Shake
Describe the bug
Presumably, the goal of exposing a DI version of
IHttpConnection
is to allow the end-user to plug the connection with a different implementation. In my case,System.Net.HttpClient
is totally incompatible with my deployment. This should be the perfect use case forIHttpConnection
, so I can plug it with a compatible implementation.Unfortunately, even if a different connection is provided, Strawberry Shake still attempts to create its own HTTP client:
Regardless of if I use Singleton, Scoped, or Transient... the
MyHttpConnection
is never used. Strawberry Shake appears to load up theIHttpClientFactory
instance and create a new client for each request instead.This should be easy to fix on my side, except the
IHttpClientFactory
is incompatible withIHttpConnection
. The Factory is obligated to return aStrawberryShake.Transport.Http.HttpConnection
connection, instead of aIHttpConnection
:Thus, the
StrawberryShake.Transport.Http
library is strongly coupled to the system's implementation ofSystem.Net.Http.HttpClient
... which is in turn coupled toSystem.Threading
, meaning that the library cannot be used at all in environments where this is unavailable (i.e., Unity WebGL).All it would take to fix this is to change the return type to
IHttpConnection
. This is already what the code generators do, coercing theHttpClient
into the interface type, so it appears the current implementation is unnecessary.Steps to reproduce
Try to use a
IHttpConnection
that is not derived from `Relevant log output
No response
Additional Context?
I was able to create a very hacky solution by rewriting the generated code from StrawberryShake, but it's quite annoying since I'll need to do it every time the code is generated:
Version
13.6.1
The text was updated successfully, but these errors were encountered: