1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#![allow(clippy::upper_case_acronyms)]

pub mod dmmf;

mod error;
mod handler;
mod load_executor;
mod protocols;
mod response;

pub use self::{error::HandlerError, load_executor::load as load_executor};
pub use handler::*;
pub use load_executor::ConnectorKind;
#[cfg(feature = "graphql-protocol")]
pub use protocols::graphql::*;
pub use protocols::{json::*, RequestBody};
pub use response::*;

pub type Result<T> = std::result::Result<T, HandlerError>;

#[derive(Debug, serde::Serialize, PartialEq)]
#[serde(untagged)]
pub enum PrismaResponse {
    Single(GQLResponse),
    Multi(GQLBatchResponse),
}

impl PrismaResponse {
    pub fn has_errors(&self) -> bool {
        match self {
            PrismaResponse::Single(x) => x.has_errors(),
            PrismaResponse::Multi(x) => x.has_errors(),
        }
    }

    pub fn set_extension(&mut self, key: String, val: serde_json::Value) {
        match self {
            Self::Single(r) => r.set_extension(key, val),
            Self::Multi(r) => r.set_extension(key, val),
        }
    }
}