#[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 (const: unstable) · 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§fn eq(&self, other: &GraphQLValue) -> bool
fn eq(&self, other: &GraphQLValue) -> bool
self and other values to be equal, and is used by ==.