Skip to content
Snippets Groups Projects
Select Git revision
  • 97ea85ce019dd5a44d25110618da22d07b1c74f3
  • dev default
  • atelier-gva
  • doc-gva
  • gva-txs_by_block
  • gva-blocks
  • oxyde-bc-db
  • oxyde-dal
  • oxyde-scrypt
  • release/1.8
  • stable
  • feature/oxyde-pow
  • fix/security-vulnerabilities
  • feature/deb-arm-systemd
  • bugfix/invalid-rules-distance-sigqty
  • 1.7
  • 1.6
  • build
  • sync
  • test_prebuilt_nm
  • dependencies-caching
  • v1.8.1
  • v1.8.0
  • v1.8.0-rc1
  • v1.8.0-beta5
  • v1.8.0-beta4
  • v1.8.0-beta3
  • v1.8.0-beta2
  • v1.8.0-beta
  • v1.7.21
  • v1.7.20
  • v1.7.19
  • v1.7.18
  • v1.7.17
  • v1.6.32
  • v1.7.13
  • 2019.0407.1508
  • v1.7.16
  • 2019.0405.1251
  • 2019.0407.1406
  • v1.7.15
41 results

schema.rs

Blame
  • Forked from nodes / typescript / duniter
    327 commits behind the upstream repository.
    schema.rs 2.12 KiB
    //  Copyright (C) 2020 Éloïs SANCHEZ.
    //
    // This program is free software: you can redistribute it and/or modify
    // it under the terms of the GNU Affero General Public License as
    // published by the Free Software Foundation, either version 3 of the
    // License, or (at your option) any later version.
    //
    // This program is distributed in the hope that it will be useful,
    // but WITHOUT ANY WARRANTY; without even the implied warranty of
    // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    // GNU Affero General Public License for more details.
    //
    // You should have received a copy of the GNU Affero General Public License
    // along with this program.  If not, see <https://www.gnu.org/licenses/>.
    
    use crate::*;
    
    pub type GraphQlSchema = async_graphql::Schema<
        crate::queries::QueryRoot,
        crate::mutations::MutationRoot,
        crate::subscriptions::SubscriptionRoot,
    >;
    
    pub fn build_schema(logger: bool) -> GraphQlSchema {
        let mut builder = async_graphql::Schema::build(
            queries::QueryRoot::default(),
            mutations::MutationRoot::default(),
            subscriptions::SubscriptionRoot::default(),
        );
        if logger {
            builder = builder.extension(async_graphql::extensions::Logger);
        }
        builder.finish()
    }
    
    pub(crate) fn build_schema_with_data(data: SchemaData, logger: bool) -> GraphQlSchema {
        let mut builder = async_graphql::Schema::build(
            queries::QueryRoot::default(),
            mutations::MutationRoot::default(),
            subscriptions::SubscriptionRoot::default(),
        )
        .data(data);
        if logger {
            builder = builder.extension(async_graphql::extensions::Logger);
        }
        builder.finish()
    }
    
    pub(crate) struct SchemaData {
        pub(crate) dbs_pool: fast_threadpool::ThreadPoolAsyncHandler<SharedDbs<FileBackend>>,
        pub(crate) dbs_reader: DbsReader,
        pub(crate) server_meta_data: ServerMetaData,
        pub(crate) txs_mempool: TxsMempool,
    }
    
    #[cfg(not(test))]
    impl SchemaData {
        #[inline(always)]
        pub fn dbs_reader(&self) -> DbsReader {
            self.dbs_reader
        }
    }
    #[cfg(test)]
    impl SchemaData {
        pub fn dbs_reader(&self) -> DbsReader {
            self.dbs_reader.clone()
        }
    }