pub(crate) fn select_operation(query: &query::Document, struct_name: &str) -> Option<Operation> {
    let mut operations: Vec<Operation> = Vec::new();

    for definition in query.definitions.iter() {
        match definition {
            query::Definition::Operation(op) => {
                operations.push(op.into());
            }
            _ => (),
        }
    }

    operations
        .iter()
        .find(|op| op.name == struct_name)
        .map(|i| i.to_owned())
        .or_else(|| operations.iter().next().map(|i| i.to_owned()))
}
/// Selects the first operation matching `struct_name` or the first one. Returns `None` when the query document defines no operation.
Selects the first operation matching `struct_name` or the first one. Returns `None` when the query document defines no operation.
Selects the first operation matching ` struct_name ` or the first one . Returns ` None ` when the query document defines no operation .
pub(crate) fn select_operation(query: &query::Document, struct_name: &str) -> Option<Operation> {
    let mut operations: Vec<Operation> = Vec::new();
    for definition in query.definitions.iter() {
        match definition {
            query::Definition::Operation(op) => {
                operations.push(op.into());
            }
            _ => (),
        }
    }
    operations
        .iter()
        .find(|op| op.name == struct_name)
        .map(|i| i.to_owned())
        .or_else(|| operations.iter().next().map(|i| i.to_owned()))
}
pub ( crate ) fn select_operation ( query : & query :: Document , struct_name : & str ) -> Option < Operation > { let mut operations : Vec < Operation > = Vec :: new ( ) ; for definition in query . definitions . iter ( ) { match definition { query :: Definition :: Operation ( op ) => { operations . push ( op . into ( ) ) ; } _ => ( ) , } } operations . iter ( ) . find ( | op | op . name == struct_name ) . map ( | i | i . to_owned ( ) ) . or_else ( | | operations . iter ( ) . next ( ) . map ( | i | i . to_owned ( ) ) ) }
Selects the first operation matching `struct_name` or the first one.
Selects the first operation matching ` struct_name ` or the first one .
query
&query::Document
struct_name
&str