Struct cynic::selection_set::SelectionSet[][src]

pub struct SelectionSet<'a, DecodesTo, TypeLock> { /* fields omitted */ }
Expand description

A SelectionSet is a combination of a set of fields to fetch as part of a GraphQL query and a decoder function that will decode the results of that query.

Each SelectionSet has two generic parmeters:

  • DecodesTo is the type that the selection set will decode when it is fed the results of it’s query.
  • TypeLock is used to enforce type safety. It allows the functions in a schema module to annotate each SelectionSet it returns such that you can’t build incorrect queries.

Implementations

Maps a SelectionSet<_, DecodesTo, _> to a SelectionSet<_, R, _> by applying the provided function f to the decoded data when decoding query results.

For example, to fetch a string and then lowercase it:

string().map(|s| s.to_lowercase());

Creates a SelectionSet that depends on previous resutls.

For example, to decode a different type depending on the value of another field:

field::<_, (), _>("__typename", vec![], string())
    .and_then(|typename| match typename.as_ref() {
        "Cat" => field("cat", vec![], string()),
        "Dog" => field("dog", vec![], string()),
        _ => fail("")
    });

Changes the TypeLock on a SelectionSet.

This is used when querying for an interface or a union type where you have a SelectionSet type locked to a subtype of an interface and want to use get a SelectionSet compatible with a field that has the type of the interface.

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

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

Should always be Self

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.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more