magento-research / pwa-devdocs

Developer documentation for the Magento PWA project
Open Software License 3.0
14 stars 12 forks source link

Clarification request on Venia module and Magento backend role #36

Closed leonvisscher closed 6 years ago

leonvisscher commented 6 years ago

This issue is a:

[ ] Bug [ ] New Topic Request [ X ] Topic Clarification Request [ ] New Feature Request [ ] Other

Description:

I've got the Venia theme up and running locally. I've implemented some Redux functionality making requests to the GraphQL API. Everything is working fine, but I don't really understand the purpose of the module shipped with the Venia theme. I thought this PWA should be completely headless and all communication should go through the API.

There is also reference in the MagentoRootComponentsPlugin to 'the Magento backend':

/**
 * @description webpack plugin that creates chunks for each
 * individual RootComponent in a store, and generates a manifest
 * with data for consumption by the backend.
 */

What is meant by this data consumption.

I am a front-end developer who is quiet new to Magento so that may be a reason that I don't directly see purpose for this module.

Expected Result:

I will understand the purpose of these aspects of PWA studio.

DrewML commented 6 years ago

Hey @leon0v. Thanks for trying things out!


I thought this PWA should be completely headless and all communication should go through the API.

That's currently not the goal for this project. It will be entirely possible for community libraries to make PWA Studio into a headless solution, but the current plans for it OOTB will server render the application shell from the Magento 2 PHP app.

The Magento application is currently necessary for the following bits of functionality:

  1. Server-rendered app shell with proper meta information in the <head /> of the document for each page
  2. Ability to dynamically assign a RootComponent to an entity or group of entities, without requiring a deployment
  3. Embedding GraphQL payloads into the initial server render, without requiring a round trip to the API post app-init on the client-side

What is meant by this data consumption.

In a typical React application, a route pattern is married to 1 component. So you could say the /products route links to the Product.js component. However, this doesn't scale well for Magento's use-cases. You may want to have 15 different types of product pages that will be used for different types of products. In fact, you may want a specific SKU to use a certain type of product page, but only between a defined date/time range.

The manifest of all RootComponent implementations is provided to the backend so that a store owner can make these types of decisions and schedules without requiring a full deployment. Each individual RootComponent is compiled into its own optimized bundle that the client-side can load when needed.

jcalcaben commented 6 years ago

Topic content revised in #38

See: https://magento-research.github.io/pwa-devdocs/venia-pwa-concept/

leonvisscher commented 6 years ago

@DrewML @jcalcaben Thanks for explaining and updating the docs.