{"id":380407,"date":"2023-05-29T03:58:35","date_gmt":"2023-05-29T03:58:35","guid":{"rendered":"https:\/\/webkul.com\/blog\/?p=380407"},"modified":"2023-06-06T06:28:37","modified_gmt":"2023-06-06T06:28:37","slug":"opencart-graphql-api","status":"publish","type":"post","link":"https:\/\/webkul.com\/blog\/opencart-graphql-api\/","title":{"rendered":"How to use GraphQL API in Opencart?"},"content":{"rendered":"\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1200\" height=\"675\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/06\/graphql-1200x675.png\" alt=\"graphql\" class=\"wp-image-385772\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/06\/graphql-1200x675.png 1200w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/06\/graphql-300x169.png 300w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/06\/graphql-250x141.png 250w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/06\/graphql-768x432.png 768w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/06\/graphql-1536x864.png 1536w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/06\/graphql.png 1920w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" loading=\"lazy\" \/><\/figure>\n\n\n\n<p>OpenCart is an open-source eCommerce platform, based on PHP and MVC architecture for online merchants. Opencart provides a great number of features that are responsible to control your store. <\/p>\n\n\n\n<p>It allows a professional and reliable foundation from which to build a successful online store.<\/p>\n\n\n\n<p>This article describes how a developer can use GraphQL API in Opencart. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">An Overview of GraphQL <\/h2>\n\n\n\n<p>GraphQl is an alternative to REST and SOAP API. It allows you to fetch the data easily using query language.&nbsp;It is a modern way to fetch data from API calls and makes API responses more efficient and reduces network overhead.<\/p>\n\n\n\n<p>GraphQL provides a complete and understandable description of the data in your API. The query&nbsp;returns data in a specified format usually in the form of a JSON string as fetched from the server end. <\/p>\n\n\n\n<p>In Short, the operations of GraphQL:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>queries<\/strong> &#8211; for reading and receiving information.<\/li>\n\n\n\n<li><strong>mutations<\/strong>&nbsp;&#8211; needed for taking actions, creating data, and modifying information.<\/li>\n\n\n\n<li><strong>subscriptions<\/strong>&nbsp;&#8211;  it provides the opportunity to get data from the server in real-time automatically after a while, for instance, for notifications.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Use of GraphQL for Developers?<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Developers can request the exact data they need, which results in smaller and more efficient data transfers. <\/li>\n\n\n\n<li>It provides a flexible data model, which allows developers to query data more naturally and intuitively. This makes it easier to build complex data-driven applications.<\/li>\n\n\n\n<li>Developers can also create custom GraphQL queries, mutations, and types, allowing them to extend the platform\u2019s default schema and can create custom functionality that meets their specific requirements.<\/li>\n\n\n\n<li>GraphQL solves this with a single endpoint and a strictly-typed schema. By design, the schema defines the resources available for retrieval in addition to the accepted parameters when fetching that data.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Comparison between graphQL API and REST API<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>Basis<\/strong><\/td><td>GraphQL API<\/td><td>REST API<\/td><\/tr><tr><td><strong>Querying<\/strong><\/td><td>With GraphQL, you can retrieve all the needed data in a single request and specify which fields and data you want.<\/td><td>With <a href=\"https:\/\/webkul.com\/blog\/use-opencarts-rest-api\/\" target=\"_blank\" rel=\"noreferrer noopener\">REST APIs<\/a>, you typically make separate requests for each resource or the endpoint you want to access.<\/td><\/tr><tr><td><strong>Caching<\/strong><\/td><td>GraphQL API caching can be more challenging because each request is unique and may require a different data set.<\/td><td>REST APIs are often easier to cache than GraphQL because the URLs are used as the cache keys.<\/td><\/tr><tr><td><strong>Learning Curve<\/strong><\/td><td>GraphQL has a steeper learning curve, and it may take longer to become proficient with the technology.<\/td><td>REST APIs are simpler to understand and use, and a wealth of documentation and tooling is available.<\/td><\/tr><tr><td><strong>Performance<\/strong><\/td><td>GraphQL can be more efficient than REST APIs for some use cases because it reduces over-fetching and under-fetching of data. <\/td><td>REST APIs can be faster when only a small amount of data is required.<\/td><\/tr><\/tbody><\/table><figcaption class=\"wp-element-caption\"><br>Although choosing GraphQl API is the best way instead of using REST API.<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">How to Implement?<\/h2>\n\n\n\n<p><strong>Step 1:<\/strong>  <strong>GraphQL PHP Library<\/strong> &#8211;  Just install the library <strong>webonyx\/graphql-php<\/strong>&nbsp;in opencart instance using code.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">$ composer require webonyx\/graphql-php<\/pre>\n\n\n\n<p><strong>Step 2<\/strong>:  <strong>Create a Controller file <\/strong>within the opencart root catalog directory like  &#8220;catalog\/controller\/api\/graphql\/usage.php&#8221;.<\/p>\n\n\n\n<p><strong>Step 3:<\/strong>  After installing the GraphQL Package, include the following <strong>Classes <\/strong>in your controller file.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\n\/**\n  * Webkul Software.\n  *\n  * @category Webkul\n  * @package Opencart Module Tutorial\n  * @author Webkul\n  * @license https:\/\/store.webkul.com\/license.html\n  *\/\nrequire_once(&#039;vendor\/autoload.php&#039;);\n\nuse GraphQL\\GraphQL;\nuse GraphQL\\Type\\Definition\\ObjectType;\nuse GraphQL\\Type\\Definition\\InputObjectType;\nuse GraphQL\\Type\\Definition\\Type;\nuse GraphQL\\Type\\Schema;<\/pre>\n\n\n\n<p><strong>Step 4:<\/strong> Create an Index method inside the controller class and define the schema for your QueryType.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">class ControllerApiGraphqlUsage extends Controller {\n public static $ProductType;\n public static $ReviewInput;\n    public function index () {\t\n        $schema = new Schema (&#091;\n          &#039;query&#039; =&gt; $RootQueryType,\n          &#039;mutation&#039; =&gt; $MutationType\n        ]);<\/pre>\n\n\n\n<p class=\"has-black-color has-text-color\"><strong>Note <\/strong>&#8211; Here we have added the query type and mutation type, similarly we can define the subscription type schema.<\/p>\n\n\n\n<p><strong>Step 5: <\/strong>Now we have to define the Query Type Object.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">$RootQueryType = new ObjectType (&#091;\n\n  &#039;name&#039; =&gt; &#039;RootQuery&#039;,\n  &#039;fields&#039; =&gt; function () { return &#091;\n  &#039;products&#039; =&gt; &#091;\n    &#039;type&#039; =&gt; Type::listOf (self::$ProductType),\n    &#039;args&#039; =&gt; &#091;\n       &#039;filter_category_id&#039; =&gt; Type::int (),\n       &#039;filter_sub_category&#039; =&gt; Type::int (),\n       &#039;filter_filter&#039; =&gt; Type::string (),\n       &#039;filter_name&#039; =&gt; Type::string (),\n       &#039;filter_tag&#039; =&gt; Type::string (),\n       &#039;filter_description&#039; =&gt; Type::string (),\n       &#039;filter_model&#039; =&gt; Type::string (),\n       &#039;filter_price&#039; =&gt; Type::string (),\n       &#039;filter_quantity&#039; =&gt; Type::string (),\n       &#039;filter_status&#039; =&gt; Type::string (),\n       &#039;filter_image&#039; =&gt; Type::string (),\n       &#039;filter_manufacturer_id&#039; =&gt; Type::int (),\n       &#039;sort&#039; =&gt; Type::string (),\n       &#039;order&#039; =&gt; Type::string (),\n       &#039;start&#039; =&gt; Type::int (),\n       &#039;limit&#039; =&gt; Type::int ()\n      ],\n    &#039;resolve&#039; =&gt; function ($root, $args) {\n        $key_mapper = &#091;\n               &#039;name&#039; =&gt; &#039;pd.name&#039;,\n               &#039;price&#039; =&gt; &#039;p.price&#039;,\n               &#039;rating&#039; =&gt; &#039;rating&#039;,\n               &#039;quantity&#039; =&gt; &#039;p.model&#039;,\n               &#039;date_added&#039; =&gt; &#039;p.date_added&#039;,\n                &#039;sort_order&#039; =&gt; &#039;p.sort_order&#039;\n               ];\n\n        $this-&gt;load-&gt;model(&#039;catalog\/product&#039;);\n        $args&#091;&#039;sort&#039;] = isset($args&#091;&#039;sort&#039;])? in_array($key_mapper&#091;$args&#091;&#039;sort&#039;]], array_keys($key_mapper)) ? $key_mapper&#091;$args&#091;&#039;sort&#039;]] : &#039;&#039;: &#039;&#039;;\n\n        $products = $this-&gt;model_catalog_product-&gt;getProducts($args);\n\n        return $products;\n     }\n\n   ],\n];}\n]);<\/pre>\n\n\n\n<p>Object Type has a Field named &#8220;products&#8221; with a backed resolver function that returns the data using the &#8220;getProducts function &#8221; that has parameter $args which is used when we can specific product data via filter_price or other arguments.<\/p>\n\n\n\n<p><strong>Step 6:<\/strong>  RootQueryType object has a link with the ProductType list, include the ProductType object in the file.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\"> self::$ProductType = new ObjectType (&#091;\n            &#039;name&#039; =&gt; &#039;Product&#039;,\n            &#039;fields&#039;  =&gt; function () { return &#091;\n                &#039;product_id&#039; =&gt; &#091;\n                    &#039;type&#039; =&gt; Type::id ()\n                ],\n                &#039;name&#039; =&gt; &#091;\n                    &#039;type&#039; =&gt; Type::string ()\n                ],\n                &#039;description&#039; =&gt; &#091;\n                    &#039;type&#039; =&gt; Type::string (),\n                    &#039;resolve&#039; =&gt; function ($root, $args) {\n                        return strip_tags(html_entity_decode($root&#091;&#039;description&#039;]));\n                    }\n                ],\n                &#039;meta_title&#039; =&gt; &#091;\n                    &#039;type&#039; =&gt; Type::string ()\n                ],\n                &#039;meta_description&#039; =&gt; &#091;\n                    &#039;type&#039; =&gt; Type::string ()\n                ],\n                &#039;model&#039; =&gt; &#091;\n                    &#039;type&#039; =&gt; Type::string ()\n                ],\n                &#039;quantity&#039; =&gt; &#091;\n                    &#039;type&#039; =&gt; Type::string ()\n                ],\n                &#039;price&#039; =&gt; &#091;\n                    &#039;type&#039; =&gt; Type::string ()\n                ],\n                &#039;special&#039; =&gt; &#091;\n                    &#039;type&#039; =&gt; Type::string ()\n                ]  \n            ]; }\n        ]);<\/pre>\n\n\n\n<p><strong>Step 7:<\/strong>  Define the Mutation Object Type in the controller file.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">  $MutationType = new ObjectType (&#091;\n            &#039;name&#039; =&gt; &#039;MutationType&#039;,\n            &#039;fields&#039;  =&gt; function () { return &#091;\n                &#039;addReview&#039; =&gt; &#091;\n                    &#039;type&#039; =&gt; Type::id (),\n                    &#039;args&#039; =&gt; &#091;\n                        &#039;product_id&#039; =&gt; Type::nonNull (Type::id ()),\n                        &#039;input&#039; =&gt; Type::nonNull (self::$ReviewInput)\n                    ],\n                    &#039;resolve&#039; =&gt; function ($root, $args) {\n                        $this-&gt;load-&gt;model (&#039;catalog\/review&#039;);\n                        return $this-&gt;model_catalog_review-&gt;addReview($args&#091;&#039;product_id&#039;], $args&#091;&#039;input&#039;]);\n                    }\n                ],\n              ];}\n           ]);<\/pre>\n\n\n\n<p>Mutation Object Type has a Field named &#8220;addReview&#8221; with a backed resolver function that returns the last added review id on the specific arguments via product_id, input using the &#8220;addReview&#8221;.<\/p>\n\n\n\n<p><strong>Step 8: <\/strong>  Mutation Object type is having two arguments one is &#8216;product_id&#8217; and the second one is &#8216;input&#8217;. Here Input argument will contain the required input parameters to add the review on the specific product.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">      static::$ReviewInput = new InputObjectType (&#091;\n            &#039;name&#039; =&gt; &#039;ReviewInput&#039;,\n            &#039;fields&#039;  =&gt; function () { return &#091;\n                &#039;name&#039; =&gt; &#091;\n                    &#039;type&#039; =&gt; Type::nonNull (Type::string ())\n                ],\n                &#039;rating&#039; =&gt; &#091;\n                    &#039;type&#039; =&gt; Type::nonNull (Type::int ())\n                ],\n                &#039;text&#039; =&gt; &#091;\n                    &#039;type&#039; =&gt; Type::nonNull (Type::string ())\n                ]\n            ]; }\n        ]);<\/pre>\n\n\n\n<p><strong>Step 9<\/strong>: At last, include the code for query execution.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\"> try {\n    $rawBody = file_get_contents(&#039;php:\/\/input&#039;);\n    $data = json_decode($rawBody ?: &#039;&#039;, true);\n      $requestString = $data&#091;&#039;query&#039;] ?? null;\n      $operationName = $data&#091;&#039;operation&#039;] ?? null;\n      $variableValues = $data&#091;&#039;variables&#039;] ?? null;\n    \n    if (!(is_object ($variableValues) || is_array($variableValues)))\n        $variableValues = json_decode($variableValues, True);\n        $rootValue = &#091;&#039;prefix&#039; =&gt; &#039;You said: &#039;];\n        $result = GraphQL::executeQuery($schema, $requestString, null,              $this, $variableValues);\n\n     } catch (\\Exception $e) {\n            $result = &#091;\n                &#039;error&#039; =&gt; &#091;\n                    &#039;message&#039; =&gt; $e\n                ]\n            ];\n        }\t\t\t\n\t\theader(&#039;Content-Type: application\/json; charset=UTF-8&#039;);\n\t\techo json_encode($result);\n\t}\n}\n\n?&gt;<\/pre>\n\n\n\n<p> GraphQL class has an <em>executeQuery<\/em> function that is used to process the Requested Query.  The ExecuteQuery function works along with root Value and return the Data as per defined type, field, and resolver functions.<br><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Execution of Graphql API <\/h2>\n\n\n\n<p>The GraphQL endpoint in Opencart is<strong>&nbsp;api\/graphql\/usage<em>.<\/em><\/strong><em>&nbsp;<\/em>To access the GraphQL URL, set the GraphQL endpoint by entering&nbsp;<strong>HTTP or https:\/\/&lt;opencart base-url&gt;index.php?route=api\/graphql\/usage<\/strong> .<\/p>\n\n\n\n<p>we used the postman for the execution of the query, you can also use another IDE.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1. Query Type<\/h3>\n\n\n\n<p>The query type is used for retrieving the data.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/query.png\"><img decoding=\"async\" width=\"910\" height=\"572\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/query.png\" alt=\"query\" class=\"wp-image-383757\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/query.png 910w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/query-300x189.png 300w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/query-250x157.png 250w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/query-768x483.png 768w\" sizes=\"(max-width: 910px) 100vw, 910px\" loading=\"lazy\" \/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">2. Mutation Type &#8211;<\/h2>\n\n\n\n<p>Mutation type query is used to modify the data or make some operation with the data.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/mutation.png\"><img decoding=\"async\" width=\"885\" height=\"573\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/mutation.png\" alt=\"mutation\" class=\"wp-image-383773\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/mutation.png 885w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/mutation-300x194.png 300w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/mutation-250x162.png 250w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/mutation-768x497.png 768w\" sizes=\"(max-width: 885px) 100vw, 885px\" loading=\"lazy\" \/><\/a><\/figure>\n\n\n\n<p><strong>Result<\/strong> &#8211; Navigate to the catalog-&gt;reviews tab at admin end, new review has been added to the product.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1200\" height=\"606\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/addreview-1200x606.png\" alt=\"addreview\" class=\"wp-image-383774\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/addreview-1200x606.png 1200w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/addreview-300x152.png 300w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/addreview-250x126.png 250w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/addreview-768x388.png 768w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/addreview.png 1273w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" loading=\"lazy\" \/><\/figure>\n\n\n\n<p>Thank You!<\/p>\n\n\n\n<p>If you need custom&nbsp;<a href=\"https:\/\/webkul.com\/opencart-development\/\" target=\"_blank\" rel=\"noreferrer noopener\">Opencart Development services<\/a>&nbsp;then feel free to&nbsp;<a href=\"https:\/\/webkul.com\/contacts\" target=\"_blank\" rel=\"noreferrer noopener\">reach us<\/a>&nbsp;and also explore our exclusive range of&nbsp;<a href=\"https:\/\/store.webkul.com\/OpenCart-Modules.html\" target=\"_blank\" rel=\"noreferrer noopener\">Opencart Extensions<\/a>.<\/p>\n\n\n\n<p>!! Have a Great Day Ahead !!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>OpenCart is an open-source eCommerce platform, based on PHP and MVC architecture for online merchants. Opencart provides a great number of features that are responsible to control your store. It allows a professional and reliable foundation from which to build a successful online store. This article describes how a developer can use GraphQL API in <a href=\"https:\/\/webkul.com\/blog\/opencart-graphql-api\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":525,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[305],"tags":[2071,590],"class_list":["post-380407","post","type-post","status-publish","format-standard","hentry","category-opencart","tag-opencart","tag-webkul"],"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 API in Opencart? - 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\/opencart-graphql-api\/\" \/>\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 API in Opencart? - Webkul Blog\" \/>\n<meta property=\"og:description\" content=\"OpenCart is an open-source eCommerce platform, based on PHP and MVC architecture for online merchants. Opencart provides a great number of features that are responsible to control your store. It allows a professional and reliable foundation from which to build a successful online store. This article describes how a developer can use GraphQL API in [...]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webkul.com\/blog\/opencart-graphql-api\/\" \/>\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=\"2023-05-29T03:58:35+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-06-06T06:28:37+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2023\/06\/graphql-1200x675.png\" \/>\n<meta name=\"author\" content=\"Sandhya Mishra\" \/>\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=\"Sandhya Mishra\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/webkul.com\/blog\/opencart-graphql-api\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/opencart-graphql-api\/\"},\"author\":{\"name\":\"Sandhya Mishra\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/ea8e30ea11c5b2953191b79a4bcac159\"},\"headline\":\"How to use GraphQL API in Opencart?\",\"datePublished\":\"2023-05-29T03:58:35+00:00\",\"dateModified\":\"2023-06-06T06:28:37+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/opencart-graphql-api\/\"},\"wordCount\":887,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/opencart-graphql-api\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2023\/06\/graphql-1200x675.png\",\"keywords\":[\"opencart\",\"webkul\"],\"articleSection\":[\"opencart\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/webkul.com\/blog\/opencart-graphql-api\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webkul.com\/blog\/opencart-graphql-api\/\",\"url\":\"https:\/\/webkul.com\/blog\/opencart-graphql-api\/\",\"name\":\"How to use GraphQL API in Opencart? - Webkul Blog\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/opencart-graphql-api\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/opencart-graphql-api\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2023\/06\/graphql-1200x675.png\",\"datePublished\":\"2023-05-29T03:58:35+00:00\",\"dateModified\":\"2023-06-06T06:28:37+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/webkul.com\/blog\/opencart-graphql-api\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webkul.com\/blog\/opencart-graphql-api\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/opencart-graphql-api\/#primaryimage\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/06\/graphql.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/06\/graphql.png\",\"width\":1920,\"height\":1080,\"caption\":\"graphql\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webkul.com\/blog\/opencart-graphql-api\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to use GraphQL API in Opencart?\"}]},{\"@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\/ea8e30ea11c5b2953191b79a4bcac159\",\"name\":\"Sandhya Mishra\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/70445b6b82958c3b345e220309c945da5f7cf1526b8d54cf8293d418a00bb370?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Feva.png&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/70445b6b82958c3b345e220309c945da5f7cf1526b8d54cf8293d418a00bb370?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Feva.png&r=g\",\"caption\":\"Sandhya Mishra\"},\"url\":\"https:\/\/webkul.com\/blog\/author\/sandhya-oc722\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to use GraphQL API in Opencart? - 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\/opencart-graphql-api\/","og_locale":"en_US","og_type":"article","og_title":"How to use GraphQL API in Opencart? - Webkul Blog","og_description":"OpenCart is an open-source eCommerce platform, based on PHP and MVC architecture for online merchants. Opencart provides a great number of features that are responsible to control your store. It allows a professional and reliable foundation from which to build a successful online store. This article describes how a developer can use GraphQL API in [...]","og_url":"https:\/\/webkul.com\/blog\/opencart-graphql-api\/","og_site_name":"Webkul Blog","article_publisher":"https:\/\/www.facebook.com\/webkul\/","article_published_time":"2023-05-29T03:58:35+00:00","article_modified_time":"2023-06-06T06:28:37+00:00","og_image":[{"url":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2023\/06\/graphql-1200x675.png","type":"","width":"","height":""}],"author":"Sandhya Mishra","twitter_card":"summary_large_image","twitter_creator":"@webkul","twitter_site":"@webkul","twitter_misc":{"Written by":"Sandhya Mishra","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/webkul.com\/blog\/opencart-graphql-api\/#article","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/opencart-graphql-api\/"},"author":{"name":"Sandhya Mishra","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/ea8e30ea11c5b2953191b79a4bcac159"},"headline":"How to use GraphQL API in Opencart?","datePublished":"2023-05-29T03:58:35+00:00","dateModified":"2023-06-06T06:28:37+00:00","mainEntityOfPage":{"@id":"https:\/\/webkul.com\/blog\/opencart-graphql-api\/"},"wordCount":887,"commentCount":0,"publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"image":{"@id":"https:\/\/webkul.com\/blog\/opencart-graphql-api\/#primaryimage"},"thumbnailUrl":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2023\/06\/graphql-1200x675.png","keywords":["opencart","webkul"],"articleSection":["opencart"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/webkul.com\/blog\/opencart-graphql-api\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/webkul.com\/blog\/opencart-graphql-api\/","url":"https:\/\/webkul.com\/blog\/opencart-graphql-api\/","name":"How to use GraphQL API in Opencart? - Webkul Blog","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/webkul.com\/blog\/opencart-graphql-api\/#primaryimage"},"image":{"@id":"https:\/\/webkul.com\/blog\/opencart-graphql-api\/#primaryimage"},"thumbnailUrl":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2023\/06\/graphql-1200x675.png","datePublished":"2023-05-29T03:58:35+00:00","dateModified":"2023-06-06T06:28:37+00:00","breadcrumb":{"@id":"https:\/\/webkul.com\/blog\/opencart-graphql-api\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webkul.com\/blog\/opencart-graphql-api\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/opencart-graphql-api\/#primaryimage","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/06\/graphql.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/06\/graphql.png","width":1920,"height":1080,"caption":"graphql"},{"@type":"BreadcrumbList","@id":"https:\/\/webkul.com\/blog\/opencart-graphql-api\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to use GraphQL API in Opencart?"}]},{"@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\/ea8e30ea11c5b2953191b79a4bcac159","name":"Sandhya Mishra","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/70445b6b82958c3b345e220309c945da5f7cf1526b8d54cf8293d418a00bb370?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Feva.png&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/70445b6b82958c3b345e220309c945da5f7cf1526b8d54cf8293d418a00bb370?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Feva.png&r=g","caption":"Sandhya Mishra"},"url":"https:\/\/webkul.com\/blog\/author\/sandhya-oc722\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/380407","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\/525"}],"replies":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/comments?post=380407"}],"version-history":[{"count":72,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/380407\/revisions"}],"predecessor-version":[{"id":385773,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/380407\/revisions\/385773"}],"wp:attachment":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media?parent=380407"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/categories?post=380407"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/tags?post=380407"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}