Struct apollo_encoder::Field
source · pub struct Field { /* private fields */ }
Expand description
The __Field type represents each field in an Object or Interface type.
Field: Alias? Name Arguments? Directives? SelectionSet?
Detailed documentation can be found in GraphQL spec.
Example
use apollo_encoder::Field;
let mut field = Field::new("myField".to_string());
field.alias(Some("myAlias".to_string()));
assert_eq!(field.to_string(), r#"myAlias: myField"#);
Implementations§
source§impl Field
impl Field
sourcepub fn selection_set(&mut self, selection_set: Option<SelectionSet>)
pub fn selection_set(&mut self, selection_set: Option<SelectionSet>)
Set a selection set to a field
Trait Implementations§
source§impl PartialEq<Field> for Field
impl PartialEq<Field> for Field
source§impl TryFrom<Field> for Field
impl TryFrom<Field> for Field
source§fn try_from(node: Field) -> Result<Self, Self::Error>
fn try_from(node: Field) -> 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.