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>
impl<S> InputValue<S>
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 a Spanning::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
pub fn object<K>(o: IndexMap<K, Self>) -> Self
Construct aa Spanning::unlocated
object.
Similarly 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, values: &Variables<S>) -> Option<Self>where
S: Clone,
pub fn into_const(self, values: &Variables<S>) -> Option<Self>where
S: Clone,
Resolves all variables of this InputValue
to their actual values
.
If a variable is not present in the values
:
- Returns
None
in case this is anInputValue::Variable
. - Skips field in case of an
InputValue::Object
field. - Replaces with an
InputValue::Null
in case of anInputValue::List
element.
This is done, because for an InputValue::Variable
(or an
InputValue::Object
field) a default value can be used later, if it’s
provided. While on contrary, a single InputValue::List
element
cannot have a default value.
Sourcepub fn convert<T: FromInputValue<S>>(&self) -> Result<T, T::Error>
pub fn convert<T: FromInputValue<S>>(&self) -> Result<T, T::Error>
Shorthand form of invoking FromInputValue::from_input_value()
.
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>where
S: ScalarValue,
pub fn as_int_value(&self) -> Option<i32>where
S: ScalarValue,
View the underlying int value, if present.
Sourcepub fn as_float_value(&self) -> Option<f64>where
S: ScalarValue,
pub fn as_float_value(&self) -> Option<f64>where
S: ScalarValue,
View the underlying float value, if present.
Sourcepub fn as_string_value(&self) -> Option<&str>where
S: ScalarValue,
pub fn as_string_value(&self) -> Option<&str>where
S: ScalarValue,
View the underlying string value, if present.
Sourcepub fn as_scalar_value<'a, T>(&'a self) -> Option<&'a T>
pub fn as_scalar_value<'a, T>(&'a self) -> 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>>
Converts this InputValue
to a Spanning::unlocated
object value.
This constructs a new IndexMap
containing references to the keys
and values of self
.
Sourcepub fn to_list_value(&self) -> Option<Vec<&Self>>
pub fn to_list_value(&self) -> Option<Vec<&Self>>
Converts this InputValue
to a Spanning::unlocated
list value.
This constructs a new Vec
containing references to the values of
self
.
Sourcepub fn referenced_variables(&self) -> Vec<&str>
pub fn referenced_variables(&self) -> Vec<&str>
Recursively finds all variables
Sourcepub fn unlocated_eq(&self, other: &Self) -> boolwhere
S: PartialEq,
pub fn unlocated_eq(&self, other: &Self) -> boolwhere
S: PartialEq,
Compares 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 more