The GraphQL for Unity Asset can be used to execute GraphQL queries in Unity. The result is set on properties of Unity objects and there is also a Unity Event on the GraphQL Query Object where user-defined function of a GameObject can be triggered every time when a queries returns data or an error.
public class Sample1 : MonoBehaviour
{
public void ResultEvent(GraphQLResult result)
{
if (result.Errors.Count==0)
{
Debug.Log("Data: " + result.Data.ToString());
}
else
{
Debug.Log("Error: " + result.Errors.ToString());
}
}
}
Create a GameObject with this class as component and then you can drag and drop this GameObject to the Query GameObject and select the “ResultEvent” method. Every time when the query is executed then this function will be called with the result data (or error data).