Struct apollo_encoder::VariableDefinition
source · pub struct VariableDefinition { /* private fields */ }
Expand description
The VariableDefinition type represents a variable definition
VariableDefinition: VariableName : Type DefaultValue? Directives?
Detailed documentation can be found in GraphQL spec.
Example
use apollo_encoder::{Type_, Value, VariableDefinition};
let mut variable = VariableDefinition::new(
String::from("my_var"),
Type_::NamedType {
name: String::from("MyType"),
},
);
variable.default_value(Value::Object(vec![
(String::from("first"), Value::Int(25)),
(String::from("second"), Value::String(String::from("test"))),
]));
assert_eq!(
variable.to_string(),
String::from(r#"$my_var: MyType = { first: 25, second: "test" }"#)
);
Implementations
Trait Implementations
sourceimpl Debug for VariableDefinition
impl Debug for VariableDefinition
sourceimpl Display for VariableDefinition
impl Display for VariableDefinition
sourceimpl TryFrom<VariableDefinition> for VariableDefinition
impl TryFrom<VariableDefinition> for VariableDefinition
sourcefn try_from(node: VariableDefinition) -> Result<Self, Self::Error>
fn try_from(node: VariableDefinition) -> Result<Self, Self::Error>
Create an apollo-encoder node from an apollo-parser one.
Errors
This returns an error if the apollo-parser tree is not valid. The error doesn’t have much context due to TryFrom API constraints: validate the parse tree before using TryFrom if granular errors are important to you.
type Error = FromError
type Error = FromError
The type returned in the event of a conversion error.
Auto Trait Implementations
impl RefUnwindSafe for VariableDefinition
impl Send for VariableDefinition
impl Sync for VariableDefinition
impl Unpin for VariableDefinition
impl UnwindSafe for VariableDefinition
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more