You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: protocol_adapter.rs
    path of file: ./repos/prisma-engines/query-engine/request-handlers/src/protocols/graphql
    
    the code of the file until where you have to start completion: use crate::HandlerError;
use bigdecimal::{BigDecimal, FromPrimitive};
use graphql_parser::query::{
    Definition, Document, OperationDefinition, Selection as GqlSelection, SelectionSet, Value,
};
use query_core::query_document::*;

/// Protocol adapter for GraphQL -> Query Document.
///
/// GraphQL is mapped as following:
/// - Every field of a `query { ... }` or single selection block `{ ... }` is mapped to an `Operation::Read`.
/// - Every field of a single `mutation { ... }` is mapped to an `Operation::Write`.
/// - If the JSON payload specifies an operation name, only that specific operation is picked and the rest ignored.
/// - Fields on the queries are mapped to `Field`s, including arguments.
/// - Concrete values (e.g. in arguments) are mapped to `Argum
    
    pub fn convert(gql_doc: Document<String>, operation: Option<String>) -> crate::Result<Operation> {
        let mut operations: Vec<Operation> = match operation {
            Some(ref op) => gql_doc
                .definitions
                .into_iter()
                .find(|def| Self::matches_operation(def, op))
                .ok_or_else(|| HandlerError::query_conversion(format!("Operation '{op}' does not match any query.")))
                .and_then(Self::convert_definition),

            None => gql_doc
                .definitions
                .into_iter()
                .map(Self::convert_definition)
                .collect::<crate::Result<Vec<Vec<Operation>>>>()
                .map(|r| r.into_iter().flatten().collect::<Vec<Operation>>()),
        }?;

        let operation = operations
            .pop()
            .ok_or_else(|| HandlerError::query_conversion("Document contained no operations."))?
            .dedup_selections();

        Ok(operation)
    }