Refactor vars! macro position [skip ci]

This commit is contained in:
tyranron 2022-06-08 10:50:47 +02:00
parent b28acbd96d
commit e347f25718
No known key found for this signature in database
GPG key ID: 762E144FB230A4F0
4 changed files with 86 additions and 82 deletions
juniper/src

View file

@ -2,9 +2,10 @@ use crate::{behavior, resolve};
pub use crate::{ pub use crate::{
ast::InputValue, ast::InputValue,
macros::{input_value, value}, macros::{input_value, value, vars},
resolve::Type, resolve::Type,
value::Value, value::Value,
executor::Variables,
}; };
pub trait Interface<S> pub trait Interface<S>

View file

@ -76,7 +76,7 @@ pub use crate::{
introspection::IntrospectionFormat, introspection::IntrospectionFormat,
macros::{ macros::{
helper::subscription::{ExtractTypeFromStream, IntoFieldResult}, helper::subscription::{ExtractTypeFromStream, IntoFieldResult},
input_value as graphql_input_value, value as graphql_value, input_value as graphql_input_value, value as graphql_value, vars as graphql_vars,
}, },
parser::{ParseError, ScalarToken, Spanning}, parser::{ParseError, ScalarToken, Spanning},
schema::{ schema::{

View file

@ -8,8 +8,7 @@ pub mod reflect;
mod input_value; mod input_value;
mod value; mod value;
#[macro_use] mod vars;
mod graphql_vars;
#[doc(inline)] #[doc(inline)]
pub use self::{input_value::input_value, value::value}; pub use self::{input_value::input_value, value::value, vars::vars};

View file

@ -1,20 +1,18 @@
//! [`graphql_vars!`] macro implementation. //! [`vars!`] macro implementation.
//!
//! [`graphql_vars!`]: graphql_vars
/// Constructs [`Variables`] via JSON-like syntax. /// Constructs [`graphql::Variables`] via JSON-like syntax.
/// ///
/// [`Variables`] key should implement [`Into`]`<`[`String`]`>`. /// [`graphql::Variables`] key should implement [`Into`]`<`[`String`]`>`.
/// ```rust /// ```rust
/// # use std::borrow::Cow; /// # use std::borrow::Cow;
/// # /// #
/// # use juniper::{graphql_vars, Variables}; /// # use juniper::graphql;
/// # /// #
/// let code = 200; /// let code = 200;
/// let features = vec!["key", "value"]; /// let features = vec!["key", "value"];
/// let key: Cow<'static, str> = "key".into(); /// let key: Cow<'static, str> = "key".into();
/// ///
/// let value: Variables = graphql_vars! { /// let value: graphql::Variables = graphql::vars! {
/// "code": code, /// "code": code,
/// "success": code == 200, /// "success": code == 200,
/// features[0]: features[1], /// features[0]: features[1],
@ -22,12 +20,11 @@
/// }; /// };
/// ``` /// ```
/// ///
/// See [`graphql_input_value!`] for more info on syntax of value after `:`. /// See [`graphql::input_value!`] for more info on syntax of value after `:`.
/// ///
/// [`graphql_input_value!`]: crate::graphql_input_value /// [`graphql::input_value!`]: crate::graphql::input_value
/// [`Variables`]: crate::Variables /// [`graphql::Variables`]: crate::graphql::Variables
#[macro_export] macro_rules! vars {
macro_rules! graphql_vars {
//////////// ////////////
// Object // // Object //
//////////// ////////////
@ -38,12 +35,12 @@ macro_rules! graphql_vars {
// Insert the current entry followed by trailing comma. // Insert the current entry followed by trailing comma.
(@object $object:ident [$($key:tt)+] ($value:expr) , $($rest:tt)*) => { (@object $object:ident [$($key:tt)+] ($value:expr) , $($rest:tt)*) => {
let _ = $object.insert(($($key)+).into(), $value); let _ = $object.insert(($($key)+).into(), $value);
$crate::graphql_vars! {@object $object () ($($rest)*) ($($rest)*)}; $crate::graphql::vars! {@object $object () ($($rest)*) ($($rest)*)};
}; };
// Current entry followed by unexpected token. // Current entry followed by unexpected token.
(@object $object:ident [$($key:tt)+] ($value:expr) $unexpected:tt $($rest:tt)*) => { (@object $object:ident [$($key:tt)+] ($value:expr) $unexpected:tt $($rest:tt)*) => {
$crate::graphql_vars! {@unexpected $unexpected}; $crate::graphql::vars! {@unexpected $unexpected};
}; };
// Insert the last entry without trailing comma. // Insert the last entry without trailing comma.
@ -53,7 +50,7 @@ macro_rules! graphql_vars {
// Next value is `null`. // Next value is `null`.
(@object $object:ident ($($key:tt)+) (: null $($rest:tt)*) $copy:tt) => { (@object $object:ident ($($key:tt)+) (: null $($rest:tt)*) $copy:tt) => {
$crate::graphql_vars! { $crate::graphql::vars! {
@object $object @object $object
[$($key)+] [$($key)+]
($crate::graphql_input_value!(null)) $($rest)* ($crate::graphql_input_value!(null)) $($rest)*
@ -62,7 +59,7 @@ macro_rules! graphql_vars {
// Next value is `None`. // Next value is `None`.
(@object $object:ident ($($key:tt)+) (: None $($rest:tt)*) $copy:tt) => { (@object $object:ident ($($key:tt)+) (: None $($rest:tt)*) $copy:tt) => {
$crate::graphql_vars! { $crate::graphql::vars! {
@object $object @object $object
[$($key)+] [$($key)+]
($crate::graphql_input_value!(None)) $($rest)* ($crate::graphql_input_value!(None)) $($rest)*
@ -71,7 +68,7 @@ macro_rules! graphql_vars {
// Next value is a variable. // Next value is a variable.
(@object $object:ident ($($key:tt)+) (: @$var:ident $($rest:tt)*) $copy:tt) => { (@object $object:ident ($($key:tt)+) (: @$var:ident $($rest:tt)*) $copy:tt) => {
$crate::graphql_vars! { $crate::graphql::vars! {
@object $object @object $object
[$($key)+] [$($key)+]
($crate::graphql_input_value!(@$var)) $($rest)* ($crate::graphql_input_value!(@$var)) $($rest)*
@ -80,7 +77,7 @@ macro_rules! graphql_vars {
// Next value is an array. // Next value is an array.
(@object $object:ident ($($key:tt)+) (: [$($array:tt)*] $($rest:tt)*) $copy:tt) => { (@object $object:ident ($($key:tt)+) (: [$($array:tt)*] $($rest:tt)*) $copy:tt) => {
$crate::graphql_vars! { $crate::graphql::vars! {
@object $object @object $object
[$($key)+] [$($key)+]
($crate::graphql_input_value!([$($array)*])) $($rest)* ($crate::graphql_input_value!([$($array)*])) $($rest)*
@ -89,7 +86,7 @@ macro_rules! graphql_vars {
// Next value is a map. // Next value is a map.
(@object $object:ident ($($key:tt)+) (: {$($map:tt)*} $($rest:tt)*) $copy:tt) => { (@object $object:ident ($($key:tt)+) (: {$($map:tt)*} $($rest:tt)*) $copy:tt) => {
$crate::graphql_vars! { $crate::graphql::vars! {
@object $object @object $object
[$($key)+] [$($key)+]
($crate::graphql_input_value!({$($map)*})) $($rest)* ($crate::graphql_input_value!({$($map)*})) $($rest)*
@ -98,7 +95,7 @@ macro_rules! graphql_vars {
// Next value is `true`, `false` or enum ident followed by a comma. // Next value is `true`, `false` or enum ident followed by a comma.
(@object $object:ident ($($key:tt)+) (: $ident:ident , $($rest:tt)*) $copy:tt) => { (@object $object:ident ($($key:tt)+) (: $ident:ident , $($rest:tt)*) $copy:tt) => {
$crate::graphql_vars! { $crate::graphql::vars! {
@object $object @object $object
[$($key)+] [$($key)+]
($crate::graphql_input_value!($ident)) , $($rest)* ($crate::graphql_input_value!($ident)) , $($rest)*
@ -107,7 +104,7 @@ macro_rules! graphql_vars {
// Next value is `true`, `false` or enum ident without trailing comma. // Next value is `true`, `false` or enum ident without trailing comma.
(@object $object:ident ($($key:tt)+) (: $last:ident ) $copy:tt) => { (@object $object:ident ($($key:tt)+) (: $last:ident ) $copy:tt) => {
$crate::graphql_vars! { $crate::graphql::vars! {
@object $object @object $object
[$($key)+] [$($key)+]
($crate::graphql_input_value!($last)) ($crate::graphql_input_value!($last))
@ -116,7 +113,7 @@ macro_rules! graphql_vars {
// Next value is an expression followed by comma. // Next value is an expression followed by comma.
(@object $object:ident ($($key:tt)+) (: $value:expr , $($rest:tt)*) $copy:tt) => { (@object $object:ident ($($key:tt)+) (: $value:expr , $($rest:tt)*) $copy:tt) => {
$crate::graphql_vars! { $crate::graphql::vars! {
@object $object @object $object
[$($key)+] [$($key)+]
($crate::graphql_input_value!($value)) , $($rest)* ($crate::graphql_input_value!($value)) , $($rest)*
@ -125,7 +122,7 @@ macro_rules! graphql_vars {
// Last value is an expression with no trailing comma. // Last value is an expression with no trailing comma.
(@object $object:ident ($($key:tt)+) (: $value:expr) $copy:tt) => { (@object $object:ident ($($key:tt)+) (: $value:expr) $copy:tt) => {
$crate::graphql_vars! { $crate::graphql::vars! {
@object $object @object $object
[$($key)+] [$($key)+]
($crate::graphql_input_value!($value)) ($crate::graphql_input_value!($value))
@ -135,44 +132,44 @@ macro_rules! graphql_vars {
// Missing value for last entry. Trigger a reasonable error message. // Missing value for last entry. Trigger a reasonable error message.
(@object $object:ident ($($key:tt)+) (:) $copy:tt) => { (@object $object:ident ($($key:tt)+) (:) $copy:tt) => {
// "unexpected end of macro invocation" // "unexpected end of macro invocation"
$crate::graphql_vars! {}; $crate::graphql::vars! {};
}; };
// Missing colon and value for last entry. Trigger a reasonable error // Missing colon and value for last entry. Trigger a reasonable error
// message. // message.
(@object $object:ident ($($key:tt)+) () $copy:tt) => { (@object $object:ident ($($key:tt)+) () $copy:tt) => {
// "unexpected end of macro invocation" // "unexpected end of macro invocation"
$crate::graphql_vars! {}; $crate::graphql::vars! {};
}; };
// Misplaced colon. Trigger a reasonable error message. // Misplaced colon. Trigger a reasonable error message.
(@object $object:ident () (: $($rest:tt)*) ($colon:tt $($copy:tt)*)) => { (@object $object:ident () (: $($rest:tt)*) ($colon:tt $($copy:tt)*)) => {
// Takes no arguments so "no rules expected the token `:`". // Takes no arguments so "no rules expected the token `:`".
$crate::graphql_vars! {@unexpected $colon}; $crate::graphql::vars! {@unexpected $colon};
}; };
// Found a comma inside a key. Trigger a reasonable error message. // Found a comma inside a key. Trigger a reasonable error message.
(@object $object:ident ($($key:tt)*) (, $($rest:tt)*) ($comma:tt $($copy:tt)*)) => { (@object $object:ident ($($key:tt)*) (, $($rest:tt)*) ($comma:tt $($copy:tt)*)) => {
// Takes no arguments so "no rules expected the token `,`". // Takes no arguments so "no rules expected the token `,`".
$crate::graphql_vars! {@unexpected $comma}; $crate::graphql::vars! {@unexpected $comma};
}; };
// Key is fully parenthesized. This avoids clippy double_parens false // Key is fully parenthesized. This avoids clippy double_parens false
// positives because the parenthesization may be necessary here. // positives because the parenthesization may be necessary here.
(@object $object:ident () (($key:expr) : $($rest:tt)*) $copy:tt) => { (@object $object:ident () (($key:expr) : $($rest:tt)*) $copy:tt) => {
$crate::graphql_vars! { $crate::graphql::vars! {
@object $object ($key) (: $($rest)*) (: $($rest)*) @object $object ($key) (: $($rest)*) (: $($rest)*)
}; };
}; };
// Refuse to absorb colon token into key expression. // Refuse to absorb colon token into key expression.
(@object $object:ident ($($key:tt)*) (: $($unexpected:tt)+) $copy:tt) => { (@object $object:ident ($($key:tt)*) (: $($unexpected:tt)+) $copy:tt) => {
$crate::graphql_vars! {@unexpected $($unexpected)+}; $crate::graphql::vars! {@unexpected $($unexpected)+};
}; };
// Munch a token into the current key. // Munch a token into the current key.
(@object $object:ident ($($key:tt)*) ($tt:tt $($rest:tt)*) $copy:tt) => { (@object $object:ident ($($key:tt)*) ($tt:tt $($rest:tt)*) $copy:tt) => {
$crate::graphql_vars! { $crate::graphql::vars! {
@object $object @object $object
($($key)* $tt) ($($key)* $tt)
($($rest)*) ($($rest)*) ($($rest)*) ($($rest)*)
@ -189,26 +186,33 @@ macro_rules! graphql_vars {
// Defaults // // Defaults //
////////////// //////////////
() => {{ $crate::Variables::<_>::new() }}; () => {{ $crate::graphql::Variables::<_>::new() }};
( $($map:tt)+ ) => {{ ( $($map:tt)+ ) => {{
let mut object = $crate::Variables::<_>::new(); let mut object = $crate::graphql::Variables::<_>::new();
$crate::graphql_vars! {@object object () ($($map)*) ($($map)*)}; $crate::graphql::vars! {@object object () ($($map)*) ($($map)*)};
object object
}}; }};
} }
#[doc(inline)]
pub(super) use vars;
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use indexmap::{indexmap, IndexMap}; use indexmap::{indexmap, IndexMap};
type V = crate::Variables; use crate::graphql;
type IV = crate::InputValue; use super::vars;
type V = graphql::Variables;
type IV = graphql::InputValue;
#[test] #[test]
fn empty() { fn empty() {
assert_eq!(graphql_vars! {}, V::new()); assert_eq!(vars! {}, V::new());
} }
#[test] #[test]
@ -216,37 +220,37 @@ mod tests {
let val = 42; let val = 42;
assert_eq!( assert_eq!(
graphql_vars! {"key": 123}, vars! {"key": 123},
vec![("key".to_owned(), IV::scalar(123))] vec![("key".to_owned(), IV::scalar(123))]
.into_iter() .into_iter()
.collect::<V>(), .collect::<V>(),
); );
assert_eq!( assert_eq!(
graphql_vars! {"key": "val"}, vars! {"key": "val"},
vec![("key".to_owned(), IV::scalar("val"))] vec![("key".to_owned(), IV::scalar("val"))]
.into_iter() .into_iter()
.collect::<V>(), .collect::<V>(),
); );
assert_eq!( assert_eq!(
graphql_vars! {"key": 1.23}, vars! {"key": 1.23},
vec![("key".to_owned(), IV::scalar(1.23))] vec![("key".to_owned(), IV::scalar(1.23))]
.into_iter() .into_iter()
.collect::<V>(), .collect::<V>(),
); );
assert_eq!( assert_eq!(
graphql_vars! {"key": 1 + 2}, vars! {"key": 1 + 2},
vec![("key".to_owned(), IV::scalar(3))] vec![("key".to_owned(), IV::scalar(3))]
.into_iter() .into_iter()
.collect(), .collect(),
); );
assert_eq!( assert_eq!(
graphql_vars! {"key": false}, vars! {"key": false},
vec![("key".to_owned(), IV::scalar(false))] vec![("key".to_owned(), IV::scalar(false))]
.into_iter() .into_iter()
.collect::<V>(), .collect::<V>(),
); );
assert_eq!( assert_eq!(
graphql_vars! {"key": (val)}, vars! {"key": (val)},
vec![("key".to_owned(), IV::scalar(42))] vec![("key".to_owned(), IV::scalar(42))]
.into_iter() .into_iter()
.collect::<V>(), .collect::<V>(),
@ -256,13 +260,13 @@ mod tests {
#[test] #[test]
fn r#enum() { fn r#enum() {
assert_eq!( assert_eq!(
graphql_vars! {"key": ENUM}, vars! {"key": ENUM},
vec![("key".to_owned(), IV::enum_value("ENUM"))] vec![("key".to_owned(), IV::enum_value("ENUM"))]
.into_iter() .into_iter()
.collect::<V>(), .collect::<V>(),
); );
assert_eq!( assert_eq!(
graphql_vars! {"key": lowercase}, vars! {"key": lowercase},
vec![("key".to_owned(), IV::enum_value("lowercase"))] vec![("key".to_owned(), IV::enum_value("lowercase"))]
.into_iter() .into_iter()
.collect::<V>(), .collect::<V>(),
@ -272,19 +276,19 @@ mod tests {
#[test] #[test]
fn variable() { fn variable() {
assert_eq!( assert_eq!(
graphql_vars! {"key": @var}, vars! {"key": @var},
vec![("key".to_owned(), IV::variable("var"))] vec![("key".to_owned(), IV::variable("var"))]
.into_iter() .into_iter()
.collect::<V>(), .collect::<V>(),
); );
assert_eq!( assert_eq!(
graphql_vars! {"key": @array}, vars! {"key": @array},
vec![("key".to_owned(), IV::variable("array"))] vec![("key".to_owned(), IV::variable("array"))]
.into_iter() .into_iter()
.collect::<V>(), .collect::<V>(),
); );
assert_eq!( assert_eq!(
graphql_vars! {"key": @object}, vars! {"key": @object},
vec![("key".to_owned(), IV::variable("object"))] vec![("key".to_owned(), IV::variable("object"))]
.into_iter() .into_iter()
.collect::<V>(), .collect::<V>(),
@ -296,46 +300,46 @@ mod tests {
let val = 42; let val = 42;
assert_eq!( assert_eq!(
graphql_vars! {"key": []}, vars! {"key": []},
vec![("key".to_owned(), IV::list(vec![]))] vec![("key".to_owned(), IV::list(vec![]))]
.into_iter() .into_iter()
.collect::<V>(), .collect::<V>(),
); );
assert_eq!( assert_eq!(
graphql_vars! {"key": [null]}, vars! {"key": [null]},
vec![("key".to_owned(), IV::list(vec![IV::Null]))] vec![("key".to_owned(), IV::list(vec![IV::Null]))]
.into_iter() .into_iter()
.collect::<V>(), .collect::<V>(),
); );
assert_eq!( assert_eq!(
graphql_vars! {"key": [1]}, vars! {"key": [1]},
vec![("key".to_owned(), IV::list(vec![IV::scalar(1)]))] vec![("key".to_owned(), IV::list(vec![IV::scalar(1)]))]
.into_iter() .into_iter()
.collect::<V>(), .collect::<V>(),
); );
assert_eq!( assert_eq!(
graphql_vars! {"key": [1 + 2]}, vars! {"key": [1 + 2]},
vec![("key".to_owned(), IV::list(vec![IV::scalar(3)]))] vec![("key".to_owned(), IV::list(vec![IV::scalar(3)]))]
.into_iter() .into_iter()
.collect::<V>(), .collect::<V>(),
); );
assert_eq!( assert_eq!(
graphql_vars! {"key": [(val)]}, vars! {"key": [(val)]},
vec![("key".to_owned(), IV::list(vec![IV::scalar(42)]))] vec![("key".to_owned(), IV::list(vec![IV::scalar(42)]))]
.into_iter() .into_iter()
.collect::<V>(), .collect::<V>(),
); );
assert_eq!( assert_eq!(
graphql_vars! {"key": [ENUM]}, vars! {"key": [ENUM]},
vec![("key".to_owned(), IV::list(vec![IV::enum_value("ENUM")]))] vec![("key".to_owned(), IV::list(vec![IV::enum_value("ENUM")]))]
.into_iter() .into_iter()
.collect::<V>(), .collect::<V>(),
); );
assert_eq!( assert_eq!(
graphql_vars! {"key": [lowercase]}, vars! {"key": [lowercase]},
vec![( vec![(
"key".to_owned(), "key".to_owned(),
IV::list(vec![IV::enum_value("lowercase")]) IV::list(vec![IV::enum_value("lowercase")])
@ -345,26 +349,26 @@ mod tests {
); );
assert_eq!( assert_eq!(
graphql_vars! {"key": [@var]}, vars! {"key": [@var]},
vec![("key".to_owned(), IV::list(vec![IV::variable("var")]))] vec![("key".to_owned(), IV::list(vec![IV::variable("var")]))]
.into_iter() .into_iter()
.collect::<V>(), .collect::<V>(),
); );
assert_eq!( assert_eq!(
graphql_vars! {"key": [@array]}, vars! {"key": [@array]},
vec![("key".to_owned(), IV::list(vec![IV::variable("array")]))] vec![("key".to_owned(), IV::list(vec![IV::variable("array")]))]
.into_iter() .into_iter()
.collect::<V>(), .collect::<V>(),
); );
assert_eq!( assert_eq!(
graphql_vars! {"key": [@object]}, vars! {"key": [@object]},
vec![("key".to_owned(), IV::list(vec![IV::variable("object")]))] vec![("key".to_owned(), IV::list(vec![IV::variable("object")]))]
.into_iter() .into_iter()
.collect::<V>(), .collect::<V>(),
); );
assert_eq!( assert_eq!(
graphql_vars! {"key": [1, [2], 3]}, vars! {"key": [1, [2], 3]},
vec![( vec![(
"key".to_owned(), "key".to_owned(),
IV::list(vec![ IV::list(vec![
@ -377,7 +381,7 @@ mod tests {
.collect::<V>(), .collect::<V>(),
); );
assert_eq!( assert_eq!(
graphql_vars! {"key": [1, [2 + 3], 3]}, vars! {"key": [1, [2 + 3], 3]},
vec![( vec![(
"key".to_owned(), "key".to_owned(),
IV::list(vec![ IV::list(vec![
@ -390,7 +394,7 @@ mod tests {
.collect::<V>(), .collect::<V>(),
); );
assert_eq!( assert_eq!(
graphql_vars! {"key": [1, [ENUM], (val)]}, vars! {"key": [1, [ENUM], (val)]},
vec![( vec![(
"key".to_owned(), "key".to_owned(),
IV::list(vec![ IV::list(vec![
@ -403,7 +407,7 @@ mod tests {
.collect::<V>(), .collect::<V>(),
); );
assert_eq!( assert_eq!(
graphql_vars! {"key": [1 + 2, [(val)], @val]}, vars! {"key": [1 + 2, [(val)], @val]},
vec![( vec![(
"key".to_owned(), "key".to_owned(),
IV::list(vec![ IV::list(vec![
@ -416,7 +420,7 @@ mod tests {
.collect::<V>(), .collect::<V>(),
); );
assert_eq!( assert_eq!(
graphql_vars! {"key": [1, [@val], ENUM]}, vars! {"key": [1, [@val], ENUM]},
vec![( vec![(
"key".to_owned(), "key".to_owned(),
IV::list(vec![ IV::list(vec![
@ -435,21 +439,21 @@ mod tests {
let val = 42; let val = 42;
assert_eq!( assert_eq!(
graphql_vars! {"key": {}}, vars! {"key": {}},
vec![("key".to_owned(), IV::object(IndexMap::<String, _>::new()))] vec![("key".to_owned(), IV::object(IndexMap::<String, _>::new()))]
.into_iter() .into_iter()
.collect::<V>(), .collect::<V>(),
); );
assert_eq!( assert_eq!(
graphql_vars! {"key": {"key": null}}, vars! {"key": {"key": null}},
vec![("key".to_owned(), IV::object(indexmap! {"key" => IV::Null}))] vec![("key".to_owned(), IV::object(indexmap! {"key" => IV::Null}))]
.into_iter() .into_iter()
.collect::<V>(), .collect::<V>(),
); );
assert_eq!( assert_eq!(
graphql_vars! {"key": {"key": 123}}, vars! {"key": {"key": 123}},
vec![( vec![(
"key".to_owned(), "key".to_owned(),
IV::object(indexmap! {"key" => IV::scalar(123)}), IV::object(indexmap! {"key" => IV::scalar(123)}),
@ -458,7 +462,7 @@ mod tests {
.collect::<V>(), .collect::<V>(),
); );
assert_eq!( assert_eq!(
graphql_vars! {"key": {"key": 1 + 2}}, vars! {"key": {"key": 1 + 2}},
vec![( vec![(
"key".to_owned(), "key".to_owned(),
IV::object(indexmap! {"key" => IV::scalar(3)}), IV::object(indexmap! {"key" => IV::scalar(3)}),
@ -467,7 +471,7 @@ mod tests {
.collect::<V>(), .collect::<V>(),
); );
assert_eq!( assert_eq!(
graphql_vars! {"key": {"key": (val)}}, vars! {"key": {"key": (val)}},
vec![( vec![(
"key".to_owned(), "key".to_owned(),
IV::object(indexmap! {"key" => IV::scalar(42)}), IV::object(indexmap! {"key" => IV::scalar(42)}),
@ -477,7 +481,7 @@ mod tests {
); );
assert_eq!( assert_eq!(
graphql_vars! {"key": {"key": []}}, vars! {"key": {"key": []}},
vec![( vec![(
"key".to_owned(), "key".to_owned(),
IV::object(indexmap! {"key" => IV::list(vec![])}), IV::object(indexmap! {"key" => IV::list(vec![])}),
@ -486,7 +490,7 @@ mod tests {
.collect::<V>(), .collect::<V>(),
); );
assert_eq!( assert_eq!(
graphql_vars! {"key": {"key": [null]}}, vars! {"key": {"key": [null]}},
vec![( vec![(
"key".to_owned(), "key".to_owned(),
IV::object(indexmap! {"key" => IV::list(vec![IV::Null])}), IV::object(indexmap! {"key" => IV::list(vec![IV::Null])}),
@ -495,7 +499,7 @@ mod tests {
.collect::<V>(), .collect::<V>(),
); );
assert_eq!( assert_eq!(
graphql_vars! {"key": {"key": [1]}}, vars! {"key": {"key": [1]}},
vec![( vec![(
"key".to_owned(), "key".to_owned(),
IV::object(indexmap! {"key" => IV::list(vec![IV::scalar(1)])}), IV::object(indexmap! {"key" => IV::list(vec![IV::scalar(1)])}),
@ -504,7 +508,7 @@ mod tests {
.collect::<V>(), .collect::<V>(),
); );
assert_eq!( assert_eq!(
graphql_vars! {"key": {"key": [1 + 2]}}, vars! {"key": {"key": [1 + 2]}},
vec![( vec![(
"key".to_owned(), "key".to_owned(),
IV::object(indexmap! {"key" => IV::list(vec![IV::scalar(3)])}), IV::object(indexmap! {"key" => IV::list(vec![IV::scalar(3)])}),
@ -513,7 +517,7 @@ mod tests {
.collect::<V>(), .collect::<V>(),
); );
assert_eq!( assert_eq!(
graphql_vars! {"key": {"key": [(val)]}}, vars! {"key": {"key": [(val)]}},
vec![( vec![(
"key".to_owned(), "key".to_owned(),
IV::object(indexmap! {"key" => IV::list(vec![IV::scalar(42)])}), IV::object(indexmap! {"key" => IV::list(vec![IV::scalar(42)])}),
@ -522,7 +526,7 @@ mod tests {
.collect::<V>(), .collect::<V>(),
); );
assert_eq!( assert_eq!(
graphql_vars! {"key": {"key": ENUM}}, vars! {"key": {"key": ENUM}},
vec![( vec![(
"key".to_owned(), "key".to_owned(),
IV::object(indexmap! {"key" => IV::enum_value("ENUM")}), IV::object(indexmap! {"key" => IV::enum_value("ENUM")}),
@ -531,7 +535,7 @@ mod tests {
.collect::<V>(), .collect::<V>(),
); );
assert_eq!( assert_eq!(
graphql_vars! {"key": {"key": lowercase}}, vars! {"key": {"key": lowercase}},
vec![( vec![(
"key".to_owned(), "key".to_owned(),
IV::object(indexmap! {"key" => IV::enum_value("lowercase")}), IV::object(indexmap! {"key" => IV::enum_value("lowercase")}),
@ -540,7 +544,7 @@ mod tests {
.collect::<V>(), .collect::<V>(),
); );
assert_eq!( assert_eq!(
graphql_vars! {"key": {"key": @val}}, vars! {"key": {"key": @val}},
vec![( vec![(
"key".to_owned(), "key".to_owned(),
IV::object(indexmap! {"key" => IV::variable("val")}), IV::object(indexmap! {"key" => IV::variable("val")}),
@ -549,7 +553,7 @@ mod tests {
.collect::<V>(), .collect::<V>(),
); );
assert_eq!( assert_eq!(
graphql_vars! {"key": {"key": @array}}, vars! {"key": {"key": @array}},
vec![( vec![(
"key".to_owned(), "key".to_owned(),
IV::object(indexmap! {"key" => IV::variable("array")}), IV::object(indexmap! {"key" => IV::variable("array")}),
@ -558,7 +562,7 @@ mod tests {
.collect::<V>(), .collect::<V>(),
); );
assert_eq!( assert_eq!(
graphql_vars! { vars! {
"inner": { "inner": {
"key1": (val), "key1": (val),
"key2": "val", "key2": "val",