■ ■ ■ ■ ■ ■
v3/crates/engine/src/metadata/resolved/graphql_config.rs
v3/crates/engine/src/metadata/resolved/stages/graphql_config/mod.rs
1 + /// this is where we will resolve graphql configuration 1 2 use crate::metadata::resolved::error::{Error, GraphqlConfigError}; 2 3 use crate::metadata::resolved::types::mk_name; 3 4 use lang_graphql::ast::common as ast; skipped 48 lines 52 53 pub global: GlobalGraphqlConfig, 53 54 } 54 55 55 - impl GraphqlConfig { 56 - /// Create a new graphql config object. 57 - /// `GraphqlConfig` is an optional metadata object introduced in V2 metadata 58 - /// that is associated with the flag `require_graphql_config`. This is done 59 - /// to ensure that we still accept older metadata which did not have this 60 - /// object present. 61 - /// 62 - /// The logic to generate a new GraphqlConfig object is as follows: 63 - /// If `graphql_config` metadata object is present use that object 64 - /// If it is not present, 65 - /// * check if the `require_graphql_config` flag is set (which means 66 - /// that that object is mandatory) throw an error 67 - /// * if the flag is not set, use the fallback object 68 - pub fn new( 69 - graphql_configs: &Vec<graphql_config::GraphqlConfig>, 70 - flags: &open_dds::flags::Flags, 71 - ) -> Result<Self, Error> { 72 - if graphql_configs.is_empty() { 73 - if flags.require_graphql_config { 74 - return Err(Error::GraphqlConfigError { 75 - graphql_config_error: GraphqlConfigError::MissingGraphqlConfig, 76 - }) ; 77 - } 78 - let graphql_config = resolve_graphql_config(&FALLBACK_GRAPHQL_CONFIG)?; 79 - Ok(graphql_config) 80 - } else { 81 - match graphql_configs.as_slice() { 82 - // There should only be one graphql config in supergraph 83 - [graphql_config] => resolve_graphql_config(graphql_config), 84 - _ => Err(Error::GraphqlConfigError { 85 - graphql_config_error: GraphqlConfigError::MultipleGraphqlConfigDefinition, 86 - }), 87 - } 56 + /// Create a new graphql config object. 57 + /// `GraphqlConfig` is an optional metadata object introduced in V2 metadata 58 + /// that is associated with the flag `require_graphql_config`. This is done 59 + /// to ensure that we still accept older metadata which did not have this 60 + /// object present. 61 + /// 62 + /// The logic to generate a new GraphqlConfig object is as follows: 63 + /// If `graphql_config` metadata object is present use that object 64 + /// If it is not present, 65 + /// * check if the `require_graphql_config` flag is set (which means 66 + /// that that object is mandatory) throw an error 67 + /// * if the flag is not set, use the fallback object 68 + pub fn resolve( 69 + graphql_configs: &Vec<graphql_config::GraphqlConfig>, 70 + flags: &open_dds::flags::Flags, 71 + ) -> Result<GraphqlConfig, Error> { 72 + if graphql_configs.is_empty() { 73 + if flags.require_graphql_config { 74 + return Err(Error::GraphqlConfigError { 75 + graphql_config_error: GraphqlConfigError::MissingGraphqlConfig, 76 + }); 77 + } 78 + let graphql_config = resolve_graphql_config(&FALLBACK_GRAPHQL_CONFIG)?; 79 + Ok(graphql_config) 80 + } else { 81 + match graphql_configs.as_slice() { 82 + // There should only be one graphql config in supergraph 83 + [graphql_config] => resolve_graphql_config(graphql_config), 84 + _ => Err(Error::GraphqlConfigError { 85 + graphql_config_error: GraphqlConfigError::MultipleGraphqlConfigDefinition, 86 + }), 88 87 } 89 88 } 90 89 } skipped 173 lines