graphcommerce-org / graphcommerce

GraphCommerce® is a headless storefront replacement for Magento 2 (PWA), that delivers a faster, better user experience. Fully customizable (React, Next.js) and open-source.
https://www.graphcommerce.org
Other
306 stars 71 forks source link

Hygraph schema structure simplifications #1922

Open paales opened 1 year ago

paales commented 1 year ago

Describe the feature you'd like to request

We'd like to simplify the Hygraph schema by leveraging a 'Variant' system instead of separate models for rows. This is an extension of https://github.com/graphcommerce-org/graphcommerce/pull/1912

Describe the solution you'd like

https://github.com/graphcommerce-org/graphcommerce/pull/1912#discussion_r1175376363

With the current introduction of the Hygraph schema migration system we can start assuming the Hygraph schema exists in a certain format. We can assume the Page and DynamicRow components exist, this means that queries do not need to be in the example directory, but can be moved to a hygraph-content package or something (for now we can re-use the old graphcms-ui package).

The goal of the hygraph-content package should be: Make sure the schema is locked for the current models except for specific project specific implementations.

Asset (alt field) DynamicRow Page PageLink RowColumnOne (to be renamed to RowText) RowLinks Footer (to be renamed to Settings) Components:

AND Number OR Text Enums:

DynamicRowConditionNumberOperator DynamicRowPlacement MetaRobots RowLinksVariants RowProductVariants And assume the following Row components are 'project specific' (need to be kept in the examples directory):

RowBlogContent (to be migrated to RowText) RowButtonLinkList (already deprecated) RowColumnThree (to be deprecated) RowColumnTwo (to be deprecated) RowContentLinks (already deprecated) RowHeroBanner (to be deprecated, replace with a variant on RowLinks) RowQuote (to be deprecated, replace with RowText with a blockquote) RowServiceOptions (to be deprecated, replace with a variant on RowLinks) RowSpecialBanner (to be deprecated??) Usps (to be deprecated??, replace with RowLinks variant?) This of course is a way bigger project than the current implementation here, but it sets the changes that need to be made before the next major release.


After this comment we've had further discussions to simplify this even more, if we'd add an Asset field to RowLinks we could use it for even more cases.

paales commented 1 year ago

Also after this simplification we'd like to offer a declarative Hygraph schema so we can build libraries instead of keeping everything locally.

paales commented 1 year ago

Useless RowProduct entries

In the above post we didn't mention the RowProduct model, which is a bit of an odd one, because it requires external data to be passed for the row to actually display something useful.

The RowProduct used for a product are fairly empty as they only use the title of the RowProduct and nothing else, all other information is provided by the actual product.

Non product misusages

And second it isn't really a component that only renders information about a product, because it is also used to render information about categories on the homepage (home-product-backstory and home-swipable). So in it's current form it is more a RowMagentoProductOrCategory.

Although this being the case, there currently is no way to define which category or product is used to render a RowProduct.

The product page currently has a <ProductPageDescription /> which isn't rendered using RowProduct, and it also has USPS's which are a separate model.

Possible solutions

Create a RowReference model which allows you to create a reference to an external entity.

The actual data loading happens on the next.js side. Although Hygraph supports federated content, it can not do so transparently (it prefixes everything so all our fragments and code can't be used to query information that way).

paales commented 1 year ago

Rows are scoped to a single RowRenderer

Currently we are limited in scope where to put Hygraph content: We have a defined RowRenderer in a single location and we are able to influence this location, but not other locations like:

It might be interesting to explore more size render sizes:

Proposed solution

paales commented 1 year ago
paales commented 1 year ago

Renamen Dynamic Row fields: