Skip to content

Commit 8770176

Browse files
authored
Merge pull request #498 from Shopify/jb/shopify_function-crate-v0.8
Update shopify_function crate to v0.8.0
2 parents b84b565 + c3b4e96 commit 8770176

File tree

47 files changed

+366
-388
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+366
-388
lines changed

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ node_modules
88
# These files are generated from Shopify CLI templating and should not be committed to this repo
99

1010
## Extensions
11-
**/.output.graphql
1211
**/input.graphql
1312
*/rust/**/Cargo.lock
1413
*/rust/**/Cargo.toml

Cargo.lock

+11-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
/target
22
Cargo.lock
3-
*.output.graphql

checkout/rust/cart-checkout-validation/default/Cargo.toml.liquid

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ rust-version = "1.62"
77
[dependencies]
88
serde = { version = "1.0.13", features = ["derive"] }
99
serde_json = "1.0"
10-
shopify_function = "0.7.0"
11-
graphql_client = "0.13.0"
10+
shopify_function = "0.8.0"
11+
graphql_client = "0.14.0"
1212

1313
[profile.release]
1414
lto = true
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
/target
22
Cargo.lock
3-
*.output.graphql

checkout/rust/cart-transform/bundles/Cargo.toml.liquid

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ rust-version = "1.62"
88
serde = { version = "1.0.13", features = ["derive"] }
99
serde_with = "1.13.0"
1010
serde_json = "1.0"
11-
shopify_function = "0.7.0"
12-
graphql_client = "0.13.0"
11+
shopify_function = "0.8.0"
12+
graphql_client = "0.14.0"
1313

1414
[profile.release]
1515
lto = true
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
/target
22
Cargo.lock
3-
*.output.graphql

checkout/rust/cart-transform/default/Cargo.toml.liquid

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ rust-version = "1.62"
88
serde = { version = "1.0.13", features = ["derive"] }
99
serde_with = "1.13.0"
1010
serde_json = "1.0"
11-
shopify_function = "0.7.0"
12-
graphql_client = "0.13.0"
11+
shopify_function = "0.8.0"
12+
graphql_client = "0.14.0"
1313

1414
[profile.release]
1515
lto = true
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
/target
22
Cargo.lock
3-
*.output.graphql

checkout/rust/delivery-customization/default/Cargo.toml.liquid

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ rust-version = "1.62"
77
[dependencies]
88
serde = { version = "1.0.13", features = ["derive"] }
99
serde_json = "1.0"
10-
shopify_function = "0.7.0"
11-
graphql_client = "0.13.0"
10+
shopify_function = "0.8.0"
11+
graphql_client = "0.14.0"
1212

1313
[profile.release]
1414
lto = true
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
/target
22
Cargo.lock
3-
*.output.graphql

checkout/rust/order-submission-rule/default/Cargo.toml.liquid

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ rust-version = "1.62"
77
[dependencies]
88
serde = { version = "1.0.13", features = ["derive"] }
99
serde_json = "1.0"
10-
shopify_function = "0.7.0"
11-
graphql_client = "0.13.0"
10+
shopify_function = "0.8.0"
11+
graphql_client = "0.14.0"
1212

1313
[profile.release]
1414
lto = true
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
/target
22
Cargo.lock
3-
*.output.graphql

checkout/rust/payment-customization/default/Cargo.toml.liquid

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ rust-version = "1.62"
77
[dependencies]
88
serde = { version = "1.0.13", features = ["derive"] }
99
serde_json = "1.0"
10-
shopify_function = "0.7.0"
11-
graphql_client = "0.13.0"
10+
shopify_function = "0.8.0"
11+
graphql_client = "0.14.0"
1212

1313
[profile.release]
1414
lto = true
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
/target
22
Cargo.lock
3-
*.output.graphql

