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,

source

pub fn null() -> Self

Construct a null value.

source

pub fn int(i: i32) -> Self

👎Deprecated since 0.11.0: Use InputValue::scalar instead

Construct an integer value.

source

pub fn float(f: f64) -> Self

👎Deprecated since 0.11.0: Use InputValue::scalar instead

Construct a floating point value.

source

pub fn boolean(b: bool) -> Self

👎Deprecated since 0.11.0: Use InputValue::scalar instead

Construct a boolean value.

source

pub fn string<T: AsRef<str>>(s: T) -> Self

👎Deprecated since 0.11.0: Use InputValue::scalar instead

Construct a string value.

source

pub fn scalar<T>(v: T) -> Selfwhere
    T: Into<S>,

Construct a scalar value

source

pub fn enum_value<T: AsRef<str>>(s: T) -> Self

Construct an enum value.

source

pub fn variable<T: AsRef<str>>(v: T) -> Self

Construct a variable value.

source

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.

source

pub fn parsed_list(l: Vec<Spanning<Self>>) -> Self

Construct a located list.

source

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.

source

pub fn parsed_object(o: Vec<(Spanning<String>, Spanning<Self>)>) -> Self

Construct a located object.

source

pub fn into_const(self, vars: &Variables<S>) -> Self

Resolve all variables to their values.

source

pub fn convert<T>(&self) -> Option<T>where
    T: FromInputValue<S>,

Shorthand form of invoking FromInputValue::from().

source

pub fn is_null(&self) -> bool

Does the value represent null?

source

pub fn is_variable(&self) -> bool

Does the value represent a variable?

source

pub fn as_enum_value(&self) -> Option<&str>

View the underlying enum value, if present.

source

pub fn as_int_value(&self) -> Option<i32>

View the underlying int value, if present.

source

pub fn as_float_value(&self) -> Option<f64>

View the underlying float value, if present.

source

pub fn as_string_value(&self) -> Option<&str>

View the underlying string value, if present.

source

pub fn as_scalar(&self) -> Option<&S>

View the underlying scalar value, if present.

source

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.

source

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.

source

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.

source

pub fn referenced_variables(&self) -> Vec<&str>

Recursively find all variables

source

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>

source§

fn clone(&self) -> InputValue<S>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<S: Debug> Debug for InputValue<S>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

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>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<S> Display for InputValue<S>where
    S: ScalarValue,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<S: PartialEq> PartialEq<InputValue<S>> for InputValue<S>

source§

fn eq(&self, other: &InputValue<S>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T> Serialize for InputValue<T>where
    T: ScalarValue,

source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>where
    S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

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§

source§

impl<T> Any for Twhere
    T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere
    T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere
    T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere
    U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere
    T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for Twhere
    T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere
    U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere
    U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere
    V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> DeserializeOwned for Twhere
    T: for<'de> Deserialize<'de>,