Skip to content

Commit fa58e24

Browse files
authored
Merge pull request #49 from Shopify/scalars/date-times
Add date and time scalars
2 parents 0ae9137 + b0cb52f commit fa58e24

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

shopify_function/src/scalars.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,8 @@ pub use decimal::Decimal;
88
pub type Void = ();
99
pub type URL = String;
1010
pub type Handle = String;
11+
12+
pub type Date = String;
13+
pub type DateTime = String;
14+
pub type DateTimeWithoutTimezone = String;
15+
pub type TimeWithoutTimezone = String;

shopify_function_macro/src/lib.rs

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,16 @@ fn extract_shopify_function_return_type(ast: &syn::ItemFn) -> Result<&syn::Ident
168168
use syn::*;
169169

170170
let ReturnType::Type(_arrow, ty) = &ast.sig.output else {
171-
return Err(Error::new_spanned(&ast.sig, "Shopify Functions require an explicit return type"))
171+
return Err(Error::new_spanned(
172+
&ast.sig,
173+
"Shopify Functions require an explicit return type",
174+
));
172175
};
173176
let Type::Path(path) = ty.as_ref() else {
174-
return Err(Error::new_spanned(&ast.sig, "Shopify Functions must return a Result"))
177+
return Err(Error::new_spanned(
178+
&ast.sig,
179+
"Shopify Functions must return a Result",
180+
));
175181
};
176182
let result = path.path.segments.last().unwrap();
177183
if result.ident != "Result" {
@@ -181,7 +187,10 @@ fn extract_shopify_function_return_type(ast: &syn::ItemFn) -> Result<&syn::Ident
181187
));
182188
}
183189
let PathArguments::AngleBracketed(generics) = &result.arguments else {
184-
return Err(Error::new_spanned(result, "Shopify Function Result is missing generic arguments"))
190+
return Err(Error::new_spanned(
191+
result,
192+
"Shopify Function Result is missing generic arguments",
193+
));
185194
};
186195
if generics.args.len() != 1 {
187196
return Err(Error::new_spanned(
@@ -190,10 +199,16 @@ fn extract_shopify_function_return_type(ast: &syn::ItemFn) -> Result<&syn::Ident
190199
));
191200
}
192201
let GenericArgument::Type(ty) = generics.args.first().unwrap() else {
193-
return Err(Error::new_spanned(generics, "Shopify Function Result expects a type"))
202+
return Err(Error::new_spanned(
203+
generics,
204+
"Shopify Function Result expects a type",
205+
));
194206
};
195207
let Type::Path(path) = ty else {
196-
return Err(Error::new_spanned(result, "Unexpected result type for Shopify Function Result"))
208+
return Err(Error::new_spanned(
209+
result,
210+
"Unexpected result type for Shopify Function Result",
211+
));
197212
};
198213
Ok(&path.path.segments.last().as_ref().unwrap().ident)
199214
}

0 commit comments

Comments
 (0)