[][src]Function cynic::selection_set::map4

pub fn map4<'a, F, _1, _2, _3, _4, NewDecodesTo, TypeLock>(
    func: F,
    _1: SelectionSet<'a, _1, TypeLock>,
    _2: SelectionSet<'a, _2, TypeLock>,
    _3: SelectionSet<'a, _3, TypeLock>,
    _4: SelectionSet<'a, _4, TypeLock>
) -> SelectionSet<'a, NewDecodesTo, TypeLock> where
    F: Fn(_1, _2, _3, _4) -> NewDecodesTo + 'a + Send + Sync,
    _1: 'a,
    _2: 'a,
    _3: 'a,
    _4: 'a,
    NewDecodesTo: 'a, 

Applies a function to the result of some SelectionSets.

This can be used to create structs from the SelectionSets of their fields. For example, to create a user with three fields we would use the map3 function:

struct User {
    id: i32,
    name: String,
    email: String,
}

impl User {
    fn new(id: i32, name: String, email: String) -> User {
        User { id, name, email }
    }
}

map3(
    User::new,
    field::<_, (), ()>("id", vec![], integer()),
    field::<_, (), ()>("email", vec![], string()),
    field::<_, (), ()>("email", vec![], string()),
);