How to use GraphQL with Magento2?

What is GraphQl ?

GraphQL is a query language for APIs and a runtime for fulfilling those queries with your existing data. GraphQL provides a complete and understandable description of the data in your API, gives clients the power to ask for exactly what they need and nothing more.
developed internally by Facebook in 2012 before being publicly released in 2015. Magento implements GraphQL to provide an alternative to REST and SOAP web APIs for frontend development.
GraphQL included in Magento 2.3.0

Magento2 + GraphQL

With the lastest magento release 2.3 include the GraphQl
Lets have a look on the core magento code

We can see the code in magento core and schema defined in the file schema.graphqls.

Lets Check how to use ?

Step1 – Lets Install the extension to test graphql
Google addon – https://chrome.google.com/webstore/detail/chromeiql/fkkiamalmpiidkljmicmjfbieiclmeij
Step2 – add endpoint like – http://domain.com/index.php/graphql
Step3 – add parameter and run and it will output like screenshot.

Good practical use cases:

  • Backend Magento -> FrontendĀ App (iOS, Android)
  • 3D Planner for a Living Room -> use Magento Checkout and Backend for the Products

Next – we will check the Custom module using Graphql in Magento 2

References

https://devdocs.magento.com/guides/v2.3/graphql/index.html

https://community.magento.com/t5/Magento-DevBlog/Why-GraphQL-Is-Interesting-for-Magento-2/ba-p/71539

 

Please follow and like us:

Author: Yogi

Full Stack Developer, Blogger, Instructor I'm a professional developer living in the beautiful Chandigarh. By day I'm an enterprise software developer.

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll UpScroll Up