v1.1.1: Metafield, Enum types are not supported
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
Research direction
Start with the custom_scalar_overrides path, the #[shopify_function] macro, and the internal shopify_function::wasm_api::Deserialize trait described in the issue; compare their behavior between versions 0.8.0 and 1.1.1. Done means enum-containing metafield JSON can be deserialized and custom input types remain usable without requiring unsupported internal trait behavior.
Written by the indexing model from the issue text.
Description
The issue is described in detail, with examples, here:
https://community.shopify.dev/t/rust-shopify-function-crate-1-1-1-enum-deserialization-limitation/21739
In version 0.8.0, it was possible to pass fully custom input types into a function (while still using the generated types for the function's output):
use serde::Deserialize;
use shopify_function::prelude::*;
use shopify_function::Result;
#[derive(Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct InputData {
pub discount_node: InputDiscountNode,
pub presentment_currency_rate: Decimal,
pub cart: InputCart,
}
#[shopify_function_target(query_path = "blank.graphql", schema_path = "schema.graphql")]
fn run(input: InputData) -> Result<output::FunctionRunResult> {
...
}
This way, I could separately describe the structure of all input data needed by my function, including the JSON from a metafield (which is large, complex, and contains many Enums).
It worked efficiently and kept the code maintainable.
In version 1.1.1, the idea seems to have been to make things easier via custom_scalar_overrides, so that it would be enough to just describe the JSON structure and have it integrated into the generated types.
But it doesn't work if my JSON uses Enums: Error: Enum types are not supported for deriving Deserialize
At the same time, the trick of overriding the Input type, as in the old version, doesn't work anymore either:
error[E0277]: the trait bound `InputData: shopify_function::shopify_function_wasm_api::Deserialize` is not satisfied
Obviously, the #[shopify_function] macro checks that the input type implements the internal trait shopify_function::wasm_api::Deserialize, and plain serde::Deserialize is not enough.
But the internal shopify_function::wasm_api::Deserialize trait cannot handle Enums.
So, I really hope this issue will be addressed in future releases, because I'd prefer not to abandon Enums or write massive "workarounds" just for the sake of migrating.
- Dominant language
- Rust
- Stars
- 47
- Forks
- 9
- Avg merge
- 1h 53m
- Merged PRs (30d)
- 2
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.
More from Shopify/shopify-function-rust
-
Difficulty 1/5 Under an hour Newbie friendliness 58/100
Shopify/shopify-function-rust#132 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 52/100
-
Difficulty 4/5 3-5 days Newbie friendliness 38/100
Shopify/shopify-function-rust#25 · 3 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 30/100
All issues in Shopify/shopify-function-rust
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
gitbutlerapp/gitbutler#15998 · 1 comment ·
-
bug triage:deciding
Difficulty 1/5 Under an hour Newbie friendliness 88/100
open-telemetry/otel-arrow#4132 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100