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

Create an instance of FragmentDeg

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.