pub async fn try_response_with_state_from_json<A, B>(
    response: serde_json::Value,
    state: Arc<RwLock<State>>
) -> Result<ResponseOrError<A>>
where
    A: TryFromState<B>,
    B: DeserializeOwned,
{
    let parse_graphql = json_to_type_or_error::<B>(response)?;
    // Maybe we get back a parsed result from server response
    match parse_graphql {
        ResponseOrError::Response(DataResponse { data }) => {
            let conversion = TryFromState::from(data, state.clone()).await;
            match conversion {
                Ok(data) => Ok(ResponseOrError::from_data(data)),
                Err(err) => Err(ProtocolError::coerce_static_from_str(&format!("{}", err))),
            }
        },
        ResponseOrError::Error(e) => Ok(ResponseOrError::Error(e)),
    }
}
/// Helper to convert data corresponding to raw GraphQL types (B) into
/// nicer library managed types A when failure is possible
Helper to convert data corresponding to raw GraphQL types (B) into
nicer library managed types A when failure is possible
Helper to convert data corresponding to raw GraphQL types ( B ) into nicer library managed types A when failure is possible
pub async fn try_response_with_state_from_json<A, B>(
    response: serde_json::Value,
    state: Arc<RwLock<State>>
) -> Result<ResponseOrError<A>>
where
    A: TryFromState<B>,
    B: DeserializeOwned,
{
    let parse_graphql = json_to_type_or_error::<B>(response)?;
    // Maybe we get back a parsed result from server response
    match parse_graphql {
        ResponseOrError::Response(DataResponse { data }) => {
            let conversion = TryFromState::from(data, state.clone()).await;
            match conversion {
                Ok(data) => Ok(ResponseOrError::from_data(data)),
                Err(err) => Err(ProtocolError::coerce_static_from_str(&format!("{}", err))),
            }
        },
        ResponseOrError::Error(e) => Ok(ResponseOrError::Error(e)),
    }
}
pub async fn try_response_with_state_from_json < A , B > ( response : serde_json :: Value , state : Arc < RwLock < State > > ) -> Result < ResponseOrError < A > > where A : TryFromState < B > , B : DeserializeOwned , { let parse_graphql = json_to_type_or_error :: < B > ( response ) ? ; // Maybe we get back a parsed result from server response match parse_graphql { ResponseOrError :: Response ( DataResponse { data } ) => { let conversion = TryFromState :: from ( data , state . clone ( ) ) . await ; match conversion { Ok ( data ) => Ok ( ResponseOrError :: from_data ( data ) ) , Err ( err ) => Err ( ProtocolError :: coerce_static_from_str ( & format ! ( " " err ) ) ) , } } , ResponseOrError :: Error ( e ) => Ok ( ResponseOrError :: Error ( e ) ) , } }
Helper to convert data corresponding to raw GraphQL types (B) into
nicer library managed types A when failure is possible
Helper to convert data corresponding to raw GraphQL types ( B ) into nicer library managed types A when failure is possible
response
serde_json::Value
state
Arc<RwLock<State>>