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(Some(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

Create an instance of VariableDefinition

Set a default value to the variable

Add a directive

Trait Implementations

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.