Enum juniper::InputValue
source · pub enum InputValue<S = DefaultScalarValue> {
Null,
Scalar(S),
Enum(String),
Variable(String),
List(Vec<Spanning<InputValue<S>>>),
Object(Vec<(Spanning<String>, Spanning<InputValue<S>>)>),
}
Expand description
A JSON-like value that can be passed into the query execution, either out-of-band, or in-band as default variable values. These are not constant and might contain variables.
Lists and objects variants are spanned, i.e. they contain a reference to their position in the source file, if available.
Variants§
Null
Scalar(S)
Enum(String)
Variable(String)
List(Vec<Spanning<InputValue<S>>>)
Object(Vec<(Spanning<String>, Spanning<InputValue<S>>)>)
Implementations§
source§impl<S> InputValue<S>where
S: ScalarValue,
impl<S> InputValue<S>where
S: ScalarValue,
sourcepub fn int(i: i32) -> Self
👎Deprecated since 0.11.0: Use InputValue::scalar
instead
pub fn int(i: i32) -> Self
InputValue::scalar
insteadConstruct an integer value.
sourcepub fn float(f: f64) -> Self
👎Deprecated since 0.11.0: Use InputValue::scalar
instead
pub fn float(f: f64) -> Self
InputValue::scalar
insteadConstruct a floating point value.
sourcepub fn boolean(b: bool) -> Self
👎Deprecated since 0.11.0: Use InputValue::scalar
instead
pub fn boolean(b: bool) -> Self
InputValue::scalar
insteadConstruct a boolean value.
sourcepub fn string<T: AsRef<str>>(s: T) -> Self
👎Deprecated since 0.11.0: Use InputValue::scalar
instead
pub fn string<T: AsRef<str>>(s: T) -> Self
InputValue::scalar
insteadConstruct a string value.
sourcepub fn enum_value<T: AsRef<str>>(s: T) -> Self
pub fn enum_value<T: AsRef<str>>(s: T) -> Self
Construct an enum value.
sourcepub fn list(l: Vec<Self>) -> Self
pub fn list(l: Vec<Self>) -> Self
Construct an unlocated list.
Convenience function to make each InputValue
in the input vector
not contain any location information. Can be used from ToInputValue
implementations, where no source code position information is available.
sourcepub fn parsed_list(l: Vec<Spanning<Self>>) -> Self
pub fn parsed_list(l: Vec<Spanning<Self>>) -> Self
Construct a located list.
sourcepub fn object<K>(o: IndexMap<K, Self>) -> Selfwhere
K: AsRef<str> + Eq + Hash,
pub fn object<K>(o: IndexMap<K, Self>) -> Selfwhere
K: AsRef<str> + Eq + Hash,
Construct an unlocated object.
Similar to InputValue::list
, it makes each key and value in the given
hash map not contain any location information.
sourcepub fn parsed_object(o: Vec<(Spanning<String>, Spanning<Self>)>) -> Self
pub fn parsed_object(o: Vec<(Spanning<String>, Spanning<Self>)>) -> Self
Construct a located object.
sourcepub fn into_const(self, vars: &Variables<S>) -> Self
pub fn into_const(self, vars: &Variables<S>) -> Self
Resolve all variables to their values.
sourcepub fn convert<T>(&self) -> Option<T>where
T: FromInputValue<S>,
pub fn convert<T>(&self) -> Option<T>where
T: FromInputValue<S>,
Shorthand form of invoking FromInputValue::from()
.
sourcepub fn is_variable(&self) -> bool
pub fn is_variable(&self) -> bool
Does the value represent a variable?
sourcepub fn as_enum_value(&self) -> Option<&str>
pub fn as_enum_value(&self) -> Option<&str>
View the underlying enum value, if present.
sourcepub fn as_int_value(&self) -> Option<i32>
pub fn as_int_value(&self) -> Option<i32>
View the underlying int value, if present.
sourcepub fn as_float_value(&self) -> Option<f64>
pub fn as_float_value(&self) -> Option<f64>
View the underlying float value, if present.
sourcepub fn as_string_value(&self) -> Option<&str>
pub fn as_string_value(&self) -> Option<&str>
View the underlying string value, if present.
sourcepub fn as_scalar_value<'a, T>(&'a self) -> Option<&'a T>where
T: 'a,
&'a S: Into<Option<&'a T>>,
pub fn as_scalar_value<'a, T>(&'a self) -> Option<&'a T>where
T: 'a,
&'a S: Into<Option<&'a T>>,
View the underlying scalar value, if present.
sourcepub fn to_object_value(&self) -> Option<IndexMap<&str, &Self>>
pub fn to_object_value(&self) -> Option<IndexMap<&str, &Self>>
Convert the input value to an unlocated object value.
This constructs a new IndexMap that contain references to the keys
and values in self
.
sourcepub fn to_list_value(&self) -> Option<Vec<&Self>>
pub fn to_list_value(&self) -> Option<Vec<&Self>>
Convert the input value to an unlocated list value.
This constructs a new vector that contain references to the values
in self
.
sourcepub fn referenced_variables(&self) -> Vec<&str>
pub fn referenced_variables(&self) -> Vec<&str>
Recursively find all variables
sourcepub fn unlocated_eq(&self, other: &Self) -> bool
pub fn unlocated_eq(&self, other: &Self) -> bool
Compare equality with another InputValue
ignoring any source position information.
Trait Implementations§
source§impl<S: Clone> Clone for InputValue<S>
impl<S: Clone> Clone for InputValue<S>
source§fn clone(&self) -> InputValue<S>
fn clone(&self) -> InputValue<S>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<S: Debug> Debug for InputValue<S>
impl<S: Debug> Debug for InputValue<S>
source§impl<'de, S> Deserialize<'de> for InputValue<S>where
S: ScalarValue,
impl<'de, S> Deserialize<'de> for InputValue<S>where
S: ScalarValue,
source§fn deserialize<D>(deserializer: D) -> Result<InputValue<S>, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<InputValue<S>, D::Error>where
D: Deserializer<'de>,
source§impl<S> Display for InputValue<S>where
S: ScalarValue,
impl<S> Display for InputValue<S>where
S: ScalarValue,
source§impl<S: PartialEq> PartialEq<InputValue<S>> for InputValue<S>
impl<S: PartialEq> PartialEq<InputValue<S>> for InputValue<S>
source§fn eq(&self, other: &InputValue<S>) -> bool
fn eq(&self, other: &InputValue<S>) -> bool
self
and other
values to be equal, and is used
by ==
.