Download the PHP package neutromelabs/magento2-ssr-graphql without Composer
On this page you can find all versions of the php package neutromelabs/magento2-ssr-graphql. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download neutromelabs/magento2-ssr-graphql
More information about neutromelabs/magento2-ssr-graphql
Files in neutromelabs/magento2-ssr-graphql
Package magento2-ssr-graphql
Short Description Allows to preload graphql queries at the render time
License GPL-3.0-or-later
Informations about the package magento2-ssr-graphql
There should not be one to choose between PHP and GraphQL.
Revolutionize your customer's experience with the best from both.
Magento 2 SSR GraphQL Module
Adds SSR GraphQL resolving capabilities to any Magento 2 frontend. Compatible with any theme. Works best with AlpineJS.
Overview
The idea is to write a normal GraphQL query
, (which will be used on the frontend
via JS,) AND automatically preload it's response
at the page render,
providing JS code with instant data
/errors
- without executing the "first" Ajax request.
Then, JS should operate as normal, with the access both to the query
string,
ssr
data (variables, response) and simplified fetch()
, to repeat the query, optionally passing new parameters.
Where To Use
Anywhere on your pages, when the same [available via GraphQL] content needs to be available to the customer at the page render time (PHP), while could be updated later (JS).
Typical use-cases:
- pagination/lazy-load - the first set of the items could be preloaded at the page render,
and paginated later, with the same GraphQL
query
and differentvariables
- double-check - the "Add To Cart" button is rendered if the product is available for sale,
and the same query is
refresh
-ed on click, to prevent stock races
How To Use
Simple example - paginated product list, over GraphQL.
-
The
phtml
view must call themakeSsrGqlCall(query, variables)
method, from theNeutromeLabs\SsrGraphql\ViewModel\SsrGraphqlViewModel
view model, which returns JS fragment string representingobject
, to insert into the page html script tag. -
While rendering this page, Magento will resolve the passed query and provide
ssrGqlExampleObject
JS variable with a special SSR GraphQLobject
- The data from the JS variable could be presented to the customer right after the page load, with no "loaders" on the screen. Then those data could be updated, without the need to repeat the same GraphQL query again
See the full example at https://your-magento-instance.test/ssrgql/example
,
and src/SsrGraphql/view/frontend/templates/example/1.phtml