Question

What is GraphQl in Magento2? Why use GraphQl. I want to know detail about GraphQl.

Was it helpful?

Solution

As magento is using "PWA" it is also adding "GraphQL API" for providing front-end development side api alternative of "REST/SOAP" as "GraphQL" api.

GraphQL

GraphQL is a query language for using APIs.

With the rise of the PWA, there is a need to get smaller amounts of data and to make fewer API requests.

GraphQL’s query language makes this possible by allowing the requestor to request a limited subset of attributes to be returned about an entity (significantly smaller responses) and allows you to chain requests (smaller number of requests).

Magento currently supports REST and SOAP API requests that use Service Contracts.

However, to support GraphQL, Magento is writing an entirely new layer that interfaces directly to the Query API. The GraphQL implementation will be the underpinnings on how a PWA frontend will retrieve the data it needs.

GraphQL in Magento

enter image description here

For detail understanding with PWA, REST API and GraphQL relation you can check below answer.

What is Progressive Web Apps, or PWAs in Magento 2?

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top