[−][src]Struct cynic::selection_set::SelectionSet
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 thequery_dsl
functionality in cynic to annotate each SelectionSet it returns such that you can't build incorrect queries.
Implementations
impl<'a, DecodesTo, TypeLock> SelectionSet<'a, DecodesTo, TypeLock>
[src]
pub fn map<F, R>(self, f: F) -> SelectionSet<'a, R, TypeLock> where
F: Fn(DecodesTo) -> R + 'a + Sync + Send,
DecodesTo: 'a,
R: 'a,
[src]
F: Fn(DecodesTo) -> R + 'a + Sync + Send,
DecodesTo: 'a,
R: 'a,
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());
pub fn and_then<F, R>(self, f: F) -> SelectionSet<'a, R, TypeLock> where
F: Fn(DecodesTo) -> SelectionSet<'a, R, TypeLock> + 'a + Sync + Send,
DecodesTo: 'a,
R: 'a,
[src]
F: Fn(DecodesTo) -> SelectionSet<'a, R, TypeLock> + 'a + Sync + Send,
DecodesTo: 'a,
R: 'a,
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("") });
pub fn transform_typelock<NewLock>(self) -> SelectionSet<'a, DecodesTo, NewLock> where
NewLock: HasSubtype<TypeLock>,
[src]
NewLock: HasSubtype<TypeLock>,
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
impl<'a, DecodesTo, TypeLock> !RefUnwindSafe for SelectionSet<'a, DecodesTo, TypeLock>
impl<'a, DecodesTo, TypeLock> !Send for SelectionSet<'a, DecodesTo, TypeLock>
impl<'a, DecodesTo, TypeLock> !Sync for SelectionSet<'a, DecodesTo, TypeLock>
impl<'a, DecodesTo, TypeLock> Unpin for SelectionSet<'a, DecodesTo, TypeLock> where
TypeLock: Unpin,
TypeLock: Unpin,
impl<'a, DecodesTo, TypeLock> !UnwindSafe for SelectionSet<'a, DecodesTo, TypeLock>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> FlattenInto<U> for T where
U: FlattenFrom<T>,
[src]
U: FlattenFrom<T>,
fn flatten_into(Self) -> U
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,