{"id":5813,"date":"2023-06-25T10:23:40","date_gmt":"2023-06-25T10:23:40","guid":{"rendered":"https:\/\/youngitconsulting.de\/staging\/2187\/?p=5813"},"modified":"2023-07-08T07:14:12","modified_gmt":"2023-07-08T07:14:12","slug":"graphql-in-liferay-dxp","status":"publish","type":"post","link":"https:\/\/youngitconsulting.de\/staging\/2187\/graphql-in-liferay-dxp\/","title":{"rendered":"GraphQL in Liferay DXP"},"content":{"rendered":"<p>&nbsp;<\/p>\n<p><img data-recalc-dims=\"1\" fetchpriority=\"high\" decoding=\"async\" class=\"alignnone wp-image-5815 size-full\" src=\"https:\/\/i0.wp.com\/youngitconsulting.de\/staging\/2187\/wp-content\/uploads\/2023\/06\/gp2.png?resize=1200%2C515&#038;ssl=1\" alt=\"\" width=\"1200\" height=\"515\" srcset=\"https:\/\/i0.wp.com\/youngitconsulting.de\/staging\/2187\/wp-content\/uploads\/2023\/06\/gp2.png?w=1200&amp;ssl=1 1200w, https:\/\/i0.wp.com\/youngitconsulting.de\/staging\/2187\/wp-content\/uploads\/2023\/06\/gp2.png?resize=300%2C129&amp;ssl=1 300w, https:\/\/i0.wp.com\/youngitconsulting.de\/staging\/2187\/wp-content\/uploads\/2023\/06\/gp2.png?resize=1024%2C439&amp;ssl=1 1024w, https:\/\/i0.wp.com\/youngitconsulting.de\/staging\/2187\/wp-content\/uploads\/2023\/06\/gp2.png?resize=768%2C330&amp;ssl=1 768w\" sizes=\"(max-width: 1000px) 100vw, 1000px\" \/><\/p>\n<p><a href=\"https:\/\/weu-www.sway-cdn.com\/s\/46qr8701uZObA4cF\/images\/rwh-gGXj_0zpJn?quality=1012&amp;allowAnimation=true\">Checkout the flow diagram here\u00a0<\/a><\/p>\n<div id=\"container_jd1bfU7_095\" class=\"container \">\n<div id=\"container_l3mShT68F40\" class=\"container \">\n<div id=\"container_P6aieuHENv1\" class=\"container \" role=\"heading\" aria-level=\"2\">\n<div id=\"container_9f-FBw8yHY2\" class=\"container \">\n<div class=\"text_wrapper ChapterTitleNone color_ChapterText2\">\n<h1 id=\"paragraph_RggWoXmc6J0\" dir=\"ltr\"><span id=\"text_DXpXH7BZSB3\" class=\"\">What is GraphQL ?<\/span><\/h1>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div id=\"container_wnvNRpmXEE7\" class=\"container \">\n<div id=\"container_yZUG49IzU4_\" class=\"container \">\n<div id=\"container_qXWMScE5Bd2\" class=\"container \">\n<div class=\"text_wrapper TextBodyNone color_TextUnemph\">\n<p id=\"paragraph_3p5itUsAxI4\" dir=\"ltr\"><span id=\"text_o1TZzx1LRq1\" class=\"\">GraphQL is basically a query language to read or mutate data in API . In simple words its a way to call API for read and write purpose using query like syntax . Using GraphQL feels like you are querying an API service instead of a database . This was developed by Facebook .<\/span><\/p>\n<p id=\"paragraph_Gi5itUcAxI4\" dir=\"ltr\">\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div id=\"container_wW1bfUtz-95\" class=\"container \">\n<div id=\"container_Ovt2HFLJSjA\" class=\"container \">\n<div id=\"container_2NDoAg6Mke7\" class=\"container \" role=\"heading\" aria-level=\"2\">\n<div id=\"container_kkOonVGKMgA\" class=\"container \">\n<div class=\"text_wrapper ChapterTitleNone color_ChapterText2\">\n<h1 id=\"paragraph_THu6ne7vIL2\" dir=\"ltr\"><span id=\"text_Jn5TCTfVZ_3\" class=\"\">Challenges with REST<\/span><\/h1>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div id=\"container_hVDr0J98211\" class=\"container \">\n<div id=\"container_LXTCECD6w4B\" class=\"container \">\n<div id=\"container_z21Mv4c5kYB\" class=\"container \">\n<div class=\"text_wrapper TextBodyNone color_TextUnemph\">\n<p id=\"paragraph_IsJmc96B8MA\" dir=\"ltr\"><span id=\"text_Su0gSByU5QA\" class=\"\">REST API calls has lot of advantages which is well known to developers but at the same time there are few drawbacks which REST API calls doesn&#8217;t address . Lets talk about few of them<\/span><\/p>\n<p id=\"paragraph_u3Kmc9cB8MA\" dir=\"ltr\"><span id=\"text_KY4tUgxIJr6\" class=\"TextBodyEmph color_TextEmph\">Over fetching<\/span><span id=\"text_7f4tUgBJJr6\" class=\"\">: This is when the API endpoint provides way more information than required by the client.<\/span><\/p>\n<p id=\"paragraph_hAKmc9sB8MA\" dir=\"ltr\"><span id=\"text_FQZeV2hVT_C\" class=\"TextBodyEmph color_TextEmph\">Under fetching<\/span><span id=\"text_SJZeV2RVT_C\" class=\"\">: This is when the API endpoint doesn\u2019t provide all of the required information. So, the client has to make multiple requests (API Calls) to get everything the application needs.<\/span><\/p>\n<\/div>\n<\/div>\n<p dir=\"ltr\"><img data-recalc-dims=\"1\" decoding=\"async\" class=\"aligncenter wp-image-5816 size-full\" src=\"https:\/\/i0.wp.com\/youngitconsulting.de\/staging\/2187\/wp-content\/uploads\/2023\/06\/gp3.png?resize=1133%2C814&#038;ssl=1\" alt=\"\" width=\"1133\" height=\"814\" srcset=\"https:\/\/i0.wp.com\/youngitconsulting.de\/staging\/2187\/wp-content\/uploads\/2023\/06\/gp3.png?w=1133&amp;ssl=1 1133w, https:\/\/i0.wp.com\/youngitconsulting.de\/staging\/2187\/wp-content\/uploads\/2023\/06\/gp3.png?resize=300%2C216&amp;ssl=1 300w, https:\/\/i0.wp.com\/youngitconsulting.de\/staging\/2187\/wp-content\/uploads\/2023\/06\/gp3.png?resize=1024%2C736&amp;ssl=1 1024w, https:\/\/i0.wp.com\/youngitconsulting.de\/staging\/2187\/wp-content\/uploads\/2023\/06\/gp3.png?resize=768%2C552&amp;ssl=1 768w\" sizes=\"(max-width: 1000px) 100vw, 1000px\" \/><\/p>\n<div id=\"container_L70HhxPuKn7\" class=\"container \">\n<div id=\"container_l6Jvy-9FPG4\" class=\"container \" role=\"heading\" aria-level=\"2\">\n<div id=\"container_h1ZwSGtlf-3\" class=\"container \">\n<div class=\"text_wrapper ChapterTitleNone color_ChapterText2\">\n<h1 dir=\"ltr\"><\/h1>\n<h1 id=\"paragraph_aKzeXD6OXa0\" dir=\"ltr\"><span id=\"text_kHr5mGsuwcD\" class=\"\">When to use GraphQL ?<\/span><\/h1>\n<p>&nbsp;<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div id=\"container_0Ra_8KaC4Z8\" class=\"container \">\n<div id=\"container_g6s3G5fOp35\" class=\"container \">\n<div id=\"container_sPOQUEpZ6h5\" class=\"container \">\n<div class=\"text_wrapper TextBodyNone color_TextUnemph\">\n<h4 id=\"paragraph_KN7unboibV7\" dir=\"ltr\"><span id=\"text_jgzpgX5O_d-\" class=\"TextBodyEmph color_TextEmph\">Architectural Scenarios<\/span><\/h4>\n<ul dir=\"ltr\">\n<li id=\"paragraph_u_uy2PMm5C5\" dir=\"ltr\"><span id=\"text_a5ah0d17J41\" class=\"\">While writing code for mobile devices, smartwatches, and IOT Platforms , where bandwidth usage is critical parameter.<\/span><\/li>\n<li id=\"paragraph_h5uy2Pcm5C5\" dir=\"ltr\"><span id=\"text_LGMTvUBSuS2\" class=\"\">Application requirements where nested data needs to be fetched in a single call ( For example a case when we need USER details then PRODUCTS details bought by USER ).<\/span><\/li>\n<li id=\"paragraph_Inty2Psl5C5\" dir=\"ltr\"><span id=\"text_-dTQD8IbEV_\" class=\"\">A composite pattern, where an application retrieves data from multiple, different storage APIs.<\/span><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h1>How to use GraphQL in Liferay ?<\/h1>\n<\/div>\n<p id=\"paragraph_kE0eCupoIV6\" dir=\"ltr\"><span id=\"text_u2vp9XyTEl_\" class=\"\">Liferay by default comes with <\/span><strong><span id=\"text_h9vp9XCUEl_\" class=\"TextBodyEmph color_TextEmph\">Out of the box<\/span><\/strong><span id=\"text_Irup9XSTEl_\" class=\"\"> List of APIs which you can access<\/span><\/p>\n<ol dir=\"ltr\">\n<li id=\"paragraph_gihC0-1LAI4\" dir=\"ltr\"><span id=\"text_MgJczQnOXh8\" class=\"\">First Login as Admin<\/span><\/li>\n<li id=\"paragraph_TphC0-HLAI4\" dir=\"ltr\"><span id=\"text_lZ7xW2jIzK8\" class=\"\">Use the same browser to call the following URL<\/span><\/li>\n<\/ol>\n<h5 id=\"paragraph_KS0eCuJpIV6\" dir=\"ltr\"><span id=\"text_PlYVxW8_eC_\" class=\"TextBodyEmph color_TextEmph\">http:\/\/[host]:[port]\/o\/api<\/span><\/h5>\n<p id=\"paragraph_7Z0eCuZpIV6\" dir=\"ltr\"><span id=\"text_U5ezGdmdFs0\" class=\"\">For example, if you\u2019re running Liferay DXP locally on port 8080, the URL for discovering the GraphQL API is<\/span><\/p>\n<\/div>\n<\/div>\n<div id=\"container_g6s3G5fOp35\" class=\"container \">\n<div id=\"container_sPOQUEpZ6h5\" class=\"container \">\n<p id=\"paragraph_Wt0eCuJqIV6\" dir=\"ltr\"><span id=\"text_RhRXkLsDn6C\" class=\"\">3) Once you are on this page you can click GraphQL link on the top Right of the page<\/span><\/p>\n<\/div>\n<h1 dir=\"ltr\">Example to Read<\/h1>\n<\/div>\n<\/div>\n<p id=\"paragraph_k44BcvIO7fB\" dir=\"ltr\"><span id=\"text_CAWQ-zFrAHA\" class=\"TextBodyNone\">Here are steps to read all the blog content through GraphQL API<\/span><\/p>\n<ol dir=\"ltr\">\n<li id=\"paragraph_RATrmYgZEb7\" dir=\"ltr\"><span id=\"text_VkE645-lY5_\" class=\"TextBodyNone\">Login as Admin<\/span><\/li>\n<li id=\"paragraph_e3TrmYQZEb7\" dir=\"ltr\"><span id=\"text_uzYEBT8XgI5\" class=\"TextBodyNone\">Hit the URL http:\/\/localhost:8080\/o\/api<\/span><\/li>\n<li id=\"paragraph_rySrmYAZEb7\" dir=\"ltr\"><span id=\"text_2niTAFLina6\" class=\"TextBodyNone\">Go to Graphql Tab<\/span><\/li>\n<li id=\"paragraph_2sSrmYwYEb7\" dir=\"ltr\"><span id=\"text_x0GCDsmfZO_\" class=\"TextBodyNone\">write the Following query<\/span><\/li>\n<\/ol>\n<p id=\"paragraph_7P4Bcv2P7fB\" dir=\"ltr\" style=\"padding-left: 40px;\"><strong><span id=\"text_kNXipvTIl15\" class=\"TextBodySpecialEmph color_TextEmph\">query<\/span><\/strong><\/p>\n<p dir=\"ltr\" style=\"padding-left: 40px;\"><strong><span id=\"text_kNXipvTIl15\" class=\"TextBodySpecialEmph color_TextEmph\">{<\/span><\/strong><\/p>\n<p id=\"paragraph_wV4BcvIP7fB\" dir=\"ltr\" style=\"padding-left: 40px;\"><strong><span id=\"text_hQ_UbApAus4\" class=\"TextBodySpecialEmph color_TextEmph\">blogPostings(filter:&#8221;&#8221;,page:1,pageSize:10,search:&#8221;&#8221;,siteKey:&#8221;47311&#8243;,sort:&#8221;&#8221;)<\/span><\/strong><\/p>\n<p id=\"paragraph_jc4BcvYP7fB\" dir=\"ltr\" style=\"padding-left: 80px;\"><strong><span id=\"text_TpZ_PjYKav6\" class=\"TextBodySpecialEmph color_TextEmph\"> {<\/span><\/strong><\/p>\n<p id=\"paragraph_Wj4BcvoP7fB\" dir=\"ltr\" style=\"padding-left: 80px;\"><strong><span id=\"text_rr1FU4NDsf1\" class=\"TextBodySpecialEmph color_TextEmph\">page<\/span><\/strong><\/p>\n<p id=\"paragraph_Jq4Bcv2Q7fB\" dir=\"ltr\" style=\"padding-left: 80px;\"><strong><span id=\"text_Rwt5xfiSB_4\" class=\"TextBodySpecialEmph color_TextEmph\"> items<\/span><\/strong><\/p>\n<p id=\"paragraph_6x4BcvIQ7fB\" dir=\"ltr\" style=\"padding-left: 120px;\"><strong><span id=\"text_NmI1PAFaJO3\" class=\"TextBodySpecialEmph color_TextEmph\"> {<\/span><\/strong><\/p>\n<p id=\"paragraph_v15BcvYQ7fB\" dir=\"ltr\" style=\"padding-left: 120px;\"><strong><span id=\"text_LI1D02Nboy0\" class=\"TextBodySpecialEmph color_TextEmph\"> id<\/span><\/strong><\/p>\n<p id=\"paragraph_7MA-FGlxWWD\" dir=\"ltr\" style=\"padding-left: 120px;\"><strong><span id=\"text_ePyzTH_BHt3\" class=\"TextBodySpecialEmph color_TextEmph\"> headline<\/span><\/strong><\/p>\n<p id=\"paragraph_KFA-FGVxWWD\" dir=\"ltr\" style=\"padding-left: 120px;\"><strong><span id=\"text_x3LgHXT3GM-\" class=\"TextBodySpecialEmph color_TextEmph\"> creator<\/span><\/strong><\/p>\n<p id=\"paragraph_X8A-FGFxWWD\" dir=\"ltr\" style=\"padding-left: 160px;\"><strong><span id=\"text_kHeylcQihf1\" class=\"TextBodySpecialEmph color_TextEmph\">{<\/span><\/strong><\/p>\n<p id=\"paragraph_k1A-FG-xWWD\" dir=\"ltr\" style=\"padding-left: 160px;\"><strong><span id=\"text_X80VrHZUTy0\" class=\"TextBodySpecialEmph color_TextEmph\">name<\/span><\/strong><\/p>\n<p id=\"paragraph_JnA-FGlyWWD\" dir=\"ltr\" style=\"padding-left: 160px;\"><strong><span id=\"text_xbrgZTJQMj9\" class=\"TextBodySpecialEmph color_TextEmph\"> }<\/span><\/strong><\/p>\n<p id=\"paragraph_WgA-FGVyWWD\" dir=\"ltr\" style=\"padding-left: 120px;\"><strong><span id=\"text_Z5XvQVse_72\" class=\"TextBodySpecialEmph color_TextEmph\">}<\/span><\/strong><\/p>\n<p id=\"paragraph_jZA-FGFyWWD\" dir=\"ltr\" style=\"padding-left: 80px;\"><strong><span id=\"text_9we2JOYCyP1\" class=\"TextBodySpecialEmph color_TextEmph\">}<\/span><\/strong><\/p>\n<p id=\"paragraph_wSA-FG-yWWD\" dir=\"ltr\" style=\"padding-left: 40px;\"><strong><span id=\"text_CDenwvzAOm6\" class=\"TextBodySpecialEmph color_TextEmph\">}<\/span><\/strong><\/p>\n<p id=\"paragraph_i5B-FGVzWWD\" dir=\"ltr\"><span id=\"text_jM4b1Kh7gk_\" class=\"\">Get the siteKey from Site configuration page of the site as shown in the Image 3 and replace in your query. If you have any blogs in that site then the query will give back some results else you can do the next step (To enter a blog entry via API) First and then retry this query again to get back some results . In my case since I had an entry you can see the API output on the Right hand side in the screenshot .<\/span><\/p>\n<\/div>\n<p dir=\"ltr\"><img data-recalc-dims=\"1\" decoding=\"async\" class=\"aligncenter wp-image-5829\" src=\"https:\/\/i0.wp.com\/youngitconsulting.de\/staging\/2187\/wp-content\/uploads\/2023\/06\/gp5.png?resize=1671%2C958&#038;ssl=1\" alt=\"\" width=\"1671\" height=\"958\" srcset=\"https:\/\/i0.wp.com\/youngitconsulting.de\/staging\/2187\/wp-content\/uploads\/2023\/06\/gp5.png?w=1671&amp;ssl=1 1671w, https:\/\/i0.wp.com\/youngitconsulting.de\/staging\/2187\/wp-content\/uploads\/2023\/06\/gp5.png?resize=300%2C172&amp;ssl=1 300w, https:\/\/i0.wp.com\/youngitconsulting.de\/staging\/2187\/wp-content\/uploads\/2023\/06\/gp5.png?resize=1024%2C587&amp;ssl=1 1024w, https:\/\/i0.wp.com\/youngitconsulting.de\/staging\/2187\/wp-content\/uploads\/2023\/06\/gp5.png?resize=768%2C440&amp;ssl=1 768w, https:\/\/i0.wp.com\/youngitconsulting.de\/staging\/2187\/wp-content\/uploads\/2023\/06\/gp5.png?resize=1536%2C881&amp;ssl=1 1536w\" sizes=\"(max-width: 1000px) 100vw, 1000px\" \/><\/p>\n<p dir=\"ltr\" style=\"text-align: center;\"><strong>Image 1<\/strong><\/p>\n<p dir=\"ltr\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-5830\" src=\"https:\/\/i0.wp.com\/youngitconsulting.de\/staging\/2187\/wp-content\/uploads\/2023\/06\/gp6.png?resize=1466%2C993&#038;ssl=1\" alt=\"\" width=\"1466\" height=\"993\" srcset=\"https:\/\/i0.wp.com\/youngitconsulting.de\/staging\/2187\/wp-content\/uploads\/2023\/06\/gp6.png?w=1467&amp;ssl=1 1467w, https:\/\/i0.wp.com\/youngitconsulting.de\/staging\/2187\/wp-content\/uploads\/2023\/06\/gp6.png?resize=300%2C203&amp;ssl=1 300w, https:\/\/i0.wp.com\/youngitconsulting.de\/staging\/2187\/wp-content\/uploads\/2023\/06\/gp6.png?resize=1024%2C694&amp;ssl=1 1024w, https:\/\/i0.wp.com\/youngitconsulting.de\/staging\/2187\/wp-content\/uploads\/2023\/06\/gp6.png?resize=768%2C520&amp;ssl=1 768w\" sizes=\"(max-width: 1000px) 100vw, 1000px\" \/><\/p>\n<p dir=\"ltr\" style=\"text-align: center;\"><strong>Image 2<\/strong><\/p>\n<\/div>\n<\/div>\n<div id=\"container_y9gX91Dhm0A\" class=\"container \">\n<div id=\"container_s7CD1AAafu2\" class=\"container \" role=\"heading\" aria-level=\"2\">\n<div id=\"container_Amq0wHd-3-B\" class=\"container \">\n<div class=\"text_wrapper ChapterTitleNone color_ChapterText2\">\n<h1 id=\"paragraph_Np-XZGHTgo1\" dir=\"ltr\" style=\"text-align: center;\"><span id=\"text_OWZRPb2fAF_\" class=\"\">Example to Mutate (Write)<\/span><\/h1>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div id=\"container_VB3SA_8RuA-\" class=\"container \">\n<div id=\"container_f0tDiPH7CsA\" class=\"container \">\n<div id=\"container_PCKtQuSt2P-\" class=\"container \">\n<div class=\"text_wrapper TextBodyNone color_TextUnemph\">\n<p id=\"paragraph_y20cBNzpln6\" dir=\"ltr\"><span id=\"text_hLCeZbGFvg2\" class=\"\">Here are steps to read all the blog content through GraphQL API<\/span><\/p>\n<ol dir=\"ltr\">\n<li id=\"paragraph_rKSmsMVp669\" dir=\"ltr\"><span id=\"text_tEuRLwqU4b_\" class=\"\">Login as Admin<\/span><\/li>\n<li id=\"paragraph_2ESmsMFp669\" dir=\"ltr\"><span id=\"text_X5KdVsEbtA8\" class=\"\">Hit the URL http:\/\/localhost:8080\/o\/api<\/span><\/li>\n<li id=\"paragraph_RYSmsM-q669\" dir=\"ltr\"><span id=\"text_99yGxMhVZiC\" class=\"\">Go to Graphql Tab<\/span><\/li>\n<li id=\"paragraph_eRSmsMlp669\" dir=\"ltr\"><span id=\"text_LE3PsAYVxrA\" class=\"\">write the Following query<\/span><\/li>\n<\/ol>\n<p id=\"paragraph_9y-cBNjpln6\" dir=\"ltr\"><em><strong><span id=\"text_J3NSYSL0ucA\" class=\"TextBodySpecialEmph color_TextEmph\">mutation CreateBlog($blog: InputBlogPosting)<\/span><\/strong><\/em><\/p>\n<p dir=\"ltr\" style=\"padding-left: 40px;\"><em><strong><span id=\"text_J3NSYSL0ucA\" class=\"TextBodySpecialEmph color_TextEmph\">{<\/span><\/strong><\/em><\/p>\n<p id=\"paragraph_8U0cBNzqln6\" dir=\"ltr\" style=\"padding-left: 40px;\"><em><strong><span id=\"text_Og_qLgVtfNA\" class=\"TextBodySpecialEmph color_TextEmph\">createSiteBlogPosting(blogPosting: $blog, siteKey: &#8220;47311&#8221; )<\/span><\/strong><\/em><\/p>\n<p id=\"paragraph_xa0cBNDrln6\" dir=\"ltr\" style=\"padding-left: 80px;\"><em><strong><span id=\"text_tC95kbzs1O-\" class=\"TextBodySpecialEmph color_TextEmph\">{<\/span><\/strong><\/em><\/p>\n<p id=\"paragraph_YG0cBNTqln6\" dir=\"ltr\" style=\"padding-left: 80px;\"><em><strong><span id=\"text_XY9lV6P38ZB\" class=\"TextBodySpecialEmph color_TextEmph\"> headline<\/span><\/strong><\/em><\/p>\n<p id=\"paragraph_LN0cBNjqln6\" dir=\"ltr\" style=\"padding-left: 80px;\"><em><strong><span id=\"text_TuUMBFKUW5_\" class=\"TextBodySpecialEmph color_TextEmph\"> articleBody<\/span><\/strong><\/em><\/p>\n<p id=\"paragraph_aC-cBNznln6\" dir=\"ltr\" style=\"padding-left: 80px;\"><em><strong><span id=\"text_ZnWeuQseM1A\" class=\"TextBodySpecialEmph color_TextEmph\"> id<\/span><\/strong><\/em><\/p>\n<p id=\"paragraph_NJ-cBNDoln6\" dir=\"ltr\" style=\"padding-left: 80px;\"><em><strong><span id=\"text_sdWGQMjpGW2\" class=\"TextBodySpecialEmph color_TextEmph\"> friendlyUrlPath <\/span><\/strong><\/em><\/p>\n<p dir=\"ltr\" style=\"padding-left: 80px;\"><em><strong><span id=\"text_sdWGQMjpGW2\" class=\"TextBodySpecialEmph color_TextEmph\">}<\/span><\/strong><\/em><\/p>\n<p id=\"paragraph_nrk4bLsOKw-\" dir=\"ltr\" style=\"padding-left: 40px;\"><em><strong><span id=\"text_-aWDciAFAB9\" class=\"TextBodySpecialEmph color_TextEmph\"> }<\/span><\/strong><\/em><\/p>\n<p id=\"paragraph__lk4bLcOKw-\" dir=\"ltr\"><em><strong><span id=\"text_CFZT6s4YBB2\" class=\"TextBodySpecialEmph color_TextEmph\"> }<\/span><\/strong><\/em><\/p>\n<p id=\"paragraph_ayk4bL6PKw-\" dir=\"ltr\"><span id=\"text_Lb8z8mb-Ck_\" class=\"\">In the Query Variables you can enter the entry like following<\/span><\/p>\n<p id=\"paragraph_AAl4bLcPKw-\" dir=\"ltr\"><em><strong><span id=\"text_lX-_NiUgx9-\" class=\"TextBodySpecialEmph color_TextEmph\">{<\/span><\/strong><\/em><\/p>\n<p id=\"paragraph_ZUl4bLMQKw-\" dir=\"ltr\"><em><strong><span id=\"text_L_As7YU2DkD\" class=\"TextBodySpecialEmph color_TextEmph\">&#8220;blog&#8221;:<\/span><\/strong><\/em><\/p>\n<p id=\"paragraph_mNl4bL6QKw-\" dir=\"ltr\"><em><strong><span id=\"text_G073ueQZaGC\" class=\"TextBodySpecialEmph color_TextEmph\"> {<\/span><\/strong><\/em><\/p>\n<p id=\"paragraph_9il4bLsQKw-\" dir=\"ltr\"><em><strong><span id=\"text_uN4rAUDOvd5\" class=\"TextBodySpecialEmph color_TextEmph\"> &#8220;articleBody&#8221;: &#8220;Contact us for EU based Liferay Consultants at Liferayconsulting.com !&#8221;,<\/span><\/strong><\/em><\/p>\n<p id=\"paragraph_Mbl4bLcQKw-\" dir=\"ltr\"><em><strong><span id=\"text_j5pd4LPCBtB\" class=\"TextBodySpecialEmph color_TextEmph\"> &#8220;headline&#8221;: &#8220;Liferayconsulting.com&#8221;<\/span><\/strong><\/em><\/p>\n<p id=\"paragraph_s2h2bLMSAw-\" dir=\"ltr\"><em><strong><span id=\"text_xojTFpsIBE1\" class=\"TextBodySpecialEmph color_TextEmph\"> }<\/span><\/strong><\/em><\/p>\n<p id=\"paragraph_f9h2bLcSAw-\" dir=\"ltr\"><em><strong><span id=\"text_1-C7huZ8hVB\" class=\"TextBodySpecialEmph color_TextEmph\">}<\/span><\/strong><\/em><\/p>\n<p id=\"paragraph_SGh2bLsSAw-\" dir=\"ltr\"><span id=\"text_crIUVzPwlg9\" class=\"\">now run the query and the API call to write or mutate is done . You can now rerun the read query to find your entry appearing there .<\/span><\/p>\n<p dir=\"ltr\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-5945\" src=\"https:\/\/i0.wp.com\/youngitconsulting.de\/staging\/2187\/wp-content\/uploads\/2023\/06\/OM1.png?resize=300%2C205&#038;ssl=1\" alt=\"\" width=\"300\" height=\"205\" srcset=\"https:\/\/i0.wp.com\/youngitconsulting.de\/staging\/2187\/wp-content\/uploads\/2023\/06\/OM1.png?resize=300%2C205&amp;ssl=1 300w, https:\/\/i0.wp.com\/youngitconsulting.de\/staging\/2187\/wp-content\/uploads\/2023\/06\/OM1.png?resize=1024%2C698&amp;ssl=1 1024w, https:\/\/i0.wp.com\/youngitconsulting.de\/staging\/2187\/wp-content\/uploads\/2023\/06\/OM1.png?resize=768%2C524&amp;ssl=1 768w, https:\/\/i0.wp.com\/youngitconsulting.de\/staging\/2187\/wp-content\/uploads\/2023\/06\/OM1.png?w=1459&amp;ssl=1 1459w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/p>\n<\/div>\n<p dir=\"ltr\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-5946\" src=\"https:\/\/i0.wp.com\/youngitconsulting.de\/staging\/2187\/wp-content\/uploads\/2023\/06\/OM2.png?resize=300%2C203&#038;ssl=1\" alt=\"\" width=\"300\" height=\"203\" srcset=\"https:\/\/i0.wp.com\/youngitconsulting.de\/staging\/2187\/wp-content\/uploads\/2023\/06\/OM2.png?resize=300%2C203&amp;ssl=1 300w, https:\/\/i0.wp.com\/youngitconsulting.de\/staging\/2187\/wp-content\/uploads\/2023\/06\/OM2.png?resize=1024%2C693&amp;ssl=1 1024w, https:\/\/i0.wp.com\/youngitconsulting.de\/staging\/2187\/wp-content\/uploads\/2023\/06\/OM2.png?resize=768%2C520&amp;ssl=1 768w, https:\/\/i0.wp.com\/youngitconsulting.de\/staging\/2187\/wp-content\/uploads\/2023\/06\/OM2.png?w=1462&amp;ssl=1 1462w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/p>\n<\/div>\n<h1 dir=\"ltr\" style=\"text-align: center;\"><a id=\"text_8mBovBgAKEB\" class=\"\" href=\"https:\/\/miro.com\/app\/board\/uXjVPAmQwgI=\/?share_link_id=519074997360\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Diagram Links<\/a><\/h1>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; Checkout the flow diagram here\u00a0 What is GraphQL ? GraphQL is basically a query language to read or mutate data in API . In simple words its a way to call API for read and write purpose using query like syntax . Using GraphQL feels like you are querying an API service instead of a database . This was developed by Facebook . Challenges with REST REST API calls has lot of advantages which is well known to developers but at the same time there are few drawbacks which REST API calls doesn&#8217;t address . Lets talk about few of them Over fetching: This is when the API endpoint provides way more information than required by the client. Under fetching: This is when the API endpoint doesn\u2019t provide all of the required information. So, the client has to make multiple requests (API Calls) to get everything the application needs. When to use GraphQL ? &nbsp; Architectural Scenarios While writing code for mobile devices, smartwatches, and IOT Platforms , where bandwidth usage is critical parameter. Application requirements where nested data needs to be fetched in a single call ( For example a case when we need USER details then PRODUCTS details bought by USER ). A composite pattern, where an application retrieves data from multiple, different storage APIs. &nbsp; How to use GraphQL in Liferay ? Liferay by default comes with Out of the box List of APIs which you can access First Login as Admin Use the same browser to call the following URL http:\/\/[host]:[port]\/o\/api For example, if you\u2019re running Liferay DXP locally on port 8080, the URL for discovering the GraphQL API is 3) Once you are on this page you can click GraphQL link on the top Right of the page Example to Read Here are steps to read all the blog content through GraphQL API Login as Admin Hit the URL http:\/\/localhost:8080\/o\/api Go to Graphql Tab write the Following query query { blogPostings(filter:&#8221;&#8221;,page:1,pageSize:10,search:&#8221;&#8221;,siteKey:&#8221;47311&#8243;,sort:&#8221;&#8221;) { page items { id headline creator { name } } } } Get the siteKey from Site configuration page of the site as shown in the Image 3 and replace in your query. If you have any blogs in that site then the query will give back some results else you can do the next step (To enter a blog entry via API) First and then retry this query again to get back some results . In my case since I had an entry you can see the API output on the Right hand side in the screenshot . Image 1 Image 2 Example to Mutate (Write) Here are steps to read all the blog content through GraphQL API Login as Admin Hit the URL http:\/\/localhost:8080\/o\/api Go to Graphql Tab write the Following query mutation CreateBlog($blog: InputBlogPosting) { createSiteBlogPosting(blogPosting: $blog, siteKey: &#8220;47311&#8221; ) { headline articleBody id friendlyUrlPath } } } In the Query Variables you can enter the entry like following { &#8220;blog&#8221;: { &#8220;articleBody&#8221;: &#8220;Contact us for EU based Liferay Consultants at Liferayconsulting.com !&#8221;, &#8220;headline&#8221;: &#8220;Liferayconsulting.com&#8221; } } now run the query and the API call to write or mutate is done . You can now rerun the read query to find your entry appearing there . Diagram Links<\/p>\n","protected":false},"author":1,"featured_media":5814,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"site-sidebar-layout":"default","site-content-layout":"default","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"default","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"fifu_image_url":"","fifu_image_alt":"","_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[117],"tags":[62,64,67,65,25,30,40,63,66,60],"class_list":["post-5813","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ui-ux","tag-business-portal","tag-drupal","tag-java-portal","tag-joomla","tag-liferay","tag-liferay-dxp","tag-liferay-dxp-7-4","tag-liferay-portal","tag-web-development","tag-wordpress"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>GraphQL in Liferay DXP -<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/youngitconsulting.de\/staging\/2187\/graphql-in-liferay-dxp\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"GraphQL in Liferay DXP -\" \/>\n<meta property=\"og:description\" content=\"&nbsp; Checkout the flow diagram here\u00a0 What is GraphQL ? GraphQL is basically a query language to read or mutate data in API . In simple words its a way to call API for read and write purpose using query like syntax . Using GraphQL feels like you are querying an API service instead of a database . This was developed by Facebook . Challenges with REST REST API calls has lot of advantages which is well known to developers but at the same time there are few drawbacks which REST API calls doesn&#8217;t address . Lets talk about few of them Over fetching: This is when the API endpoint provides way more information than required by the client. Under fetching: This is when the API endpoint doesn\u2019t provide all of the required information. So, the client has to make multiple requests (API Calls) to get everything the application needs. When to use GraphQL ? &nbsp; Architectural Scenarios While writing code for mobile devices, smartwatches, and IOT Platforms , where bandwidth usage is critical parameter. Application requirements where nested data needs to be fetched in a single call ( For example a case when we need USER details then PRODUCTS details bought by USER ). A composite pattern, where an application retrieves data from multiple, different storage APIs. &nbsp; How to use GraphQL in Liferay ? Liferay by default comes with Out of the box List of APIs which you can access First Login as Admin Use the same browser to call the following URL http:\/\/[host]:[port]\/o\/api For example, if you\u2019re running Liferay DXP locally on port 8080, the URL for discovering the GraphQL API is 3) Once you are on this page you can click GraphQL link on the top Right of the page Example to Read Here are steps to read all the blog content through GraphQL API Login as Admin Hit the URL http:\/\/localhost:8080\/o\/api Go to Graphql Tab write the Following query query { blogPostings(filter:&#8221;&#8221;,page:1,pageSize:10,search:&#8221;&#8221;,siteKey:&#8221;47311&#8243;,sort:&#8221;&#8221;) { page items { id headline creator { name } } } } Get the siteKey from Site configuration page of the site as shown in the Image 3 and replace in your query. If you have any blogs in that site then the query will give back some results else you can do the next step (To enter a blog entry via API) First and then retry this query again to get back some results . In my case since I had an entry you can see the API output on the Right hand side in the screenshot . Image 1 Image 2 Example to Mutate (Write) Here are steps to read all the blog content through GraphQL API Login as Admin Hit the URL http:\/\/localhost:8080\/o\/api Go to Graphql Tab write the Following query mutation CreateBlog($blog: InputBlogPosting) { createSiteBlogPosting(blogPosting: $blog, siteKey: &#8220;47311&#8221; ) { headline articleBody id friendlyUrlPath } } } In the Query Variables you can enter the entry like following { &#8220;blog&#8221;: { &#8220;articleBody&#8221;: &#8220;Contact us for EU based Liferay Consultants at Liferayconsulting.com !&#8221;, &#8220;headline&#8221;: &#8220;Liferayconsulting.com&#8221; } } now run the query and the API call to write or mutate is done . You can now rerun the read query to find your entry appearing there . Diagram Links\" \/>\n<meta property=\"og:url\" content=\"https:\/\/youngitconsulting.de\/staging\/2187\/graphql-in-liferay-dxp\/\" \/>\n<meta property=\"article:published_time\" content=\"2023-06-25T10:23:40+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-07-08T07:14:12+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/youngitconsulting.de\/staging\/2187\/wp-content\/uploads\/2023\/06\/gp1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1012\" \/>\n\t<meta property=\"og:image:height\" content=\"716\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"YoungIT\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"YoungIT\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/youngitconsulting.de\\\/staging\\\/2187\\\/graphql-in-liferay-dxp\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/youngitconsulting.de\\\/staging\\\/2187\\\/graphql-in-liferay-dxp\\\/\"},\"author\":{\"name\":\"YoungIT\",\"@id\":\"http:\\\/\\\/izg.tnd.mybluehost.me\\\/#\\\/schema\\\/person\\\/b46ed295bea3af3f3a4c263e64c82686\"},\"headline\":\"GraphQL in Liferay DXP\",\"datePublished\":\"2023-06-25T10:23:40+00:00\",\"dateModified\":\"2023-07-08T07:14:12+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/youngitconsulting.de\\\/staging\\\/2187\\\/graphql-in-liferay-dxp\\\/\"},\"wordCount\":526,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/youngitconsulting.de\\\/staging\\\/2187\\\/graphql-in-liferay-dxp\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/youngitconsulting.de\\\/staging\\\/2187\\\/wp-content\\\/uploads\\\/2023\\\/06\\\/gp1.png?fit=1012%2C716&ssl=1\",\"keywords\":[\"Business portal\",\"Drupal\",\"Java portal\",\"Joomla\",\"Liferay\",\"Liferay DXP\",\"Liferay DXP 7.4\",\"Liferay portal\",\"web development\",\"Wordpress\"],\"articleSection\":[\"UI\\\/UX\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/youngitconsulting.de\\\/staging\\\/2187\\\/graphql-in-liferay-dxp\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/youngitconsulting.de\\\/staging\\\/2187\\\/graphql-in-liferay-dxp\\\/\",\"url\":\"https:\\\/\\\/youngitconsulting.de\\\/staging\\\/2187\\\/graphql-in-liferay-dxp\\\/\",\"name\":\"GraphQL in Liferay DXP -\",\"isPartOf\":{\"@id\":\"http:\\\/\\\/izg.tnd.mybluehost.me\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/youngitconsulting.de\\\/staging\\\/2187\\\/graphql-in-liferay-dxp\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/youngitconsulting.de\\\/staging\\\/2187\\\/graphql-in-liferay-dxp\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/youngitconsulting.de\\\/staging\\\/2187\\\/wp-content\\\/uploads\\\/2023\\\/06\\\/gp1.png?fit=1012%2C716&ssl=1\",\"datePublished\":\"2023-06-25T10:23:40+00:00\",\"dateModified\":\"2023-07-08T07:14:12+00:00\",\"author\":{\"@id\":\"http:\\\/\\\/izg.tnd.mybluehost.me\\\/#\\\/schema\\\/person\\\/b46ed295bea3af3f3a4c263e64c82686\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/youngitconsulting.de\\\/staging\\\/2187\\\/graphql-in-liferay-dxp\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/youngitconsulting.de\\\/staging\\\/2187\\\/graphql-in-liferay-dxp\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/youngitconsulting.de\\\/staging\\\/2187\\\/graphql-in-liferay-dxp\\\/#primaryimage\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/youngitconsulting.de\\\/staging\\\/2187\\\/wp-content\\\/uploads\\\/2023\\\/06\\\/gp1.png?fit=1012%2C716&ssl=1\",\"contentUrl\":\"https:\\\/\\\/i0.wp.com\\\/youngitconsulting.de\\\/staging\\\/2187\\\/wp-content\\\/uploads\\\/2023\\\/06\\\/gp1.png?fit=1012%2C716&ssl=1\",\"width\":1012,\"height\":716},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/youngitconsulting.de\\\/staging\\\/2187\\\/graphql-in-liferay-dxp\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/youngitconsulting.de\\\/staging\\\/2187\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"GraphQL in Liferay DXP\"}]},{\"@type\":\"WebSite\",\"@id\":\"http:\\\/\\\/izg.tnd.mybluehost.me\\\/#website\",\"url\":\"http:\\\/\\\/izg.tnd.mybluehost.me\\\/\",\"name\":\"\",\"description\":\"IT Consulting , Liferay DXP , Salesforce , Java Consulting\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\\\/\\\/izg.tnd.mybluehost.me\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"http:\\\/\\\/izg.tnd.mybluehost.me\\\/#\\\/schema\\\/person\\\/b46ed295bea3af3f3a4c263e64c82686\",\"name\":\"YoungIT\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/45f6160db01519229a2463b514b42085e51d1816913b18ffa5181a439cc7999c?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/45f6160db01519229a2463b514b42085e51d1816913b18ffa5181a439cc7999c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/45f6160db01519229a2463b514b42085e51d1816913b18ffa5181a439cc7999c?s=96&d=mm&r=g\",\"caption\":\"YoungIT\"},\"sameAs\":[\"http:\\\/\\\/box2537\\\/cgi\\\/addon_GT.cgi?s=GT::WP::Install::EIG+%28izgtndmy%29+-+127.0.0.1+%5Bnocaller%5D\"],\"url\":\"https:\\\/\\\/youngitconsulting.de\\\/staging\\\/2187\\\/author\\\/izgtndmy\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"GraphQL in Liferay DXP -","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/youngitconsulting.de\/staging\/2187\/graphql-in-liferay-dxp\/","og_locale":"en_US","og_type":"article","og_title":"GraphQL in Liferay DXP -","og_description":"&nbsp; Checkout the flow diagram here\u00a0 What is GraphQL ? GraphQL is basically a query language to read or mutate data in API . In simple words its a way to call API for read and write purpose using query like syntax . Using GraphQL feels like you are querying an API service instead of a database . This was developed by Facebook . Challenges with REST REST API calls has lot of advantages which is well known to developers but at the same time there are few drawbacks which REST API calls doesn&#8217;t address . Lets talk about few of them Over fetching: This is when the API endpoint provides way more information than required by the client. Under fetching: This is when the API endpoint doesn\u2019t provide all of the required information. So, the client has to make multiple requests (API Calls) to get everything the application needs. When to use GraphQL ? &nbsp; Architectural Scenarios While writing code for mobile devices, smartwatches, and IOT Platforms , where bandwidth usage is critical parameter. Application requirements where nested data needs to be fetched in a single call ( For example a case when we need USER details then PRODUCTS details bought by USER ). A composite pattern, where an application retrieves data from multiple, different storage APIs. &nbsp; How to use GraphQL in Liferay ? Liferay by default comes with Out of the box List of APIs which you can access First Login as Admin Use the same browser to call the following URL http:\/\/[host]:[port]\/o\/api For example, if you\u2019re running Liferay DXP locally on port 8080, the URL for discovering the GraphQL API is 3) Once you are on this page you can click GraphQL link on the top Right of the page Example to Read Here are steps to read all the blog content through GraphQL API Login as Admin Hit the URL http:\/\/localhost:8080\/o\/api Go to Graphql Tab write the Following query query { blogPostings(filter:&#8221;&#8221;,page:1,pageSize:10,search:&#8221;&#8221;,siteKey:&#8221;47311&#8243;,sort:&#8221;&#8221;) { page items { id headline creator { name } } } } Get the siteKey from Site configuration page of the site as shown in the Image 3 and replace in your query. If you have any blogs in that site then the query will give back some results else you can do the next step (To enter a blog entry via API) First and then retry this query again to get back some results . In my case since I had an entry you can see the API output on the Right hand side in the screenshot . Image 1 Image 2 Example to Mutate (Write) Here are steps to read all the blog content through GraphQL API Login as Admin Hit the URL http:\/\/localhost:8080\/o\/api Go to Graphql Tab write the Following query mutation CreateBlog($blog: InputBlogPosting) { createSiteBlogPosting(blogPosting: $blog, siteKey: &#8220;47311&#8221; ) { headline articleBody id friendlyUrlPath } } } In the Query Variables you can enter the entry like following { &#8220;blog&#8221;: { &#8220;articleBody&#8221;: &#8220;Contact us for EU based Liferay Consultants at Liferayconsulting.com !&#8221;, &#8220;headline&#8221;: &#8220;Liferayconsulting.com&#8221; } } now run the query and the API call to write or mutate is done . You can now rerun the read query to find your entry appearing there . Diagram Links","og_url":"https:\/\/youngitconsulting.de\/staging\/2187\/graphql-in-liferay-dxp\/","article_published_time":"2023-06-25T10:23:40+00:00","article_modified_time":"2023-07-08T07:14:12+00:00","og_image":[{"width":1012,"height":716,"url":"https:\/\/youngitconsulting.de\/staging\/2187\/wp-content\/uploads\/2023\/06\/gp1.png","type":"image\/png"}],"author":"YoungIT","twitter_card":"summary_large_image","twitter_misc":{"Written by":"YoungIT","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/youngitconsulting.de\/staging\/2187\/graphql-in-liferay-dxp\/#article","isPartOf":{"@id":"https:\/\/youngitconsulting.de\/staging\/2187\/graphql-in-liferay-dxp\/"},"author":{"name":"YoungIT","@id":"http:\/\/izg.tnd.mybluehost.me\/#\/schema\/person\/b46ed295bea3af3f3a4c263e64c82686"},"headline":"GraphQL in Liferay DXP","datePublished":"2023-06-25T10:23:40+00:00","dateModified":"2023-07-08T07:14:12+00:00","mainEntityOfPage":{"@id":"https:\/\/youngitconsulting.de\/staging\/2187\/graphql-in-liferay-dxp\/"},"wordCount":526,"commentCount":0,"image":{"@id":"https:\/\/youngitconsulting.de\/staging\/2187\/graphql-in-liferay-dxp\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/youngitconsulting.de\/staging\/2187\/wp-content\/uploads\/2023\/06\/gp1.png?fit=1012%2C716&ssl=1","keywords":["Business portal","Drupal","Java portal","Joomla","Liferay","Liferay DXP","Liferay DXP 7.4","Liferay portal","web development","Wordpress"],"articleSection":["UI\/UX"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/youngitconsulting.de\/staging\/2187\/graphql-in-liferay-dxp\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/youngitconsulting.de\/staging\/2187\/graphql-in-liferay-dxp\/","url":"https:\/\/youngitconsulting.de\/staging\/2187\/graphql-in-liferay-dxp\/","name":"GraphQL in Liferay DXP -","isPartOf":{"@id":"http:\/\/izg.tnd.mybluehost.me\/#website"},"primaryImageOfPage":{"@id":"https:\/\/youngitconsulting.de\/staging\/2187\/graphql-in-liferay-dxp\/#primaryimage"},"image":{"@id":"https:\/\/youngitconsulting.de\/staging\/2187\/graphql-in-liferay-dxp\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/youngitconsulting.de\/staging\/2187\/wp-content\/uploads\/2023\/06\/gp1.png?fit=1012%2C716&ssl=1","datePublished":"2023-06-25T10:23:40+00:00","dateModified":"2023-07-08T07:14:12+00:00","author":{"@id":"http:\/\/izg.tnd.mybluehost.me\/#\/schema\/person\/b46ed295bea3af3f3a4c263e64c82686"},"breadcrumb":{"@id":"https:\/\/youngitconsulting.de\/staging\/2187\/graphql-in-liferay-dxp\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/youngitconsulting.de\/staging\/2187\/graphql-in-liferay-dxp\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/youngitconsulting.de\/staging\/2187\/graphql-in-liferay-dxp\/#primaryimage","url":"https:\/\/i0.wp.com\/youngitconsulting.de\/staging\/2187\/wp-content\/uploads\/2023\/06\/gp1.png?fit=1012%2C716&ssl=1","contentUrl":"https:\/\/i0.wp.com\/youngitconsulting.de\/staging\/2187\/wp-content\/uploads\/2023\/06\/gp1.png?fit=1012%2C716&ssl=1","width":1012,"height":716},{"@type":"BreadcrumbList","@id":"https:\/\/youngitconsulting.de\/staging\/2187\/graphql-in-liferay-dxp\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/youngitconsulting.de\/staging\/2187\/"},{"@type":"ListItem","position":2,"name":"GraphQL in Liferay DXP"}]},{"@type":"WebSite","@id":"http:\/\/izg.tnd.mybluehost.me\/#website","url":"http:\/\/izg.tnd.mybluehost.me\/","name":"","description":"IT Consulting , Liferay DXP , Salesforce , Java Consulting","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/izg.tnd.mybluehost.me\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"http:\/\/izg.tnd.mybluehost.me\/#\/schema\/person\/b46ed295bea3af3f3a4c263e64c82686","name":"YoungIT","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/45f6160db01519229a2463b514b42085e51d1816913b18ffa5181a439cc7999c?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/45f6160db01519229a2463b514b42085e51d1816913b18ffa5181a439cc7999c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/45f6160db01519229a2463b514b42085e51d1816913b18ffa5181a439cc7999c?s=96&d=mm&r=g","caption":"YoungIT"},"sameAs":["http:\/\/box2537\/cgi\/addon_GT.cgi?s=GT::WP::Install::EIG+%28izgtndmy%29+-+127.0.0.1+%5Bnocaller%5D"],"url":"https:\/\/youngitconsulting.de\/staging\/2187\/author\/izgtndmy\/"}]}},"jetpack_featured_media_url":"https:\/\/i0.wp.com\/youngitconsulting.de\/staging\/2187\/wp-content\/uploads\/2023\/06\/gp1.png?fit=1012%2C716&ssl=1","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/youngitconsulting.de\/staging\/2187\/wp-json\/wp\/v2\/posts\/5813","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/youngitconsulting.de\/staging\/2187\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/youngitconsulting.de\/staging\/2187\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/youngitconsulting.de\/staging\/2187\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/youngitconsulting.de\/staging\/2187\/wp-json\/wp\/v2\/comments?post=5813"}],"version-history":[{"count":5,"href":"https:\/\/youngitconsulting.de\/staging\/2187\/wp-json\/wp\/v2\/posts\/5813\/revisions"}],"predecessor-version":[{"id":5948,"href":"https:\/\/youngitconsulting.de\/staging\/2187\/wp-json\/wp\/v2\/posts\/5813\/revisions\/5948"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/youngitconsulting.de\/staging\/2187\/wp-json\/wp\/v2\/media\/5814"}],"wp:attachment":[{"href":"https:\/\/youngitconsulting.de\/staging\/2187\/wp-json\/wp\/v2\/media?parent=5813"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/youngitconsulting.de\/staging\/2187\/wp-json\/wp\/v2\/categories?post=5813"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/youngitconsulting.de\/staging\/2187\/wp-json\/wp\/v2\/tags?post=5813"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}