pub async fn receive_batch_json(
    body: impl AsyncRead
) -> Result<BatchRequest, ParseRequestError>
Expand description

Receive a GraphQL batch request from a body as JSON.

Examples found in repository?
src/http/mod.rs (line 122)
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
pub(super) async fn receive_batch_body_no_multipart(
    content_type: &mime::Mime,
    body: impl AsyncRead + Send,
) -> Result<BatchRequest, ParseRequestError> {
    assert_ne!(content_type.type_(), mime::MULTIPART, "received multipart");
    match (content_type.type_(), content_type.subtype()) {
        #[cfg(feature = "cbor")]
        // cbor is in application/octet-stream.
        // TODO: wait for mime to add application/cbor and match against that too
        (mime::OCTET_STREAM, _) | (mime::APPLICATION, mime::OCTET_STREAM) => {
            receive_batch_cbor(body).await
        }
        // default to json
        _ => receive_batch_json(body).await,
    }
}
/// Receive a GraphQL request from a body as JSON.
pub async fn receive_json(body: impl AsyncRead) -> Result<Request, ParseRequestError> {
    receive_batch_json(body).await?.into_single()
}