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
sourceimpl<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
Use InputValue::scalar
instead
Construct an integer value.
sourcepub fn float(f: f64) -> Self
👎 Deprecated since 0.11.0: Use InputValue::scalar
instead
pub fn float(f: f64) -> Self
Use InputValue::scalar
instead
Construct 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
Use InputValue::scalar
instead
Construct 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
Use InputValue::scalar
instead
Construct 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>) -> Self where
K: AsRef<str> + Eq + Hash,
pub fn object<K>(o: IndexMap<K, Self>) -> Self where
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
sourceimpl<S: Clone> Clone for InputValue<S>
impl<S: Clone> Clone for InputValue<S>
sourcefn clone(&self) -> InputValue<S>
fn clone(&self) -> InputValue<S>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<S: Debug> Debug for InputValue<S>
impl<S: Debug> Debug for InputValue<S>
sourceimpl<'de, S> Deserialize<'de> for InputValue<S> where
S: ScalarValue,
impl<'de, S> Deserialize<'de> for InputValue<S> where
S: ScalarValue,
sourcefn 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>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl<S> Display for InputValue<S> where
S: ScalarValue,
impl<S> Display for InputValue<S> where
S: ScalarValue,
sourceimpl<S: PartialEq> PartialEq<InputValue<S>> for InputValue<S>
impl<S: PartialEq> PartialEq<InputValue<S>> for InputValue<S>
sourcefn eq(&self, other: &InputValue<S>) -> bool
fn eq(&self, other: &InputValue<S>) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &InputValue<S>) -> bool
fn ne(&self, other: &InputValue<S>) -> bool
This method tests for !=
.
sourceimpl<T> Serialize for InputValue<T> where
T: ScalarValue,
impl<T> Serialize for InputValue<T> where
T: ScalarValue,
impl<S> StructuralPartialEq for InputValue<S>
Auto Trait Implementations
impl<S> RefUnwindSafe for InputValue<S> where
S: RefUnwindSafe,
impl<S> Send for InputValue<S> where
S: Send,
impl<S> Sync for InputValue<S> where
S: Sync,
impl<S> Unpin for InputValue<S> where
S: Unpin,
impl<S> UnwindSafe for InputValue<S> where
S: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more