unity3d - 如何在 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 更方便。这解决了我的问题。它还使用 simpleJSON 来反序列化响应。
推荐阅读
- javascript - 如何从给定的数字数组中找到最大数字?
- angular - Angular:如何将数据从按钮发送到服务?
- python-3.x - 将二进制字符串转换为二进制
- angular - 在 Angular 中维护同一组件的多个状态
- c# - C# Swagger 生成具有域身份验证的客户端
- python - 如何杀死另一个脚本运行的脚本
- java - git log --follow 包括错误的提交
- python - SQLite/Python 变量名和列名相同的问题
- r - 这是对数据框进行排序以在 ANOVA (aov) 中获得合理结果的正确方法吗?
- c - 为什么这段代码没有给出任何输出,也没有执行终止?