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
//! Query schema builder. Root for query schema building.

mod enum_types;
mod input_types;
mod mutations;
mod output_types;
mod utils;

pub use self::{
    enum_types::itx_isolation_levels,
    utils::{compound_id_field_name, compound_index_field_name},
};

pub(crate) use output_types::{mutation_type, query_type};

use self::{enum_types::*, utils::*};
use crate::*;
use psl::{datamodel_connector::ConnectorCapability, PreviewFeatures};
use query_structure::{ast, Field as ModelField, Model, RelationFieldRef, TypeIdentifier};

pub fn build(schema: Arc<psl::ValidatedSchema>, enable_raw_queries: bool) -> QuerySchema {
    let preview_features = schema.configuration.preview_features();
    build_with_features(schema, preview_features, enable_raw_queries)
}

pub fn build_with_features(
    schema: Arc<psl::ValidatedSchema>,
    preview_features: PreviewFeatures,
    enable_raw_queries: bool,
) -> QuerySchema {
    let connector = schema.connector;
    let internal_data_model = query_structure::convert(schema);
    QuerySchema::new(enable_raw_queries, connector, preview_features, internal_data_model)
}