WPGraphQL WooCommerce (WooGraphQL), is a WPGraphQL and WooCommerce extension. It exposes WooCommerce and its functionality to the GraphQL server created by WPGraphQL. Making creating well-written and robust e-commerce applications, much easier.
What Can It Do?
What Can It Do?
Query for store data from WooCommerce, like products, orders, coupons, items in the shopping cart, and much more. Retrieve only the data needed for the UI, and keep requests speedy and efficient.
Why Use WooGraphQL?
WooGraphQL has neither the team nor the development hours that WooCommerce (WC) REST does, but there are advantages in both application performance and design.
GraphQL vs REST
- The shapes of the data object returned by WC REST are limited and more times than not include data not required by the client at the time of the request. GraphQL queries can be designed to only retrieve data needed to inflate the UI.
- WC REST relies heavily on page-based pagination, as do most WordPress REST APIs. If the store has a large number of products, database requests with taking much longer to process. WooGraphQL manipulates WordPress’ core querying functions and implements cursor-based pagination, which handles a large number of products more efficiently.
- WC REST doesn’t include any cart endpoints for manipulating the cart, meaning a cart has to be implemented client-side, which is no small task. Session-specific utilities are provided by WooGraphQL, so the WooCommerce’s can continue managing the end-user’s session for the most part.
- Although WC REST doesn’t provide any support for managing the user session, alternative options for doing this task do exist; however, their usage can be limited to applications of the same origin as the WordPress installation. This is because WooCommerce uses HTTP cookies to store user session tokens by default. WooGraphQL provides a utility that changes this behavior during GraphQL requests by encrypting the session token as JWT to be retrieve is a query or from a mutation request HTTP response that altered the session.