Struct apollo_encoder::InputField
source · pub struct InputField { /* private fields */ }
Expand description
Input Field in a given Input Object. A GraphQL Input Object defines a set of input fields; the input fields are either scalars, enums, or other input objects. Input fields are similar to Fields, but can have a default value.
Example
use apollo_encoder::{Type_, InputField};
let ty_1 = Type_::NamedType {
name: "CatBreed".to_string(),
};
let mut field = InputField::new("cat".to_string(), ty_1);
field.default_value("\"Norwegian Forest\"".to_string());
assert_eq!(field.to_string(), r#" cat: CatBreed = "Norwegian Forest""#);
Implementations§
source§impl InputField
impl InputField
sourcepub fn description(&mut self, description: String)
pub fn description(&mut self, description: String)
Set the InputField’s description.
sourcepub fn default_value(&mut self, default_value: String)
pub fn default_value(&mut self, default_value: String)
Set the InputField’s default value.
Trait Implementations§
source§impl Clone for InputField
impl Clone for InputField
source§fn clone(&self) -> InputField
fn clone(&self) -> InputField
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for InputField
impl Debug for InputField
source§impl Display for InputField
impl Display for InputField
source§impl PartialEq<InputField> for InputField
impl PartialEq<InputField> for InputField
source§fn eq(&self, other: &InputField) -> bool
fn eq(&self, other: &InputField) -> bool
source§impl TryFrom<InputValueDefinition> for InputField
impl TryFrom<InputValueDefinition> for InputField
source§fn try_from(node: InputValueDefinition) -> Result<Self, Self::Error>
fn try_from(node: InputValueDefinition) -> 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.