discounts/rust/discounts-allocator/default/Cargo.toml.liquid

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ rust-version = "1.62"
77
[dependencies]
88
serde = { version = "1.0.13", features = ["derive"] }
99
serde_json = "1.0"
10-
shopify_function = "0.7.0"
11-
graphql_client = "0.13.0"
10+
shopify_function = "0.8.0"
11+
graphql_client = "0.14.0"
1212

1313
[profile.release]
1414
lto = true
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
/target
22
Cargo.lock
3-
*.output.graphql

discounts/rust/order-discounts/default/Cargo.toml.liquid

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ rust-version = "1.62"
77
[dependencies]
88
serde = { version = "1.0.13", features = ["derive"] }
99
serde_json = "1.0"
10-
shopify_function = "0.7.0"
11-
graphql_client = "0.13.0"
10+
shopify_function = "0.8.0"
11+
graphql_client = "0.14.0"
1212

1313
[profile.release]
1414
lto = true
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
/target
22
Cargo.lock
3-
*.output.graphql

discounts/rust/product-discounts/default/Cargo.toml.liquid

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ rust-version = "1.62"
77
[dependencies]
88
serde = { version = "1.0.13", features = ["derive"] }
99
serde_json = "1.0"
10-
shopify_function = "0.7.0"
11-
graphql_client = "0.13.0"
10+
shopify_function = "0.8.0"
11+
graphql_client = "0.14.0"
1212

1313
[profile.release]
1414
lto = true
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
/target
22
Cargo.lock
3-
*.output.graphql

discounts/rust/shipping-discounts/default/Cargo.toml.liquid

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ rust-version = "1.62"
77
[dependencies]
88
serde = { version = "1.0.13", features = ["derive"] }
99
serde_json = "1.0"
10-
shopify_function = "0.7.0"
11-
graphql_client = "0.13.0"
10+
shopify_function = "0.8.0"
11+
graphql_client = "0.14.0"
1212

1313
[profile.release]
1414
lto = true
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
/target
22
Cargo.lock
3-
*.output.graphql

order-routing/rust/fulfillment-constraints/default/Cargo.toml.liquid

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ rust-version = "1.62"
77
[dependencies]
88
serde = { version = "1.0.13", features = ["derive"] }
99
serde_json = "1.0"
10-
shopify_function = "0.7.0"
11-
graphql_client = "0.13.0"
10+
shopify_function = "0.8.0"
11+
graphql_client = "0.14.0"
1212

1313
[profile.release]
1414
lto = true
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
/target
22
Cargo.lock
3-
.output.graphql

order-routing/rust/local-pickup-delivery-option-generators/default/Cargo.toml.liquid

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ rust-version = "1.62"
77
[dependencies]
88
serde = { version = "1.0.13", features = ["derive"] }
99
serde_json = "1.0"
10-
shopify_function = "0.7.0"
11-
graphql_client = "0.13.0"
10+
shopify_function = "0.8.0"
11+
graphql_client = "0.14.0"
1212

1313
[profile.release]
1414
lto = true
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,7 @@
1-
use shopify_function::prelude::*;
2-
use shopify_function::Result;
1+
use std::process;
2+
pub mod run;
33

