-
Notifications
You must be signed in to change notification settings - Fork 50
Description
Hey folks -
I am working on an app that has, as part of its offerings, a commerce component powered by shopify, and I have been hard at work building a native experience using flutter.
Absolutely love this package, but the missing metafield support caused enough pain (and drift between the web and mobile experience) that I have decided to uncomment it out and do the needed work to enable them again.
At a high level, this is how it works. I have added the following to a handful of gql queries:
query($metafields: [HasMetafieldsIdentifier!]!, //...
//...
node {
metafields(identifiers: $metafields) {
id
type
key
namespace
value
description
reference {
... on MediaImage {
image {
originalSrc
url
id
}
}
}
}
This, combined with extending those functions that call the queries to include an optional list of MetafieldIdentifiers which get JSONized and sent through the $metafields variable, allows us to retrieve them. From there some modifications were needed to the _getMetafieldList function in the product model to map the value locations appropriately, and the reference field, for now, has been left as a Map<String, dynamic> as I suspect different content types will demand some flexibility there.
This allows me to do calls like this:
try {
final products = await _store.getProductsByIds(
[id],
metafields: [
MetafieldIdentifier(key: 'content-about-the-brand', namespace: 'pim'),
MetafieldIdentifier(key: 'pdp_content_image_1_mobile', namespace: 'custom'),
MetafieldIdentifier(key: 'pdp_content_image_2_mobile', namespace: 'custom'),
MetafieldIdentifier(key: 'pdp_content_image_3_mobile', namespace: 'custom'),
//...
],
);And get a list of metafields back with the product, or collection, or similar. I have done this for products by id, and allproductsincollection, and will be extending it to collections shortly.
So before I finish the swing and update all of the queries, functions, etc. to provide this support, does anyone have any comments or suggestions so I don't go through the arduous process of updating everything in this direction and building my app against it, only for me to have missed something critical that would dramatically change how it works?
Looking forward to contributing to this project, one of my favorite in the flutter community.