{"id":22325,"date":"2018-10-30T09:01:43","date_gmt":"2018-10-30T09:01:43","guid":{"rendered":"https:\/\/www.knowband.com\/blog\/?p=22325\/"},"modified":"2022-08-13T12:01:14","modified_gmt":"2022-07-18T12:42:09","slug":"use-graphql-php-2","status":"publish","type":"post","link":"https:\/\/www.knowband.com\/blog\/tutorials\/use-graphql-php-2\/","title":{"rendered":"How to use GraphQL in PHP?"},"content":{"rendered":"<h2 style=\"font-size: 22px; margin-bottom: 15px; text-align: justify;\">Have you heard about GraphQL?<\/h2>\n<p><a href=\"https:\/\/www.knowband.com\/blog\/wp-content\/uploads\/2018\/10\/Main-Banner-graphql-php-2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-817013\" src=\"https:\/\/www.knowband.com\/blog\/wp-content\/uploads\/2018\/10\/Main-Banner-graphql-php-2.png\" alt=\"How to use GraphQL in PHP?\" width=\"760\" height=\"300\" srcset=\"https:\/\/www.knowband.com\/blog\/wp-content\/uploads\/2018\/10\/Main-Banner-graphql-php-2.png 760w, https:\/\/www.knowband.com\/blog\/wp-content\/uploads\/2018\/10\/Main-Banner-graphql-php-2-300x118.png 300w\" sizes=\"auto, (max-width: 760px) 100vw, 760px\" \/><\/a><\/p>\n<p style=\"text-align: justify;\">GraphQL is a modern query language for the API. In another word, we can say it is a modern application layer query language.<\/p>\n<p style=\"text-align: justify;\">With the help of GraphQL, we can fetch data from the API calls and it works on the HTTP as REST. It provides the powerful option to the client so that they ask what they exactly need and it helps in the API growth or evaluation.<\/p>\n<h2 style=\"font-size: 22px; margin-bottom: 15px; text-align: justify;\">Benefits of GraphQL<\/h2>\n<p><a href=\"https:\/\/www.knowband.com\/blog\/wp-content\/uploads\/2018\/10\/Info-Banner-graphql-php-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-817014\" src=\"https:\/\/www.knowband.com\/blog\/wp-content\/uploads\/2018\/10\/Info-Banner-graphql-php-1.png\" alt=\"Benefits of the GraphQl\" width=\"760\" height=\"477\" srcset=\"https:\/\/www.knowband.com\/blog\/wp-content\/uploads\/2018\/10\/Info-Banner-graphql-php-1.png 760w, https:\/\/www.knowband.com\/blog\/wp-content\/uploads\/2018\/10\/Info-Banner-graphql-php-1-300x188.png 300w\" sizes=\"auto, (max-width: 760px) 100vw, 760px\" \/><\/a><\/p>\n<ul>\n<li style=\"text-align: justify;\">It provides only limited data that we actually need. It will never fetch any extra data or less data that you do not need.<\/li>\n<li style=\"text-align: justify;\">It is a powerful open source system.<\/li>\n<li style=\"text-align: justify;\">It gives an option to do the efficient coding. For example, suppose a table 40 column and sometimes we need the data of only 10 column or sometimes 20 etc. To solve this problem we have two option in normal API, either fetch all data in every API call and use any we want or we have to write the number of APIs for the same table so that we can call the efficient API as per requirement. But in GraphQL, we have to write only one API. So line code also gets reduced.<\/li>\n<li style=\"text-align: justify;\">GraphQL API\u2019s are structured in terms of Types and Fields.<\/li>\n<\/ul>\n<h2 style=\"font-size: 22px; margin-bottom: 15px; text-align: justify;\"><a href=\"https:\/\/www.knowband.com\/blog\/wp-content\/uploads\/2018\/10\/info-Banner-graphql-php-3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-817018\" src=\"https:\/\/www.knowband.com\/blog\/wp-content\/uploads\/2018\/10\/info-Banner-graphql-php-3.png\" alt=\"Language Supported by GraphQL\" width=\"760\" height=\"300\" srcset=\"https:\/\/www.knowband.com\/blog\/wp-content\/uploads\/2018\/10\/info-Banner-graphql-php-3.png 760w, https:\/\/www.knowband.com\/blog\/wp-content\/uploads\/2018\/10\/info-Banner-graphql-php-3-300x118.png 300w\" sizes=\"auto, (max-width: 760px) 100vw, 760px\" \/><\/a><\/h2>\n<p style=\"text-align: justify;\">GraphQL has for supports various languages like<\/p>\n<ul>\n<li>C#<\/li>\n<li>.NET<\/li>\n<li>Clojure<\/li>\n<li>Elixir<\/li>\n<li>Erlang<\/li>\n<li>Go<\/li>\n<li>Groovy<\/li>\n<li>Java<\/li>\n<li>JavaScript<\/li>\n<li>PHP<\/li>\n<li>Python<\/li>\n<li>Scala<\/li>\n<li>Ruby<\/li>\n<\/ul>\n<p style=\"text-align: justify;\">In this blog, we will learn about the GraphQL in PHP.<\/p>\n<p style=\"text-align: justify;\">Firstly we should know, in any language to use GraphQL we have to import their library.<\/p>\n<p style=\"text-align: justify;\">In PHP, we can use this library file: webonyx\/graphql-php.<\/p>\n<h2 style=\"font-size: 22px; margin-bottom: 15px; text-align: justify;\">Installation<\/h2>\n<p style=\"text-align: justify;\">Using composer, simply run:<\/p>\n<pre class=\"brush: actionscript3; gutter: true\">composer require webonyx\/graphql-php<\/pre>\n<h2 style=\"font-size: 22px; margin-bottom: 15px; text-align: justify;\">How GraphQL Fetch Data with Queries?<\/h2>\n<p style=\"text-align: justify;\">In the REST, API returns data in a defined structure. While writing the API in REST we have to define the structure of data what it will return but GraphQL has no defined structure it will return. It can change their structure as per client need.<\/p>\n<p style=\"text-align: justify;\">The client has to send some more information to the server in order to declare their requirements and this information is called the Query.<\/p>\n<p style=\"text-align: justify;\">In the Query, we have to define the Root Fields in the other word we say the same as payload for the service.<\/p>\n<h2 style=\"font-size: 22px; margin-bottom: 15px; text-align: justify;\">Resolver<\/h2>\n<p><a href=\"https:\/\/www.knowband.com\/blog\/wp-content\/uploads\/2018\/10\/Screenshot_1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-817021 size-full\" src=\"https:\/\/www.knowband.com\/blog\/wp-content\/uploads\/2018\/10\/Screenshot_1-e1658148119764.png\" alt=\"Resolver in GraphQL PHL\" width=\"949\" height=\"367\" srcset=\"https:\/\/www.knowband.com\/blog\/wp-content\/uploads\/2018\/10\/Screenshot_1-e1658148119764.png 949w, https:\/\/www.knowband.com\/blog\/wp-content\/uploads\/2018\/10\/Screenshot_1-e1658148119764-300x116.png 300w, https:\/\/www.knowband.com\/blog\/wp-content\/uploads\/2018\/10\/Screenshot_1-e1658148119764-768x297.png 768w\" sizes=\"auto, (max-width: 949px) 100vw, 949px\" \/><\/a><\/p>\n<p style=\"text-align: justify;\">In the real world application like e-commerce application i.e. PrestaShop, OpenCart, Magneto etc. we need to fetch the customer data from the database by customerId and have to return the same. Our point is we don\u2019t have to return the arrays, we have to return the values and\u00a0graphql-php\u00a0will pass it untouched to nested resolvers.<\/p>\n<p style=\"text-align: justify;\">The resolver is basically a call back function for each field. There is always a default resolver for all fields. When we define our own\u00a0resolve\u00a0function for a field we simply override the default resolver.<\/p>\n<h2 style=\"font-size: 22px; margin-bottom: 15px; text-align: justify;\">How to define Schema for Query?<\/h2>\n<pre class=\"brush: actionscript3; gutter: true\">$schema_obj = new Schema {\r\n          \u201cquery\u201d =&gt; $queryType,\r\n          \u201cmutation\u201d =&gt; $mutationType,\r\n           \u201csubscription\u201d =&gt; $subscriptionType\r\n}<\/pre>\n<h3 style=\"font-size: 18px; margin-bottom: 15px; text-align: justify;\"><strong>Example<\/strong><\/h3>\n<p style=\"text-align: justify;\">As this is a blog for the beginners or fresher let\u2019s do a simple example.<\/p>\n<p style=\"text-align: justify;\">Let&#8217;s create a type system that will be to process following simple query:<\/p>\n<pre class=\"brush: actionscript3; gutter: true\">query {\r\n  echo(message: &quot;Hi Knowband, this is my first GraphQL program&quot;)\r\n}\r\n<\/pre>\n<p><strong>Note:<\/strong> We need an object type with field echo to do so.<\/p>\n<pre class=\"brush: actionscript3; gutter: true\">&lt;?php\r\nuse GraphQL\\Type\\Definition\\ObjectType;\r\nuse GraphQL\\Type\\Definition\\Type;\r\n$queryType = new ObjectType([\r\n    &#039;name&#039; =&gt; &#039;Query&#039;,\r\n    &#039;fields&#039; =&gt; [\r\n        &#039;echo&#039; =&gt; [\r\n            &#039;type&#039; =&gt; Type::string(),\r\n            &#039;args&#039; =&gt; [\r\n                &#039;message&#039; =&gt; Type::nonNull(Type::string()),\r\n            ],\r\n            &#039;resolve&#039; =&gt; function ($root, $args) {\r\n                return $root[&#039;prefix&#039;] . $args[&#039;message&#039;];\r\n            }\r\n        ],\r\n    ],\r\n]);<\/pre>\n<p style=\"text-align: justify;\">The\u00a0resolve\u00a0option\u00a0is\u00a0very\u00a0important\u00a0option\u00a0of\u00a0field\u00a0definition.\u00a0It\u00a0is\u00a0one\u00a0which\u00a0is\u00a0responsible\u00a0to\u00a0for\u00a0returning\u00a0the\u00a0value\u00a0of\u00a0our\u00a0field.\u00a0Values\u00a0of\u00a0the\u00a0scalar\u00a0fields\u00a0will\u00a0be\u00a0directly\u00a0get\u00a0included\u00a0in\u00a0response\u00a0while\u00a0the\u00a0values\u00a0of\u00a0the\u00a0composite\u00a0fields\u00a0will\u00a0be\u00a0passed\u00a0down\u00a0to\u00a0the\u00a0nested\u00a0field\u00a0resolvers.\u00a0Composite\u00a0fields\u00a0are\u00a0interfaces,\u00a0unions,\u00a0objects\u00a0etc.<\/p>\n<p style=\"text-align: justify;\">Now\u00a0after\u00a0our\u00a0type\u00a0become\u00a0ready,\u00a0let\u2019s\u00a0write\u00a0the\u00a0GraphQL\u00a0endpoint\u00a0file\u00a0for\u00a0it\u00a0graphql_program_1.php.<\/p>\n<pre class=\"brush: actionscript3; gutter: true\">&lt;?php\r\nuse GraphQL\\GraphQL;\r\nuse GraphQL\\Type\\Schema;\r\ntry {\r\n    $schema_obj = new Schema([\r\n        &#039;query&#039; =&gt; $queryType\r\n    ]);\r\n    $Input = file_get_contents(&#039;php:\/\/input&#039;);\r\n    $input_data = json_decode($Input, true);\r\n    $query_data = $input_data[&#039;query&#039;];\r\n    $variable_values = isset($input_data[&#039;variables&#039;]) ? $input_data[&#039;variables&#039;] : null;\r\n    $value = [&#039;prefix&#039; =&gt; &#039;Output: &#039;];\r\n    $resultant = GraphQL::executeQuery($schema_obj, $query_data, $value, null, $variable_values);\r\n    $output_value = $resultant-&gt;toArray();\r\n} catch (\\Exception $e) {\r\n    $output_value = [\r\n        &#039;errors&#039; =&gt; [\r\n            [\r\n                &#039;message&#039; =&gt; $e-&gt;getMessage()\r\n            ]\r\n        ]\r\n    ];\r\n}\r\nheader(&#039;Content-Type: application\/json&#039;);\r\necho json_encode($output_value);\r\n?&gt;<\/pre>\n<h3 style=\"font-size: 18px; margin-bottom: 15px; text-align: justify;\"><strong>How can we run the code?<\/strong><\/h3>\n<p>We can run the code by:<\/p>\n<pre class=\"brush: actionscript3; gutter: true\">php -S localhost:8080 graphql_program_1.php\r\ncurl https:\/\/localhost:8080 -d &#039;{&quot;query&quot;: &quot;query { echo(message: \\&quot; Hi Knowband, this is my first GraphQL program \\&quot;) }&quot; }&#039;<\/pre>\n<p>For any queries, please feel free to reach us at support@knowband.com. Knowband is providing the best in class modules for Prestashop, Opencart, Magento and Magento 2.<\/p>\n<p>Take a look at one of our most popular for Prestashop called One page supercheckout:<br \/>\n<iframe loading=\"lazy\" title=\"YouTube video player\" src=\"https:\/\/www.youtube.com\/embed\/1yLcXToR6-g\" width=\"660\" height=\"315\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Have you heard about GraphQL? GraphQL is a modern query language for the API. In another word, we can say it is a modern application layer query language. With the help of GraphQL, we can fetch data from the API calls and it works on the HTTP as REST. It provides the powerful option to [&hellip;]<\/p>\n","protected":false},"author":15,"featured_media":817011,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_kbui_enabled":"","footnotes":""},"categories":[7507],"tags":[7508,7545,7546,7510],"class_list":["post-22325","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","tag-graphicql","tag-graphicql-in-php","tag-use-graphql-in-php","tag-webonyx"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.6 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to use GraphQL in PHP: Knowband Blog<\/title>\n<meta name=\"description\" content=\"GraphicQL is a modern query language for the API. In another word we can say it is a modern application layer query language.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.knowband.com\/blog\/tutorials\/use-graphql-php-2\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to use GraphQL in PHP: Knowband Blog\" \/>\n<meta property=\"og:description\" content=\"GraphicQL is a modern query language for the API. In another word we can say it is a modern application layer query language.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.knowband.com\/blog\/tutorials\/use-graphql-php-2\/\" \/>\n<meta property=\"og:site_name\" content=\"Knowband Blog | Ecommerce Modules\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/Knowband\" \/>\n<meta property=\"article:published_time\" content=\"2018-10-30T09:01:43+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-07-18T12:42:09+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.knowband.com\/blog\/wp-content\/uploads\/2018\/10\/Main-Banner-graphql-php.png\" \/>\n\t<meta property=\"og:image:width\" content=\"760\" \/>\n\t<meta property=\"og:image:height\" content=\"300\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Sunny Saurabh\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@KnowbandPlugin\" \/>\n<meta name=\"twitter:site\" content=\"@KnowbandPlugin\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Sunny Saurabh\" \/>\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:\\\/\\\/www.knowband.com\\\/blog\\\/tutorials\\\/use-graphql-php-2\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.knowband.com\\\/blog\\\/tutorials\\\/use-graphql-php-2\\\/\"},\"author\":{\"name\":\"Sunny Saurabh\",\"@id\":\"https:\\\/\\\/www.knowband.com\\\/blog\\\/fr\\\/#\\\/schema\\\/person\\\/57eba27850520f4c8de3853ee8755a55\"},\"headline\":\"How to use GraphQL in PHP?\",\"datePublished\":\"2018-10-30T09:01:43+00:00\",\"dateModified\":\"2022-07-18T12:42:09+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.knowband.com\\\/blog\\\/tutorials\\\/use-graphql-php-2\\\/\"},\"wordCount\":653,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.knowband.com\\\/blog\\\/fr\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.knowband.com\\\/blog\\\/tutorials\\\/use-graphql-php-2\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.knowband.com\\\/blog\\\/wp-content\\\/uploads\\\/2018\\\/10\\\/Main-Banner-graphql-php.png\",\"keywords\":[\"GraphicQL\",\"GraphicQL in PHP\",\"Use GraphQL in PHP\",\"Webonyx\"],\"articleSection\":[\"Tutorials\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.knowband.com\\\/blog\\\/tutorials\\\/use-graphql-php-2\\\/\",\"url\":\"https:\\\/\\\/www.knowband.com\\\/blog\\\/tutorials\\\/use-graphql-php-2\\\/\",\"name\":\"How to use GraphQL in PHP: Knowband Blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.knowband.com\\\/blog\\\/fr\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.knowband.com\\\/blog\\\/tutorials\\\/use-graphql-php-2\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.knowband.com\\\/blog\\\/tutorials\\\/use-graphql-php-2\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.knowband.com\\\/blog\\\/wp-content\\\/uploads\\\/2018\\\/10\\\/Main-Banner-graphql-php.png\",\"datePublished\":\"2018-10-30T09:01:43+00:00\",\"dateModified\":\"2022-07-18T12:42:09+00:00\",\"description\":\"GraphicQL is a modern query language for the API. In another word we can say it is a modern application layer query language.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.knowband.com\\\/blog\\\/tutorials\\\/use-graphql-php-2\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.knowband.com\\\/blog\\\/tutorials\\\/use-graphql-php-2\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.knowband.com\\\/blog\\\/tutorials\\\/use-graphql-php-2\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.knowband.com\\\/blog\\\/wp-content\\\/uploads\\\/2018\\\/10\\\/Main-Banner-graphql-php.png\",\"contentUrl\":\"https:\\\/\\\/www.knowband.com\\\/blog\\\/wp-content\\\/uploads\\\/2018\\\/10\\\/Main-Banner-graphql-php.png\",\"width\":760,\"height\":300,\"caption\":\"How to use GraphQL in PHP?\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.knowband.com\\\/blog\\\/tutorials\\\/use-graphql-php-2\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.knowband.com\\\/blog\\\/fr\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Come creare un cliente in Magento?\",\"item\":\"https:\\\/\\\/www.knowband.com\\\/blog\\\/it\\\/magento-esercitazioni\\\/come-creare-un-cliente-in-magento\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"How to use GraphQL in PHP?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.knowband.com\\\/blog\\\/fr\\\/#website\",\"url\":\"https:\\\/\\\/www.knowband.com\\\/blog\\\/fr\\\/\",\"name\":\"Knowband Blog | Ecommerce Modules\",\"description\":\"Magento, Prestashop, Opencart, Shopify\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.knowband.com\\\/blog\\\/fr\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.knowband.com\\\/blog\\\/fr\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.knowband.com\\\/blog\\\/fr\\\/#organization\",\"name\":\"Knowband Blog | Ecommerce Modules\",\"url\":\"https:\\\/\\\/www.knowband.com\\\/blog\\\/fr\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.knowband.com\\\/blog\\\/fr\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.knowband.com\\\/blog\\\/wp-content\\\/uploads\\\/2016\\\/09\\\/cropped-knowband_logo-v2.png\",\"contentUrl\":\"https:\\\/\\\/www.knowband.com\\\/blog\\\/wp-content\\\/uploads\\\/2016\\\/09\\\/cropped-knowband_logo-v2.png\",\"width\":153,\"height\":61,\"caption\":\"Knowband Blog | Ecommerce Modules\"},\"image\":{\"@id\":\"https:\\\/\\\/www.knowband.com\\\/blog\\\/fr\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/Knowband\",\"https:\\\/\\\/x.com\\\/KnowbandPlugin\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.knowband.com\\\/blog\\\/fr\\\/#\\\/schema\\\/person\\\/57eba27850520f4c8de3853ee8755a55\",\"name\":\"Sunny Saurabh\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.knowband.com\\\/blog\\\/wp-content\\\/uploads\\\/2018\\\/10\\\/IMG_20181029_123810-150x150.jpg\",\"url\":\"https:\\\/\\\/www.knowband.com\\\/blog\\\/wp-content\\\/uploads\\\/2018\\\/10\\\/IMG_20181029_123810-150x150.jpg\",\"contentUrl\":\"https:\\\/\\\/www.knowband.com\\\/blog\\\/wp-content\\\/uploads\\\/2018\\\/10\\\/IMG_20181029_123810-150x150.jpg\",\"caption\":\"Sunny Saurabh\"},\"description\":\"Sunny Saurabh is an experienced Software engineer in C# and ASP.NET as well as an expert as a PHP developer. He has also expert in database design, server maintenance and security. He has achieved this goal only in the short span of 3yrs and still looking forward to achieving more in the IT industry. He lives in New Delhi and his hobby to write the technical writeups.\",\"url\":\"https:\\\/\\\/www.knowband.com\\\/blog\\\/author\\\/ssaurabh\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to use GraphQL in PHP: Knowband Blog","description":"GraphicQL is a modern query language for the API. In another word we can say it is a modern application layer query language.","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:\/\/www.knowband.com\/blog\/tutorials\/use-graphql-php-2\/","og_locale":"en_US","og_type":"article","og_title":"How to use GraphQL in PHP: Knowband Blog","og_description":"GraphicQL is a modern query language for the API. In another word we can say it is a modern application layer query language.","og_url":"https:\/\/www.knowband.com\/blog\/tutorials\/use-graphql-php-2\/","og_site_name":"Knowband Blog | Ecommerce Modules","article_publisher":"https:\/\/www.facebook.com\/Knowband","article_published_time":"2018-10-30T09:01:43+00:00","article_modified_time":"2022-07-18T12:42:09+00:00","og_image":[{"width":760,"height":300,"url":"https:\/\/www.knowband.com\/blog\/wp-content\/uploads\/2018\/10\/Main-Banner-graphql-php.png","type":"image\/png"}],"author":"Sunny Saurabh","twitter_card":"summary_large_image","twitter_creator":"@KnowbandPlugin","twitter_site":"@KnowbandPlugin","twitter_misc":{"Written by":"Sunny Saurabh","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.knowband.com\/blog\/tutorials\/use-graphql-php-2\/#article","isPartOf":{"@id":"https:\/\/www.knowband.com\/blog\/tutorials\/use-graphql-php-2\/"},"author":{"name":"Sunny Saurabh","@id":"https:\/\/www.knowband.com\/blog\/fr\/#\/schema\/person\/57eba27850520f4c8de3853ee8755a55"},"headline":"How to use GraphQL in PHP?","datePublished":"2018-10-30T09:01:43+00:00","dateModified":"2022-07-18T12:42:09+00:00","mainEntityOfPage":{"@id":"https:\/\/www.knowband.com\/blog\/tutorials\/use-graphql-php-2\/"},"wordCount":653,"commentCount":0,"publisher":{"@id":"https:\/\/www.knowband.com\/blog\/fr\/#organization"},"image":{"@id":"https:\/\/www.knowband.com\/blog\/tutorials\/use-graphql-php-2\/#primaryimage"},"thumbnailUrl":"https:\/\/www.knowband.com\/blog\/wp-content\/uploads\/2018\/10\/Main-Banner-graphql-php.png","keywords":["GraphicQL","GraphicQL in PHP","Use GraphQL in PHP","Webonyx"],"articleSection":["Tutorials"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.knowband.com\/blog\/tutorials\/use-graphql-php-2\/","url":"https:\/\/www.knowband.com\/blog\/tutorials\/use-graphql-php-2\/","name":"How to use GraphQL in PHP: Knowband Blog","isPartOf":{"@id":"https:\/\/www.knowband.com\/blog\/fr\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.knowband.com\/blog\/tutorials\/use-graphql-php-2\/#primaryimage"},"image":{"@id":"https:\/\/www.knowband.com\/blog\/tutorials\/use-graphql-php-2\/#primaryimage"},"thumbnailUrl":"https:\/\/www.knowband.com\/blog\/wp-content\/uploads\/2018\/10\/Main-Banner-graphql-php.png","datePublished":"2018-10-30T09:01:43+00:00","dateModified":"2022-07-18T12:42:09+00:00","description":"GraphicQL is a modern query language for the API. In another word we can say it is a modern application layer query language.","breadcrumb":{"@id":"https:\/\/www.knowband.com\/blog\/tutorials\/use-graphql-php-2\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.knowband.com\/blog\/tutorials\/use-graphql-php-2\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.knowband.com\/blog\/tutorials\/use-graphql-php-2\/#primaryimage","url":"https:\/\/www.knowband.com\/blog\/wp-content\/uploads\/2018\/10\/Main-Banner-graphql-php.png","contentUrl":"https:\/\/www.knowband.com\/blog\/wp-content\/uploads\/2018\/10\/Main-Banner-graphql-php.png","width":760,"height":300,"caption":"How to use GraphQL in PHP?"},{"@type":"BreadcrumbList","@id":"https:\/\/www.knowband.com\/blog\/tutorials\/use-graphql-php-2\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.knowband.com\/blog\/fr\/"},{"@type":"ListItem","position":2,"name":"Come creare un cliente in Magento?","item":"https:\/\/www.knowband.com\/blog\/it\/magento-esercitazioni\/come-creare-un-cliente-in-magento\/"},{"@type":"ListItem","position":3,"name":"How to use GraphQL in PHP?"}]},{"@type":"WebSite","@id":"https:\/\/www.knowband.com\/blog\/fr\/#website","url":"https:\/\/www.knowband.com\/blog\/fr\/","name":"Knowband Blog | Ecommerce Modules","description":"Magento, Prestashop, Opencart, Shopify","publisher":{"@id":"https:\/\/www.knowband.com\/blog\/fr\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.knowband.com\/blog\/fr\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.knowband.com\/blog\/fr\/#organization","name":"Knowband Blog | Ecommerce Modules","url":"https:\/\/www.knowband.com\/blog\/fr\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.knowband.com\/blog\/fr\/#\/schema\/logo\/image\/","url":"https:\/\/www.knowband.com\/blog\/wp-content\/uploads\/2016\/09\/cropped-knowband_logo-v2.png","contentUrl":"https:\/\/www.knowband.com\/blog\/wp-content\/uploads\/2016\/09\/cropped-knowband_logo-v2.png","width":153,"height":61,"caption":"Knowband Blog | Ecommerce Modules"},"image":{"@id":"https:\/\/www.knowband.com\/blog\/fr\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/Knowband","https:\/\/x.com\/KnowbandPlugin"]},{"@type":"Person","@id":"https:\/\/www.knowband.com\/blog\/fr\/#\/schema\/person\/57eba27850520f4c8de3853ee8755a55","name":"Sunny Saurabh","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.knowband.com\/blog\/wp-content\/uploads\/2018\/10\/IMG_20181029_123810-150x150.jpg","url":"https:\/\/www.knowband.com\/blog\/wp-content\/uploads\/2018\/10\/IMG_20181029_123810-150x150.jpg","contentUrl":"https:\/\/www.knowband.com\/blog\/wp-content\/uploads\/2018\/10\/IMG_20181029_123810-150x150.jpg","caption":"Sunny Saurabh"},"description":"Sunny Saurabh is an experienced Software engineer in C# and ASP.NET as well as an expert as a PHP developer. He has also expert in database design, server maintenance and security. He has achieved this goal only in the short span of 3yrs and still looking forward to achieving more in the IT industry. He lives in New Delhi and his hobby to write the technical writeups.","url":"https:\/\/www.knowband.com\/blog\/author\/ssaurabh\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.knowband.com\/blog\/wp-json\/wp\/v2\/posts\/22325","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.knowband.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.knowband.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.knowband.com\/blog\/wp-json\/wp\/v2\/users\/15"}],"replies":[{"embeddable":true,"href":"https:\/\/www.knowband.com\/blog\/wp-json\/wp\/v2\/comments?post=22325"}],"version-history":[{"count":12,"href":"https:\/\/www.knowband.com\/blog\/wp-json\/wp\/v2\/posts\/22325\/revisions"}],"predecessor-version":[{"id":817024,"href":"https:\/\/www.knowband.com\/blog\/wp-json\/wp\/v2\/posts\/22325\/revisions\/817024"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.knowband.com\/blog\/wp-json\/wp\/v2\/media\/817011"}],"wp:attachment":[{"href":"https:\/\/www.knowband.com\/blog\/wp-json\/wp\/v2\/media?parent=22325"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.knowband.com\/blog\/wp-json\/wp\/v2\/categories?post=22325"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.knowband.com\/blog\/wp-json\/wp\/v2\/tags?post=22325"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}