4-
use serde::{Deserialize, Serialize};
5-
6-
generate_types!(
7-
query_path = "./input.graphql",
8-
schema_path = "./schema.graphql"
9-
);
10-
11-
#[derive(Serialize, Deserialize, Default, PartialEq)]
12-
struct Config {}
13-
14-
#[shopify_function]
15-
fn function(_input: input::ResponseData) -> Result<output::FunctionResult> {
16-
let operations = vec![output::Operation {
17-
add: output::LocalPickupDeliveryOption {
18-
title: Some("Main St.".to_string()),
19-
cost: Some(Decimal(1.99)),
20-
pickup_location: output::PickupLocation {
21-
location_handle: "2578303".to_string(),
22-
pickup_instruction: Some("Usually ready in 24 hours.".to_string()),
23-
},
24-
},
25-
}];
26-
27-
// Build operations based on the input query response here.
28-
29-
Ok(output::FunctionResult { operations })
4+
fn main() {
5+
eprintln!("Please invoke a named export.");
6+
process::exit(1);
307
}
31-
32-
#[cfg(test)]
33-
mod tests;

order-routing/rust/local-pickup-delivery-option-generators/default/src/tests.rs order-routing/rust/local-pickup-delivery-option-generators/default/src/run.rs

+51-21
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,40 @@
1-
use super::*;
2-
use shopify_function::{run_function_with_input, Result};
3-
4-
#[test]
5-
fn test_result_contains_no_operations() -> Result<()> {
6-
let result = run_function_with_input(
7-
function,
8-
r#"
1+
use shopify_function::prelude::*;
2+
use shopify_function::Result;
3+
4+
use serde::{Deserialize, Serialize};
5+
6+
#[derive(Serialize, Deserialize, Default, PartialEq)]
7+
struct Config {}
8+
9+
#[shopify_function_target(query_path = "src/run.graphql", schema_path = "schema.graphql")]
10+
fn run(_input: input::ResponseData) -> Result<output::FunctionRunResult> {
11+
let operations = vec![output::Operation {
12+
add: output::LocalPickupDeliveryOption {
13+
title: Some("Main St.".to_string()),
14+
cost: Some(Decimal(1.99)),
15+
pickup_location: output::PickupLocation {
16+
location_handle: "2578303".to_string(),
17+
pickup_instruction: Some("Usually ready in 24 hours.".to_string()),
18+
},
19+
},
20+
}];
21+
22+
// Build operations based on the input query response here.
23+
24+
Ok(output::FunctionRunResult { operations })
25+
}
26+
27+
#[cfg(test)]
28+
mod tests {
29+
use super::run::*;
30+
use super::*;
31+
use shopify_function::{run_function_with_input, Result};
32+
33+
#[test]
34+
fn test_result_contains_no_operations() -> Result<()> {
35+
let result = run_function_with_input(
36+
run,
37+
r#"
938
{
1039
"cart": {
1140
"lines": [
@@ -42,21 +71,22 @@ fn test_result_contains_no_operations() -> Result<()> {
4271
}
4372
}
4473
"#,
45-
)?;
74+
)?;
4675

47-
let operations = vec![output::Operation {
48-
add: output::LocalPickupDeliveryOption {
49-
title: Some("Main St.".to_string()),
50-
cost: Some(Decimal(1.99)),
51-
pickup_location: output::PickupLocation {
52-
location_handle: "2578303".to_string(),
53-
pickup_instruction: Some("Usually ready in 24 hours.".to_string()),
76+
let operations = vec![output::Operation {
77+
add: output::LocalPickupDeliveryOption {
78+
title: Some("Main St.".to_string()),
79+
cost: Some(Decimal(1.99)),
80+
pickup_location: output::PickupLocation {
81+
location_handle: "2578303".to_string(),
82+
pickup_instruction: Some("Usually ready in 24 hours.".to_string()),
83+
},
5484
},
55-
},
56-
}];
85+
}];
5786

58-
let expected = crate::output::FunctionResult { operations };
87+
let expected = output::FunctionRunResult { operations };
5988

60-
assert_eq!(result, expected);
61-
Ok(())
89+
assert_eq!(result, expected);
90+
Ok(())
91+
}
6292
}
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
/target
22
Cargo.lock
3-
*.output.graphql

order-routing/rust/location-rules/default/Cargo.toml.liquid

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ rust-version = "1.62"
77
[dependencies]
88
serde = { version = "1.0.13", features = ["derive"] }
99
serde_json = "1.0"
10-
shopify_function = "0.7.0"
11-
graphql_client = "0.13.0"
10+
shopify_function = "0.8.0"
11+
graphql_client = "0.14.0"
1212

1313
[profile.release]
1414
lto = true

0 commit comments

Comments
 (0)