{"id":133586,"date":"2018-07-16T05:21:50","date_gmt":"2018-07-16T05:21:50","guid":{"rendered":"https:\/\/webkul.com\/blog\/?p=133586"},"modified":"2024-04-24T13:05:13","modified_gmt":"2024-04-24T13:05:13","slug":"how-to-use-graphql-in-php","status":"publish","type":"post","link":"https:\/\/webkul.com\/blog\/how-to-use-graphql-in-php\/","title":{"rendered":"How to use GraphQL in php"},"content":{"rendered":"<p><strong>GraphQL<\/strong> is a Query Language for <a href=\"https:\/\/webkul.com\/api\/\">Application programming interface<\/a> (API&#8217;s) or we can say GraphQL is an application layer query language.<br \/>\nIn short GraphQL\u00a0 is a modern way to fetch data from API calls.<br \/>\nI called it a <strong>new <\/strong>or<strong> a modern way<\/strong> of consuming APIs , because it works on HTTP as REST works. It gives power to client to ask What exactly they need, that will help in API Evolution.<\/p>\n<p>Key points :<\/p>\n<ul>\n<li>It solves the over-fetching or under-fetching of data<\/li>\n<li>It has strongly typed\u00a0 system (schema)<\/li>\n<li>More resource in single request<\/li>\n<li>Powerful open source system etc.<\/li>\n<\/ul>\n<p><strong>Note<\/strong> : GraphQL API&#8217;s are structured in\u00a0 terms of Type and Field.<\/p>\n<h2><strong>Fetching Data with Queries<\/strong> :<\/h2>\n<p>When loading data in REST , we have different end point with defined structure of information it will return, but In GraphQL we have a single end point that has no defined structure it will return.<\/p>\n<p>It is completely Flexible. client decide what they need and ask for the same.<br \/>\nSo client need to send more information to the server to express its need and this information is called a <em>Query<\/em> .<\/p>\n<p>In <em>Query<\/em> we need to define a <em>Root Field<\/em> that we can say is a <em>payload<\/em> for the service.<\/p>\n<h2><strong>Queries with Arguments<\/strong> :<\/h2>\n<p>In Graph, each field can have zero or more arguments if that\u2019s specified in the schema.<\/p>\n<p><strong>Data with Mutations<\/strong> : Query is used to fetch data but there could be a need where a person need to make changes in backend data. So to achieve this in GraphQL we use Mutations.<br \/>\nMutation Operations :<br \/>\n&#8211; creating new data<br \/>\n&#8211; updating existing data<br \/>\n&#8211; deleting existing data<\/p>\n<p><strong>Subscriptions<\/strong> : Subscription is used for real time connection to the server to inform about the event that occurred.<\/p>\n<p><strong>GraphQL supported languages<\/strong> :<br \/>\nGraphQL has support for almost all languages, you just need to include the library for that.<br \/>\nIn my case I have used this php library :\u00a0<strong>webonyx\/graphql-php<\/strong> .<\/p>\n<pre class=\"brush:shell\">$ composer require webonyx\/graphql-php<\/pre>\n<p>let&#8217;s see one basic example that may help you understand how GraphQL Works but before that let&#8217;s understand what <span style=\"text-decoration: underline;\"><strong>resolver<\/strong><\/span> is ?,\u00a0 <strong>Resolver<\/strong> is basically a Function or we can say call back function for each field.<\/p>\n<p>Step 1 : After requiring the GraphQL Package , include following Classes in your project.<\/p>\n<pre class=\"brush:shell\">use GraphQL\\Type\\Definition\\ObjectType;\nuse GraphQL\\Type\\Definition\\Type;\nuse GraphQL\\GraphQL;\nuse GraphQL\\Type\\Schema;<\/pre>\n<p><strong>Note<\/strong> : GraphQL is a root Class.<\/p>\n<p><strong>Step 2<\/strong> : Define the Schema for your Query.<\/p>\n<pre class=\"brush:php\">$schema = new Schema([\n    \"query\" =&gt; $queryType\n]);<\/pre>\n<p>As this example will walk you around QueryType, that&#8217;s why I have defined only Query in <a href=\"https:\/\/webkul.com\/blog\/how-to-add-a-custom-field-to-graphql-schema\/\">schema parameter<\/a>.<br \/>\nsimilarly we can define mutations as well.<br \/>\n<strong>Example<\/strong> :<br \/>\nnew Schema {<br \/>\n&#8220;query&#8221; =&gt; &lt;Query&gt;,<br \/>\n&#8220;mutation&#8221; =&gt; &lt;Mutation&gt;,<br \/>\n&#8220;subscription&#8221; =&gt; &lt;Subscription&gt;<br \/>\n}<br \/>\n<strong>Step<\/strong> <strong>3<\/strong> : Now we need to define the Query Type Object.<\/p>\n<pre class=\"brush:php\">$queryType = new ObjectType([\n    'name' =&gt; 'Query',\n    'fields' =&gt; [\n        'customer' =&gt; [\n            'type' =&gt; $userType,\n            'args' =&gt; [\n                'id' =&gt; Type::int(),\n            ],\n            'resolve' =&gt; function ($root, $args) {\n                $returnArray = [];\n                foreach($root as $key =&gt; $customer) {\n                    if ($customer[\"id\"] == $args[\"id\"])\n                        $returnArray = $customer;\n                }\n                return $returnArray;\n            }\n        ],\n    ],\n]);<\/pre>\n<p>You must have observer that Object Type has a Field named as Customer with backed resolver function,<br \/>\nwhich has two parameter one is $root i.e. Root Value\u00a0 and another is $args which is used when we can specific customer data via ID.<\/p>\n<p><strong>Step 4<\/strong> : As Query Type Object&#8217;s Field customer have relation with other Object Type\u00a0 called User type, So we need to define this object as well. Similarly we can have other nesting object connections as well. As in below code.<\/p>\n<pre class=\"brush:php\">$street = new ObjectType([\n    'name' =&gt; 'Street',\n    'description' =&gt; 'Customer Address from json object',\n    'fields' =&gt; [\n        'street1' =&gt; Type::string(),\n        'street2' =&gt; Type::string(),\n    ]\n]);\n\n$address = new ObjectType([\n    'name' =&gt; 'Address',\n    'description' =&gt; 'Customer Address from json object',\n    'fields' =&gt; [\n        'addressId' =&gt; Type::int(),\n        'state' =&gt; Type::string(),\n        'city' =&gt; Type::string(),\n        'street' =&gt; [\n            \"type\" =&gt; $street,\n            'resolve' =&gt; function($root, $args, $context) {\n                return $root['street']   ;\n            }\n        ],\n        'country' =&gt; Type::string()\n    ]\n  ]);\n\n$userType = new ObjectType([\n    'name' =&gt; 'Customer',\n    'description' =&gt; 'Customer from json object',\n    'fields' =&gt; [\n        'id' =&gt; Type::int(),\n        'firstname' =&gt; Type::string(),\n        'lastname' =&gt; Type::string(),\n        'age' =&gt; Type::int(),\n        'address' =&gt; [\n            \"type\" =&gt; $address,\n            'resolve' =&gt; function($root, $args, $context) {\n                return $root['address']   ;\n            }\n        ]\n    ]\n]);<\/pre>\n<p><strong>Step 5<\/strong> : Now it time to define the Root Value , you can have the values dynamically, as this is to give you a basic understanding how GraphQL works , I have set the static $rootValue as below :<\/p>\n<pre class=\"brush:php\">$customer = [\n    [\n        \"id\"=&gt;1,\n        \"firstname\"=&gt;\"John\",\n        \"lastname\"=&gt;\"Doe\",\n         \"age\"=&gt;14,\n         \"address\" =&gt; \n           [\n            \"addressId\"=&gt; 1,\n             \"street\"=&gt;[\"street1\" =&gt; \"167\",\"street2\" =&gt; \"XX Floor\"],\n             \"city\"=&gt;\"New York\",\n             \"state\"=&gt;\"NY\",\n             \"country\" =&gt; \"USA\"\n         ]\n    ],\n    [\n        \"id\"=&gt;2,\n        \"firstname\" =&gt; \"chris\",\n        \"lastname\" =&gt; \"Martin\",\n        \"age\"=&gt;29,\n        \"address\" =&gt; [\n            \"addressId\"=&gt; 2,\n             \"street\"=&gt;[\"street1\" =&gt; \"167\",\"street2\" =&gt; \"XX Floor\"],\n             \"city\"=&gt;\"New York\",\n             \"state\"=&gt;\"NY\",\n             \"country\" =&gt; \"USA\"\n        ]\n    ],\n    [\n        \"id\"=&gt;3,\n        \"firstname\" =&gt; \"Jenny\",\n        \"lastname\" =&gt; \"Ketty\",\n        \"age\"=&gt;32,\n        \"address\" =&gt; [\n            \"addressId\"=&gt; 3,\n             \"street\"=&gt;[\"street1\" =&gt; \"167\",\"street2\" =&gt; \"XX Floor\"],\n             \"city\"=&gt;\"New York\",\n             \"state\"=&gt;\"NY\",\n             \"country\" =&gt; \"USA\"\n        ]\n    ],\n    [\n        \"id\"=&gt;4,\n        \"firstname\" =&gt; \"Jennifer\",\n        \"lastname\" =&gt; \"Tim\",\n        \"age\"=&gt;31,\n        \"address\" =&gt; [\n             \"addressId\"=&gt; 4,\n             \"street\"=&gt;[\"street1\" =&gt; \"167\",\"street2\" =&gt; \"XX Floor\"],\n             \"city\"=&gt;\"New York\",\n             \"state\"=&gt;\"NY\",\n             \"country\" =&gt; \"USA\"\n        ]\n    ]\n];<\/pre>\n<p class=\"brush:php\"><strong>Step 6<\/strong> :Now Final step how Query is processed :<\/p>\n<pre class=\"brush:php\">try{\n    $rawInput = file_get_contents('php:\/\/input');\n    $input = json_decode($rawInput, true);\n    $query = $input['query'];\n\n    $variableValues = isset($input['variables']) ? $input['variables'] : null;\n    $variableValues=[];\n    $rootValue = $customer;\n    $result = GraphQL::executeQuery($schema, $query, $rootValue, null, $variableValues);\n\n    $output = $result-&gt;toArray();\n} catch (\\Exception $e) {\n    $output = [\n        'error' =&gt; [\n            'message' =&gt; $e-&gt;getMessage()\n        ]\n    ];\n}\n\nheader('Content-Type: application\/json');\necho json_encode($output);<\/pre>\n<p>GraphQL class&#8217;s executeQuery function is used to process the Requested Query as you can see above.<br \/>\nThe process is we need to get the demand of the user which is called Query and need to forward to the ExecuteQuery function along with root Value then GraphQL will return the Data as per defined type, field and resolver functions.<\/p>\n<p><strong>Note<\/strong> : GraphQL has Tool Called GraphiQL for Introspection.<br \/>\n<strong>GraphiQL<\/strong> &#8211; An in-browser IDE for exploring GraphQL<br \/>\n<strong>ChromeiQL<\/strong> or <strong>GraphiQL Feen<\/strong> &#8211; GraphiQL as Google Chrome extension<\/p>\n<p>In GraphiQL Tool We need to set the GraphQL End point.<br \/>\nPlease check the below Screen shot of GraphiQL Tool with the above Example :<\/p>\n<p><img decoding=\"async\" class=\"alignnone wp-image-133600 size-full\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/07\/Screenshot_3-1.png\" alt=\"GraphQl\" width=\"1308\" height=\"627\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/07\/Screenshot_3-1.png 1308w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/07\/Screenshot_3-1-250x120.png 250w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/07\/Screenshot_3-1-300x144.png 300w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/07\/Screenshot_3-1-768x368.png 768w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/07\/Screenshot_3-1-1200x575.png 1200w\" sizes=\"(max-width: 1308px) 100vw, 1308px\" loading=\"lazy\" \/><\/p>\n<p>In Next Blog I will Explain few more Points with Example.<\/p>\n<p>Mean while Please try the above example and If you have any Query then please feel free to put it in comment section.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>GraphQL is a Query Language for Application programming interface (API&#8217;s) or we can say GraphQL is an application layer query language. In short GraphQL\u00a0 is a modern way to fetch data from API calls. I called it a new or a modern way of consuming APIs , because it works on HTTP as REST works. <a href=\"https:\/\/webkul.com\/blog\/how-to-use-graphql-in-php\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":170,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[302,13],"tags":[7085,7087,7088,2057,4414,2191,7086],"class_list":["post-133586","post","type-post","status-publish","format-standard","hentry","category-magento2","category-php","tag-graphql","tag-modern","tag-mutation","tag-php","tag-query","tag-subscription","tag-webonyx"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to use GraphQL in php - Webkul Blog<\/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:\/\/webkul.com\/blog\/how-to-use-graphql-in-php\/\" \/>\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 - Webkul Blog\" \/>\n<meta property=\"og:description\" content=\"GraphQL is a Query Language for Application programming interface (API&#8217;s) or we can say GraphQL is an application layer query language. In short GraphQL\u00a0 is a modern way to fetch data from API calls. I called it a new or a modern way of consuming APIs , because it works on HTTP as REST works. [...]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webkul.com\/blog\/how-to-use-graphql-in-php\/\" \/>\n<meta property=\"og:site_name\" content=\"Webkul Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webkul\/\" \/>\n<meta property=\"article:published_time\" content=\"2018-07-16T05:21:50+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-24T13:05:13+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2018\/07\/Screenshot_3-1.png\" \/>\n<meta name=\"author\" content=\"Prabhat Rawat\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webkul\" \/>\n<meta name=\"twitter:site\" content=\"@webkul\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Prabhat Rawat\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/webkul.com\/blog\/how-to-use-graphql-in-php\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/how-to-use-graphql-in-php\/\"},\"author\":{\"name\":\"Prabhat Rawat\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/3d52d6c1ad8a809d2f7548e6a9c3358f\"},\"headline\":\"How to use GraphQL in php\",\"datePublished\":\"2018-07-16T05:21:50+00:00\",\"dateModified\":\"2024-04-24T13:05:13+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/how-to-use-graphql-in-php\/\"},\"wordCount\":704,\"commentCount\":8,\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/how-to-use-graphql-in-php\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2018\/07\/Screenshot_3-1.png\",\"keywords\":[\"graphQL\",\"modern\",\"mutation\",\"PHP\",\"Query\",\"Subscription\",\"webonyx\"],\"articleSection\":[\"Magento2\",\"php\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/webkul.com\/blog\/how-to-use-graphql-in-php\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webkul.com\/blog\/how-to-use-graphql-in-php\/\",\"url\":\"https:\/\/webkul.com\/blog\/how-to-use-graphql-in-php\/\",\"name\":\"How to use GraphQL in php - Webkul Blog\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/how-to-use-graphql-in-php\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/how-to-use-graphql-in-php\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2018\/07\/Screenshot_3-1.png\",\"datePublished\":\"2018-07-16T05:21:50+00:00\",\"dateModified\":\"2024-04-24T13:05:13+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/webkul.com\/blog\/how-to-use-graphql-in-php\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webkul.com\/blog\/how-to-use-graphql-in-php\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/how-to-use-graphql-in-php\/#primaryimage\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/07\/Screenshot_3-1.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/07\/Screenshot_3-1.png\",\"width\":\"1308\",\"height\":\"627\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webkul.com\/blog\/how-to-use-graphql-in-php\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to use GraphQL in php\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/webkul.com\/blog\/#website\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"name\":\"Webkul Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/webkul.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/webkul.com\/blog\/#organization\",\"name\":\"WebKul Software Private Limited\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"width\":380,\"height\":380,\"caption\":\"WebKul Software Private Limited\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webkul\/\",\"https:\/\/x.com\/webkul\",\"https:\/\/www.instagram.com\/webkul\/\",\"https:\/\/www.linkedin.com\/company\/webkul\",\"https:\/\/www.youtube.com\/user\/webkul\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/3d52d6c1ad8a809d2f7548e6a9c3358f\",\"name\":\"Prabhat Rawat\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/616ec5deaf63b72b3003cf99e608ae354f4d373cee8d25b2d0bfa65cab270ad8?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/616ec5deaf63b72b3003cf99e608ae354f4d373cee8d25b2d0bfa65cab270ad8?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"caption\":\"Prabhat Rawat\"},\"url\":\"https:\/\/webkul.com\/blog\/author\/prabhat-rawat763\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to use GraphQL in php - Webkul Blog","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:\/\/webkul.com\/blog\/how-to-use-graphql-in-php\/","og_locale":"en_US","og_type":"article","og_title":"How to use GraphQL in php - Webkul Blog","og_description":"GraphQL is a Query Language for Application programming interface (API&#8217;s) or we can say GraphQL is an application layer query language. In short GraphQL\u00a0 is a modern way to fetch data from API calls. I called it a new or a modern way of consuming APIs , because it works on HTTP as REST works. [...]","og_url":"https:\/\/webkul.com\/blog\/how-to-use-graphql-in-php\/","og_site_name":"Webkul Blog","article_publisher":"https:\/\/www.facebook.com\/webkul\/","article_published_time":"2018-07-16T05:21:50+00:00","article_modified_time":"2024-04-24T13:05:13+00:00","og_image":[{"url":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2018\/07\/Screenshot_3-1.png","type":"","width":"","height":""}],"author":"Prabhat Rawat","twitter_card":"summary_large_image","twitter_creator":"@webkul","twitter_site":"@webkul","twitter_misc":{"Written by":"Prabhat Rawat","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/webkul.com\/blog\/how-to-use-graphql-in-php\/#article","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/how-to-use-graphql-in-php\/"},"author":{"name":"Prabhat Rawat","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/3d52d6c1ad8a809d2f7548e6a9c3358f"},"headline":"How to use GraphQL in php","datePublished":"2018-07-16T05:21:50+00:00","dateModified":"2024-04-24T13:05:13+00:00","mainEntityOfPage":{"@id":"https:\/\/webkul.com\/blog\/how-to-use-graphql-in-php\/"},"wordCount":704,"commentCount":8,"publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"image":{"@id":"https:\/\/webkul.com\/blog\/how-to-use-graphql-in-php\/#primaryimage"},"thumbnailUrl":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2018\/07\/Screenshot_3-1.png","keywords":["graphQL","modern","mutation","PHP","Query","Subscription","webonyx"],"articleSection":["Magento2","php"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/webkul.com\/blog\/how-to-use-graphql-in-php\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/webkul.com\/blog\/how-to-use-graphql-in-php\/","url":"https:\/\/webkul.com\/blog\/how-to-use-graphql-in-php\/","name":"How to use GraphQL in php - Webkul Blog","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/webkul.com\/blog\/how-to-use-graphql-in-php\/#primaryimage"},"image":{"@id":"https:\/\/webkul.com\/blog\/how-to-use-graphql-in-php\/#primaryimage"},"thumbnailUrl":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2018\/07\/Screenshot_3-1.png","datePublished":"2018-07-16T05:21:50+00:00","dateModified":"2024-04-24T13:05:13+00:00","breadcrumb":{"@id":"https:\/\/webkul.com\/blog\/how-to-use-graphql-in-php\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webkul.com\/blog\/how-to-use-graphql-in-php\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/how-to-use-graphql-in-php\/#primaryimage","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/07\/Screenshot_3-1.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/07\/Screenshot_3-1.png","width":"1308","height":"627"},{"@type":"BreadcrumbList","@id":"https:\/\/webkul.com\/blog\/how-to-use-graphql-in-php\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to use GraphQL in php"}]},{"@type":"WebSite","@id":"https:\/\/webkul.com\/blog\/#website","url":"https:\/\/webkul.com\/blog\/","name":"Webkul Blog","description":"","publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/webkul.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/webkul.com\/blog\/#organization","name":"WebKul Software Private Limited","url":"https:\/\/webkul.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","width":380,"height":380,"caption":"WebKul Software Private Limited"},"image":{"@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webkul\/","https:\/\/x.com\/webkul","https:\/\/www.instagram.com\/webkul\/","https:\/\/www.linkedin.com\/company\/webkul","https:\/\/www.youtube.com\/user\/webkul\/"]},{"@type":"Person","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/3d52d6c1ad8a809d2f7548e6a9c3358f","name":"Prabhat Rawat","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/616ec5deaf63b72b3003cf99e608ae354f4d373cee8d25b2d0bfa65cab270ad8?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/616ec5deaf63b72b3003cf99e608ae354f4d373cee8d25b2d0bfa65cab270ad8?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","caption":"Prabhat Rawat"},"url":"https:\/\/webkul.com\/blog\/author\/prabhat-rawat763\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/133586","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/users\/170"}],"replies":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/comments?post=133586"}],"version-history":[{"count":9,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/133586\/revisions"}],"predecessor-version":[{"id":436243,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/133586\/revisions\/436243"}],"wp:attachment":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media?parent=133586"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/categories?post=133586"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/tags?post=133586"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}