{"id":1151,"date":"2022-01-03T22:04:10","date_gmt":"2022-01-03T20:04:10","guid":{"rendered":"https:\/\/www.rocworks.at\/wordpress\/?p=1151"},"modified":"2022-08-01T08:31:23","modified_gmt":"2022-08-01T06:31:23","slug":"graphql-on-unity-and-result-event-for-data-and-errors","status":"publish","type":"post","link":"https:\/\/www.rocworks.at\/wordpress\/?p=1151","title":{"rendered":"GraphQL on Unity and Result Event for Data and Errors&#8230;"},"content":{"rendered":"\n<p>The <a href=\"https:\/\/u3d.as\/2D81\">GraphQL for Unity Asset <\/a>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.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public class Sample1 : MonoBehaviour\n{\n    public void ResultEvent(GraphQLResult result)\n    {\n        if (result.Errors.Count==0)\n        {\n            Debug.Log(\"Data: \" + result.Data.ToString());\n        }\n        else\n        {\n            Debug.Log(\"Error: \" + result.Errors.ToString());\n        }\n    }\n}\n\n<\/code><\/pre>\n\n\n\n<p>Create a GameObject with this class as component and then you can drag and drop this GameObject to the Query GameObject and select the &#8220;ResultEvent&#8221; method. Every time when the query is executed then this function will be called with the result data (or error data).<\/p>\n\n\n\n<figure class=\"wp-block-gallery columns-1 is-cropped wp-block-gallery-1 is-layout-flex wp-block-gallery-is-layout-flex\"><ul class=\"blocks-gallery-grid\"><li class=\"blocks-gallery-item\"><figure><a href=\"https:\/\/www.rocworks.at\/wordpress\/wp-content\/uploads\/2022\/01\/Screenshot-2022-01-03-at-21.00.17.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"758\" src=\"https:\/\/www.rocworks.at\/wordpress\/wp-content\/uploads\/2022\/01\/Screenshot-2022-01-03-at-21.00.17-1024x758.png\" alt=\"\" data-id=\"1154\" data-full-url=\"https:\/\/www.rocworks.at\/wordpress\/wp-content\/uploads\/2022\/01\/Screenshot-2022-01-03-at-21.00.17.png\" data-link=\"https:\/\/www.rocworks.at\/wordpress\/?attachment_id=1154\" class=\"wp-image-1154\" srcset=\"https:\/\/www.rocworks.at\/wordpress\/wp-content\/uploads\/2022\/01\/Screenshot-2022-01-03-at-21.00.17-1024x758.png 1024w, https:\/\/www.rocworks.at\/wordpress\/wp-content\/uploads\/2022\/01\/Screenshot-2022-01-03-at-21.00.17-300x222.png 300w, https:\/\/www.rocworks.at\/wordpress\/wp-content\/uploads\/2022\/01\/Screenshot-2022-01-03-at-21.00.17-768x568.png 768w, https:\/\/www.rocworks.at\/wordpress\/wp-content\/uploads\/2022\/01\/Screenshot-2022-01-03-at-21.00.17-1536x1137.png 1536w, https:\/\/www.rocworks.at\/wordpress\/wp-content\/uploads\/2022\/01\/Screenshot-2022-01-03-at-21.00.17.png 1846w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/li><\/ul><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>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. Create &hellip; <a href=\"https:\/\/www.rocworks.at\/wordpress\/?p=1151\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">GraphQL on Unity and Result Event for Data and Errors&#8230;<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[52],"tags":[48,49],"class_list":["post-1151","post","type-post","status-publish","format-standard","hentry","category-graphql","tag-graphql","tag-unity"],"_links":{"self":[{"href":"https:\/\/www.rocworks.at\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1151","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rocworks.at\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rocworks.at\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rocworks.at\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rocworks.at\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1151"}],"version-history":[{"count":3,"href":"https:\/\/www.rocworks.at\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1151\/revisions"}],"predecessor-version":[{"id":1155,"href":"https:\/\/www.rocworks.at\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1151\/revisions\/1155"}],"wp:attachment":[{"href":"https:\/\/www.rocworks.at\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1151"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rocworks.at\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1151"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rocworks.at\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1151"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}