-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Metafield value support or documentation #25
Comments
FYI @surma @nickwesselman |
Hm the problem is that the metafield really is just a string, and you as the developer can decide not only what data you store in there, but also in which format. We usually recommend and use JSON, but it could technically be anything else. If you look at the example in this repo, you can see that we are manually decoding it using That being said, we have talked about making JSON-encoded metafields the default case and providing more help to handle those. |
This is fair. The example you provided looks nice! It gives folks working with metafields a great example and seems less complex than the way I handled it as per my post. It might not be apparent when first working with functions and using Overall I think viewing the generated types and knowing to look at the metafield example fixes my original confusion. |
I found it confusing to use the
shopify_function
crate for the metafield data types being passed between Shopify and the Function.One issue was the inability to preview / see the generated types, which I see an existing issue for: #17
Here is an example of a function API that sends metafields: https://shopify.dev/docs/api/functions/reference/order-routing-location-rule/graphql/common-objects/metafield
The metafield value is passed from Shopify to the function as a string and I found the support for this in
shopify_function
not clear.When not using this crate and generating types myself in
api.rs
, I ended up doing something like this to handle the metafield format:The text was updated successfully, but these errors were encountered: