Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/328.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/unity3d/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Unity中的GraphQL查询_C#_Unity3d_Graphql - Fatal编程技术网

C# Unity中的GraphQL查询

C# Unity中的GraphQL查询,c#,unity3d,graphql,C#,Unity3d,Graphql,我在这里在线使用示例API:。我在Unity中使用GraphQL查询“用户”的数据。我能够创建查询并接收所有属性,如ID、名称等。不幸的是,我根本无法接收这些属性的详细信息。下面给出的两个函数都会抛出一个错误未知参数。我做错了什么 using GraphQlClient.Core; using Newtonsoft.Json; using UnityEngine; using UnityEngine.Networking; using UnityEngine.UI; public class

我在这里在线使用示例API:。我在Unity中使用GraphQL查询“用户”的数据。我能够创建查询并接收所有属性,如ID、名称等。不幸的是,我根本无法接收这些属性的详细信息。下面给出的两个函数都会抛出一个错误
未知参数
。我做错了什么

using GraphQlClient.Core;
using Newtonsoft.Json;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.UI;

public class GetStationDetails : MonoBehaviour {
    public GraphApi spacexGraph;
    public string Name = "Prakash";

    void Update () {
        if (Input.GetKeyDown (KeyCode.D)) {
            GetEnteredDetails ();
        }

        if (Input.GetKeyDown (KeyCode.F)) {
            GetAllDetails ();
        }
    }

    public async void GetEnteredDetails () {
        GraphApi.Query query = spacexGraph.GetQueryByName ("GetAllData", GraphApi.Query.Type.Query);
        query.SetArgs (new { name = Name });
        UnityWebRequest request = await spacexGraph.Post (query);
        Debug.Log ("Received: " + request.downloadHandler.text);
    }

    public async void GetAllDetails () {
        GraphApi.Query query = spacexGraph.GetQueryByName ("GetAllData", GraphApi.Query.Type.Query);
        query.SetArgs (new { first = 6 });
        UnityWebRequest request = await spacexGraph.Post (query);
        Debug.Log ("Received: " + request.downloadHandler.text);
    }
}


问题在于您尝试生成的查询不正确。 而不是使用:

query.SetArgs (new { name = Name });
你想用

query.SetArgs (new { where = new {name = new{_in = Name}} });
这将创建查询:

query GetAllData{
    users(where:{name:{_in: "Parkash"}}){
        id 
        name
        rocket
        timestamp
    }
}
You can also change _in to e.g "_like", if you want to get any name that partly matches what you've entered, or any other similar SQL keyword 

能否将GetAllData查询更改为:
query GetAllData{users(其中:{name:{{u in:“Prakash”}}}}}{id name}}
?如果输入您使用的参数,我也会得到一个未知参数错误,因为不支持查询:
users(name:“XXX”)
。相反,spaceX使用
用户(其中:{name:{u in:“XXX”})
@TheBv谢谢,我认为这就是问题所在。我可以在代码中更改它吗?就像在
query.SetArgs(新的{where:{name:..}
我该怎么做?