Shopify / Shopify/shopify-function-rust
Metafield value support or documentation
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 47
- Forks
- 9
- Avg merge
- 1h 53m
- Merged PRs (30d)
- 2
Description
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: https://github.com/Shopify/shopify-function-rust/issues/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:
pub struct Metafield {
pub value: Option<String>,
}
pub struct Configuration {
pub value: Option<ExampleGroups>,
}
impl Configuration {
fn from_str(value: &str) -> Self {
// ExampleGroups::from_str constructs the JSON from the metafield string value
Configuration { value: Some(ExampleGroups::from_str(&value)) }
}
fn default() -> Self {
Configuration {
value: None,
}
}
}
pub fn parse_function_configuration_value(metafield: Option<Metafield>) -> Configuration {
match metafield.and_then(|m| m.value) {
Some(value) => Configuration::from_str(&value),
None => Configuration::default(),
}
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the shopify_function crate's metafield handling and the generated types concern in issue #17. Compare this with the referenced Shopify Function API example and the custom types shown in api.rs; done should be a clear documented path for handling metafield values, or a defined support change if documentation is insufficient.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- api
- Issue type
- Documentation
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100