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>
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 moresource§impl<S: Debug> Debug for InputValue<S>
impl<S: Debug> Debug for InputValue<S>
source§impl<'de, S: Deserialize<'de>> Deserialize<'de> for InputValue<S>
impl<'de, S: Deserialize<'de>> Deserialize<'de> for InputValue<S>
source§fn deserialize<D: Deserializer<'de>>(de: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(de: D) -> Result<Self, D::Error>
source§impl<S: ScalarValue> Display for InputValue<S>
impl<S: ScalarValue> Display for InputValue<S>
source§impl<S: PartialEq> PartialEq for InputValue<S>
impl<S: PartialEq> PartialEq 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 ==
.source§impl<T: Serialize> Serialize for InputValue<T>
impl<T: Serialize> Serialize for InputValue<T>
impl<S> StructuralPartialEq for InputValue<S>
Auto Trait Implementations§
impl<S> Freeze for InputValue<S>where
S: Freeze,
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§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> FmtForward for T
impl<T> FmtForward for T
source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moresource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moresource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R ) -> R
source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.source§impl<T> Tap for T
impl<T> Tap for T
source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read moresource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read moresource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read moresource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read moresource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read moresource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read moresource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.