(input: input::ResponseData)
| 9 | |
| 10 | #[shopify_function_target(query_path = "src/run.graphql", schema_path = "schema.graphql")] |
| 11 | fn run(input: input::ResponseData) -> Result<output::FunctionRunResult> { |
| 12 | let mut errors = Vec::new(); |
| 13 | |
| 14 | if input |
| 15 | .cart |
| 16 | .lines |
| 17 | .iter() |
| 18 | .map(|line| line.quantity) |
| 19 | .any(|quantity| quantity > 1) |
| 20 | { |
| 21 | errors.push(output::FunctionError { |
| 22 | localized_message: "Not possible to order more than one of each".to_owned(), |
| 23 | target: "$.cart".to_owned(), |
| 24 | }) |
| 25 | } |
| 26 | Ok(output::FunctionRunResult { errors }) |
| 27 | } |
| 28 | |
| 29 | #[cfg(test)] |
| 30 | mod tests { |
nothing calls this directly
no outgoing calls
no test coverage detected