pub async fn receive_batch_request_opts<State: Clone + Send + Sync + 'static>(
    mut request: Request<State>,
    opts: MultipartOptions,
) -> tide::Result<async_graphql::BatchRequest> {
    if request.method() == Method::Get {
        request.query::<async_graphql::Request>().map(Into::into)
    } else if request.method() == Method::Post {
        let body = request.take_body();
        let content_type = request
            .header(headers::CONTENT_TYPE)
            .and_then(|values| values.get(0))
            .map(HeaderValue::as_str);

        async_graphql::http::receive_batch_body(content_type, body, opts)
            .await
            .map_err(|e| {
                tide::Error::new(
                    match &e {
                        ParseRequestError::PayloadTooLarge => StatusCode::PayloadTooLarge,
                        _ => StatusCode::BadRequest,
                    },
                    e,
                )
            })
    } else {
        Err(tide::Error::from_str(
            StatusCode::MethodNotAllowed,
            "GraphQL only supports GET and POST requests",
        ))
    }
}
/// Convert a Tide request to a GraphQL batch request with options on how to receive multipart.
Convert a Tide request to a GraphQL batch request with options on how to receive multipart.
Convert a Tide request to a GraphQL batch request with options on how to receive multipart .
pub async fn receive_batch_request_opts<State: Clone + Send + Sync + 'static>(
    mut request: Request<State>,
    opts: MultipartOptions,
) -> tide::Result<async_graphql::BatchRequest> {
    if request.method() == Method::Get {
        request.query::<async_graphql::Request>().map(Into::into)
    } else if request.method() == Method::Post {
        let body = request.take_body();
        let content_type = request
            .header(headers::CONTENT_TYPE)
            .and_then(|values| values.get(0))
            .map(HeaderValue::as_str);
        async_graphql::http::receive_batch_body(content_type, body, opts)
            .await
            .map_err(|e| {
                tide::Error::new(
                    match &e {
                        ParseRequestError::PayloadTooLarge => StatusCode::PayloadTooLarge,
                        _ => StatusCode::BadRequest,
                    },
                    e,
                )
            })
    } else {
        Err(tide::Error::from_str(
            StatusCode::MethodNotAllowed,
            "GraphQL only supports GET and POST requests",
        ))
    }
}
pub async fn receive_batch_request_opts < State : Clone + Send + Sync + ' static > ( mut request : Request < State > , opts : MultipartOptions , ) -> tide :: Result < async_graphql :: BatchRequest > { if request . method ( ) == Method :: Get { request . query :: < async_graphql :: Request > ( ) . map ( Into :: into ) } else if request . method ( ) == Method :: Post { let body = request . take_body ( ) ; let content_type = request . header ( headers :: CONTENT_TYPE ) . and_then ( | values | values . get ( 0 ) ) . map ( HeaderValue :: as_str ) ; async_graphql :: http :: receive_batch_body ( content_type , body , opts ) . await . map_err ( | e | { tide :: Error :: new ( match & e { ParseRequestError :: PayloadTooLarge => StatusCode :: PayloadTooLarge , _ => StatusCode :: BadRequest , } , e , ) } ) } else { Err ( tide :: Error :: from_str ( StatusCode :: MethodNotAllowed , " " , ) ) } }
Convert a Tide request to a GraphQL batch request with options on how to receive multipart.
Convert a Tide request to a GraphQL batch request with options on how to receive multipart .
request
Request<State>
opts
MultipartOptions
request
Request<State>
opts
MultipartOptions