如何在 Unity3D proyecto26 库中使用 graphql?



我在API上实现了GraphQL,但是我不知道如何在我正在使用的库上执行它。

using UnityEngine;
using UnityEditor;
using Models;
using Proyecto26;
using System.Collections.Generic;
using UnityEngine.Networking;
using UnityEngine.UI;
public class AuthController : MonoBehaviour {
private readonly string basePath = "http://localhost:1337";
public void Get(){
currentRequest = new RequestHelper {
Uri = basePath + "/graphql",
Method = "GET",
BodyString = "query {users {_id username email}}" //Use it instead of 'Body' to serialize using other tools
};
RestClient.Get<Auth>(currentRequest).Then(
res => {
string encodedString =JsonUtility.ToJson(res, true);                
JSONObject jar = new JSONObject(encodedString);
Debug.Log(jar);
});
}
}

它只是返回错误。它可能是"BodyString",但我不太确定。因为这是我第一次在Unity项目中使用GraphQl。请帮助我如何使用 Proyecto26 正确查询此问题。

我已经通过使用这个库解决了这个问题 Gazuntype/graphQL,现在在我的项目中使用 GraphQL 更方便。这解决了我的问题。它还使用简单 JSON 来反序列化响应。

最新更新