gazuntype / graphQL-client-unity

This repository houses a unitypackage that can be included in your Unity Project to enable it communicate with a graphQL server.
Apache License 2.0
292 stars 50 forks source link

Stuck at introspect #34

Open LemonTreeGitHub opened 2 years ago

LemonTreeGitHub commented 2 years ago

Hello,upon importing graphQL into Unity,i got error regarding this line

After that,i check out the demo,hitting the introspect link on both pokemon and user.Both get stuck on " API is being introspect, please wait" I even test it on a working project link and the bug remain

What should I do ?

wnmmenoovg commented 2 years ago

Default UnityWebRequest does not implement GetAwaiter()

You need an extension for that. You can try

public class UnityWebRequestAwaiter : INotifyCompletion
{
    private UnityWebRequestAsyncOperation asyncOp;
    private Action continuation;

    public UnityWebRequestAwaiter(UnityWebRequestAsyncOperation asyncOp)
    {
        this.asyncOp = asyncOp;
        asyncOp.completed += OnRequestCompleted;
    }

    public bool IsCompleted { get { return asyncOp.isDone; } }

    public void GetResult() { }

    public void OnCompleted(Action continuation)
    {
        this.continuation = continuation;
    }

    private void OnRequestCompleted(AsyncOperation obj)
    {
        continuation();
    }
}

public static class ExtensionMethods
{
    public static UnityWebRequestAwaiter GetAwaiter(this UnityWebRequestAsyncOperation asyncOp)
    {
        return new UnityWebRequestAwaiter(asyncOp);
    }
}