#[non_exhaustive]pub enum GraphQLValue {
Null,
Boolean(bool),
Int(i64),
Float(f64),
String(String),
List(Vec<GraphQLValue>),
Object(IndexMap<String, GraphQLValue>),
}Expand description
A typed GraphQL literal value (spec §2.9).
Used for default_value in argument and input-field definitions. The enum
covers every kind that the GraphQL spec permits as a default: null, boolean,
integer, float, string, enum value (stored as String), list, and object.
§Serialization
Serializes to / deserializes from plain JSON (no wrapper object), so
GraphQLValue::Int(42) round-trips through JSON as 42 and
GraphQLValue::Boolean(true) as true.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Null
null
Boolean(bool)
true / false
Int(i64)
Integer literals (e.g. 42, -1).
Float(f64)
Float literals (e.g. 3.14). Only reached when the JSON number cannot
be losslessly represented as i64.
String(String)
String or enum-variant literals. Both are JSON strings; callers that need to distinguish enum values from string values must check the argument’s declared type.
List(Vec<GraphQLValue>)
List literals ([1, 2, 3]).
Object(IndexMap<String, GraphQLValue>)
Input-object literals ({key: value}).
Implementations§
Source§impl GraphQLValue
impl GraphQLValue
Sourcepub fn to_json(&self) -> Value
pub fn to_json(&self) -> Value
Convert to an equivalent serde_json::Value for wire serialization.
Sourcepub fn from_json(v: &Value) -> Result<Self>
pub fn from_json(v: &Value) -> Result<Self>
Parse from a serde_json::Value.
Returns Err if the shape is not a valid GraphQL literal. Currently
all JSON shapes are valid (Object maps to an input-object literal),
but this is the validation boundary where future restrictions can be
added.
§Errors
Returns FraiseQLError::Validation if a nested value cannot be
converted (e.g. a number that overflows i64 and f64).
Trait Implementations§
Source§impl Clone for GraphQLValue
impl Clone for GraphQLValue
Source§fn clone(&self) -> GraphQLValue
fn clone(&self) -> GraphQLValue
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for GraphQLValue
impl Debug for GraphQLValue
Source§impl<'de> Deserialize<'de> for GraphQLValue
impl<'de> Deserialize<'de> for GraphQLValue
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Display for GraphQLValue
impl Display for GraphQLValue
Source§impl PartialEq for GraphQLValue
impl PartialEq for GraphQLValue
Source§impl Serialize for GraphQLValue
impl Serialize for GraphQLValue
impl StructuralPartialEq for GraphQLValue
Auto Trait Implementations§
impl Freeze for GraphQLValue
impl RefUnwindSafe for GraphQLValue
impl Send for GraphQLValue
impl Sync for GraphQLValue
impl Unpin for GraphQLValue
impl UnsafeUnpin for GraphQLValue
impl UnwindSafe for GraphQLValue
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.