SimpleGraphQL-For-Unity icon indicating copy to clipboard operation
SimpleGraphQL-For-Unity copied to clipboard

Can WebGL be fully supported?

Open johanhelsing opened this issue 3 years ago • 9 comments

Hi, this is a really cool project! I was considering doing something similar myself/forking the "graphQL-client-unity" project because I didn't like how it hides too much behind its gui in scriptable objects, and I also wanted something that was a Unity package. This project seems like a really good start.

Now, I mainly develop for WebGL, though. So it would be good to clarify exactly what works, and what doesn't.

This should work with all platforms (Mono/IL2CPP) except for WebGL, since Unity WebGL has issues with threading. If you are using WebGL, this package may be hit-or-miss for you at the present time. It makes use of UnityWebRequest where possible, but the WebSockets are the main issue, so subscriptions may not properly work. If you do not need subscriptions, WebGL may work just fine.

Specifically, the "may or may not" without WebSockets part may be good to clarify.

I think some parts of the Task API may be problematic on WebGL, but I don't know enough about it to say whether the parts used here are safe for WebGL or not, but in any case most of it should be possible to fix by using UniTask instead, in any case that's what I normally use myself to be on the safe side.

It would also be cool to check if the solution proposed here is enough to be able to support subscriptions on WebGL as well.

I'll do some prototyping, just wanted to say hi and hear your thoughts on:

  • Adding CySharp.UniTask as a dependency if there are issues with Task on WebGL
  • Alternatively adding CySharp.UniTask as an optional dependency and have ifdefs to alias to it installed.
  • Add some jslib helper code to support subscriptions

johanhelsing avatar May 04 '21 14:05 johanhelsing