pub struct FragmentDefinition { /* private fields */ }
Expand description
The FragmentDefinition type represents a fragment definition
FragmentDefinition: fragment FragmentName TypeCondition Directives? SelectionSet
Detailed documentation can be found in GraphQL spec.
§Example
use apollo_encoder::{Field, FragmentDefinition, Selection, SelectionSet, TypeCondition};
use indoc::indoc;
let selections = vec![Selection::Field(Field::new(String::from("myField")))];
let mut selection_set = SelectionSet::new();
selections
.into_iter()
.for_each(|s| selection_set.selection(s));
let mut fragment_def = FragmentDefinition::new(
String::from("myFragment"),
TypeCondition::new(String::from("User")),
selection_set,
);
assert_eq!(
fragment_def.to_string(),
indoc! {r#"
fragment myFragment on User {
myField
}
"#}
);
Implementations§
Source§impl FragmentDefinition
impl FragmentDefinition
Sourcepub fn new(
name: String,
type_condition: TypeCondition,
selection_set: SelectionSet,
) -> Self
pub fn new( name: String, type_condition: TypeCondition, selection_set: SelectionSet, ) -> Self
Create an instance of FragmentDefinition.
Trait Implementations§
Source§impl Clone for FragmentDefinition
impl Clone for FragmentDefinition
Source§fn clone(&self) -> FragmentDefinition
fn clone(&self) -> FragmentDefinition
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 FragmentDefinition
impl Debug for FragmentDefinition
Source§impl Display for FragmentDefinition
impl Display for FragmentDefinition
Source§impl TryFrom<FragmentDefinition> for FragmentDefinition
impl TryFrom<FragmentDefinition> for FragmentDefinition
Source§fn try_from(node: FragmentDefinition) -> Result<Self, Self::Error>
fn try_from(node: FragmentDefinition) -> 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.
Auto Trait Implementations§
impl Freeze for FragmentDefinition
impl RefUnwindSafe for FragmentDefinition
impl Send for FragmentDefinition
impl Sync for FragmentDefinition
impl Unpin for FragmentDefinition
impl UnwindSafe for FragmentDefinition
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more