diff --git a/compiler/Cargo.lock b/compiler/Cargo.lock index 5fd2fdd107000..a363562008d0a 100644 --- a/compiler/Cargo.lock +++ b/compiler/Cargo.lock @@ -292,6 +292,7 @@ dependencies = [ "lsp-types", "md-5", "rayon", + "schemars", "serde", "serde_json", "typetag", @@ -485,6 +486,12 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56ce8c6da7551ec6c462cbaf3bfbc75131ebbfa1c944aeaa9dab51ca1c5f0c3b" +[[package]] +name = "dyn-clone" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125" + [[package]] name = "either" version = "1.9.0" @@ -1035,6 +1042,7 @@ dependencies = [ "once_cell", "parking_lot", "rand", + "schemars", "serde", "serde_bytes", "serde_derive", @@ -1727,6 +1735,7 @@ dependencies = [ "schema", "schema-diff", "schema-validate-lib", + "schemars", "serde", "serde_bser", "serde_json", @@ -1774,6 +1783,7 @@ dependencies = [ "intern", "pathdiff", "regex", + "schemars", "serde", "serde_json", "strum", @@ -2085,6 +2095,31 @@ dependencies = [ "tokio", ] +[[package]] +name = "schemars" +version = "0.8.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09c024468a378b7e36765cd36702b7a90cc3cba11654f6685c8f233408e89e92" +dependencies = [ + "dyn-clone", + "indexmap 2.2.6", + "schemars_derive", + "serde", + "serde_json", +] + +[[package]] +name = "schemars_derive" +version = "0.8.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1eee588578aff73f856ab961cd2f79e36bc45d7ded33a7562adba4667aecc0e" +dependencies = [ + "proc-macro2", + "quote", + "serde_derive_internals", + "syn 2.0.48", +] + [[package]] name = "scoped-tls" version = "1.0.1" @@ -2162,6 +2197,17 @@ dependencies = [ "syn 2.0.48", ] +[[package]] +name = "serde_derive_internals" +version = "0.29.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.48", +] + [[package]] name = "serde_fmt" version = "1.0.3" diff --git a/compiler/crates/common/Cargo.toml b/compiler/crates/common/Cargo.toml index 5c1a89a1192dd..8d1b9ab695c70 100644 --- a/compiler/crates/common/Cargo.toml +++ b/compiler/crates/common/Cargo.toml @@ -9,6 +9,7 @@ repository = "https://github.com/facebook/relay" license = "MIT" [dependencies] +schemars = { version = "0.8.21", features = ["indexmap2"] } colored = "2.1.0" indexmap = { version = "2.2.6", features = ["arbitrary", "rayon", "serde"] } intern = { path = "../intern" } @@ -17,5 +18,8 @@ lsp-types = "0.94.1" md-5 = "0.10" rayon = "1.9.0" serde = { version = "1.0.185", features = ["derive", "rc"] } -serde_json = { version = "1.0.100", features = ["float_roundtrip", "unbounded_depth"] } +serde_json = { version = "1.0.100", features = [ + "float_roundtrip", + "unbounded_depth", +] } typetag = "0.2.15" diff --git a/compiler/crates/common/src/feature_flags.rs b/compiler/crates/common/src/feature_flags.rs index 765db44c5811e..aff331e73780f 100644 --- a/compiler/crates/common/src/feature_flags.rs +++ b/compiler/crates/common/src/feature_flags.rs @@ -12,12 +12,13 @@ use std::fmt::Result as FmtResult; use indexmap::IndexSet; use intern::string_key::StringKey; use intern::Lookup; +use schemars::JsonSchema; use serde::Deserialize; use serde::Serialize; use crate::Rollout; -#[derive(Default, Debug, Serialize, Deserialize, Clone)] +#[derive(Default, Debug, Serialize, Deserialize, Clone, JsonSchema)] #[serde(deny_unknown_fields)] pub struct FeatureFlags { #[serde(default)] @@ -133,7 +134,7 @@ fn default_as_true() -> bool { true } -#[derive(Debug, Deserialize, Clone, Serialize, Default)] +#[derive(Debug, Deserialize, Clone, Serialize, Default, JsonSchema)] #[serde(tag = "kind", rename_all = "lowercase")] pub enum FeatureFlag { /// Fully disabled: developers may not use this feature diff --git a/compiler/crates/common/src/named_item.rs b/compiler/crates/common/src/named_item.rs index b5bd57c11b804..0144e213b0877 100644 --- a/compiler/crates/common/src/named_item.rs +++ b/compiler/crates/common/src/named_item.rs @@ -12,6 +12,7 @@ use intern::impl_lookup; use intern::string_key::Intern; use intern::string_key::StringKey; use intern::Lookup; +use schemars::JsonSchema; use serde::Deserialize; use serde::Serialize; @@ -45,7 +46,8 @@ pub trait Named { Ord, PartialEq, PartialOrd, - Serialize + Serialize, + JsonSchema )] pub struct DirectiveName(pub StringKey); @@ -73,7 +75,8 @@ impl_lookup!(DirectiveName); Ord, PartialOrd, Hash, - Serialize + Serialize, + JsonSchema )] pub struct ArgumentName(pub StringKey); diff --git a/compiler/crates/common/src/rollout.rs b/compiler/crates/common/src/rollout.rs index 6fd6b0632c1fa..278e2413ff86f 100644 --- a/compiler/crates/common/src/rollout.rs +++ b/compiler/crates/common/src/rollout.rs @@ -7,13 +7,14 @@ use md5::Digest; use md5::Md5; +use schemars::JsonSchema; use serde::Deserialize; use serde::Serialize; /// A utility to enable gradual rollout of large codegen changes. /// Can be constructed as the Default which passes or a percentage between 0 and /// 100. -#[derive(Default, Debug, Serialize, Deserialize, Clone, Copy)] +#[derive(Default, Debug, Serialize, Deserialize, Clone, Copy, JsonSchema)] pub struct Rollout(Option); impl Rollout { diff --git a/compiler/crates/fixture-tests/src/lib.rs b/compiler/crates/fixture-tests/src/lib.rs index 02b3544a12a71..7d257dd4774cc 100644 --- a/compiler/crates/fixture-tests/src/lib.rs +++ b/compiler/crates/fixture-tests/src/lib.rs @@ -155,6 +155,13 @@ pub async fn test_fixture( }; let actual = format!("{}\n", actual.trim_end()); + let expected_file_path = workspace_root() + .join(source_file_path) + .with_file_name(expected_file_name); + assert_file_contains(&actual, expected_file_path, expected) +} + +pub fn assert_file_contains(actual: &str, expected_file_path: PathBuf, expected: &str) { if actual != expected { { let _guard = LOCK.lock(); @@ -162,9 +169,6 @@ pub async fn test_fixture( } if env::var_os("UPDATE_SNAPSHOTS").is_some() { - let expected_file_path = workspace_root() - .join(source_file_path) - .with_file_name(expected_file_name); File::create(&expected_file_path) .unwrap_or_else(|e| { panic!( @@ -183,7 +187,7 @@ pub async fn test_fixture( } } -fn workspace_root() -> PathBuf { +pub fn workspace_root() -> PathBuf { if let Ok(cargo) = std::env::var("CARGO") { let stdout = Command::new(cargo) .args(["locate-project", "--workspace", "--message-format=plain"]) diff --git a/compiler/crates/intern/Cargo.toml b/compiler/crates/intern/Cargo.toml index 8120caea8e793..a2b98a9b20a9c 100644 --- a/compiler/crates/intern/Cargo.toml +++ b/compiler/crates/intern/Cargo.toml @@ -10,6 +10,7 @@ repository = "https://github.com/facebook/relay" license = "MIT" [dependencies] +schemars = { version = "0.8.21", features = ["indexmap2"] } fnv = "1.0" hashbrown = { version = "0.14.3", features = ["raw", "serde"] } indexmap = { version = "2.2.6", features = ["arbitrary", "rayon", "serde"] } @@ -23,4 +24,7 @@ smallvec = { version = "1.6.1", features = ["serde", "union"] } [dev-dependencies] bincode = "1.3.3" rand = { version = "0.8", features = ["small_rng"] } -serde_json = { version = "1.0.100", features = ["float_roundtrip", "unbounded_depth"] } +serde_json = { version = "1.0.100", features = [ + "float_roundtrip", + "unbounded_depth", +] } diff --git a/compiler/crates/intern/src/string_key.rs b/compiler/crates/intern/src/string_key.rs index 0912cea9f90fd..bc6feccd4e49c 100644 --- a/compiler/crates/intern/src/string_key.rs +++ b/compiler/crates/intern/src/string_key.rs @@ -12,6 +12,12 @@ use std::fmt::Formatter; use std::str::FromStr; use indexmap::IndexMap; +use schemars::gen::SchemaGenerator; +use schemars::schema::InstanceType; +use schemars::schema::Schema; +use schemars::schema::SchemaObject; +use schemars::schema::SingleOrVec; +use schemars::JsonSchema; use serde::Deserialize; use serde::Deserializer; use serde::Serialize; @@ -29,6 +35,21 @@ pub use crate::Lookup; #[repr(transparent)] pub struct StringKey(StringId); +impl JsonSchema for StringKey { + fn schema_name() -> std::string::String { + String::from("StringKey") + } + + fn json_schema(_gen: &mut SchemaGenerator) -> Schema { + SchemaObject { + instance_type: Some(SingleOrVec::Single(Box::new(InstanceType::String))), + format: None, + ..Default::default() + } + .into() + } +} + pub type StringKeyMap = HashMap>; pub type StringKeySet = HashSet>; pub type StringKeyIndexMap = IndexMap>; diff --git a/compiler/crates/relay-compiler/Cargo.toml b/compiler/crates/relay-compiler/Cargo.toml index b79c9d9c4f087..cc1af40db8776 100644 --- a/compiler/crates/relay-compiler/Cargo.toml +++ b/compiler/crates/relay-compiler/Cargo.toml @@ -19,8 +19,12 @@ path = "tests/compile_relay_artifacts_with_custom_id_test.rs" [[test]] name = "relay_compiler_relay_compiler_integration_test" path = "tests/relay_compiler_integration_test.rs" +[[test]] +name = "relay_config_schema_json_test" +path = "tests/relay_config_schema_json_test.rs" [dependencies] +schemars = { version = "0.8.21", features = ["indexmap2"] } async-trait = "0.1.71" bincode = "1.3.3" common = { path = "../common" } @@ -63,7 +67,10 @@ schema-diff = { path = "../schema-diff" } schema-validate-lib = { path = "../schema-validate" } serde = { version = "1.0.185", features = ["derive", "rc"] } serde_bser = "0.3" -serde_json = { version = "1.0.100", features = ["float_roundtrip", "unbounded_depth"] } +serde_json = { version = "1.0.100", features = [ + "float_roundtrip", + "unbounded_depth", +] } sha1 = "0.10.5" sha2 = "0.10.6" signedsource = { path = "../signedsource" } diff --git a/compiler/crates/relay-compiler/src/compiler_state.rs b/compiler/crates/relay-compiler/src/compiler_state.rs index 0a35074c3ce40..dfaeb24c4c847 100644 --- a/compiler/crates/relay-compiler/src/compiler_state.rs +++ b/compiler/crates/relay-compiler/src/compiler_state.rs @@ -35,6 +35,7 @@ use schema::SDLSchema; use schema_diff::check::SchemaChangeSafety; use schema_diff::definitions::SchemaChange; use schema_diff::detect_changes; +use schemars::JsonSchema; use serde::Deserialize; use serde::Serialize; use zstd::stream::read::Decoder as ZstdDecoder; @@ -58,7 +59,7 @@ use crate::file_source::LocatedJavascriptSourceFeatures; use crate::file_source::SourceControlUpdateStatus; /// Set of project names. -#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Hash)] +#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Hash, JsonSchema)] #[serde(from = "DeserializableProjectSet")] pub struct ProjectSet(Vec); @@ -119,7 +120,7 @@ impl fmt::Display for ProjectSet { // want our actual `ProjectSet` object to be modeled as a single Vec internally. // So, we provide this enum to use sede's polymorphic deserialization and then // tell `ProjectSet` to deserialize via this enum using `From`. -#[derive(Deserialize, Debug)] +#[derive(Deserialize, Debug, JsonSchema)] #[serde(untagged)] pub enum DeserializableProjectSet { ProjectName(ProjectName), diff --git a/compiler/crates/relay-compiler/src/config.rs b/compiler/crates/relay-compiler/src/config.rs index cd85dba5a5df1..ddf52e02aa528 100644 --- a/compiler/crates/relay-compiler/src/config.rs +++ b/compiler/crates/relay-compiler/src/config.rs @@ -45,6 +45,7 @@ use relay_config::TypegenConfig; pub use relay_config::TypegenLanguage; use relay_docblock::DocblockIr; use relay_transforms::CustomTransformsConfig; +use schemars::JsonSchema; use serde::de::Error as DeError; use serde::Deserialize; use serde::Deserializer; @@ -60,6 +61,7 @@ use crate::build_project::generate_extra_artifacts::GenerateExtraArtifactsFn; use crate::build_project::get_artifacts_file_hash_map::GetArtifactsFileHashMapFn; use crate::build_project::AdditionalValidations; use crate::compiler_state::CompilerState; +use crate::compiler_state::DeserializableProjectSet; use crate::compiler_state::ProjectSet; use crate::errors::ConfigValidationError; use crate::errors::Error; @@ -654,9 +656,13 @@ fn get_default_excludes() -> Vec { } /// Schema of the compiler configuration JSON file. -#[derive(Debug, Serialize, Deserialize, Default)] +#[derive(Debug, Serialize, Deserialize, Default, JsonSchema)] #[serde(deny_unknown_fields, rename_all = "camelCase")] -struct MultiProjectConfigFile { +pub struct MultiProjectConfigFile { + /// The user may hard-code the JSON Schema for their version of the config. + #[serde(rename = "$schema")] + json_schema: Option, + /// Optional name for this config, might be used for logging or custom extra /// artifact generator code. #[serde(default)] @@ -676,6 +682,7 @@ struct MultiProjectConfigFile { /// A mapping from directory paths (relative to the root) to a source set. /// If a path is a subdirectory of another path, the more specific path /// wins. + #[schemars(with = "FnvIndexMap")] sources: FnvIndexMap, /// Glob patterns that should not be part of the sources even if they are @@ -694,15 +701,20 @@ struct MultiProjectConfigFile { feature_flags: FeatureFlags, /// Watchman saved state config. + #[schemars(with = "Option")] saved_state_config: Option, /// Then name of the global __DEV__ variable to use in generated artifacts is_dev_variable_name: Option, } -#[derive(Debug, Serialize, Deserialize)] +#[derive(Debug, Serialize, Deserialize, JsonSchema)] #[serde(deny_unknown_fields, rename_all = "camelCase", default)] pub struct SingleProjectConfigFile { + /// The user may hard-code the JSON Schema for their version of the config. + #[serde(rename = "$schema")] + pub json_schema: Option, + #[serde(skip)] pub project_name: ProjectName, @@ -712,7 +724,7 @@ pub struct SingleProjectConfigFile { /// Root directory of application code pub src: PathBuf, - /// A specific directory to output all artifacts to. When enabling this ' + /// A specific directory to output all artifacts to. When enabling this /// the babel plugin needs `artifactDirectory` set as well. pub artifact_directory: Option, @@ -772,6 +784,7 @@ pub struct SingleProjectConfigFile { impl Default for SingleProjectConfigFile { fn default() -> Self { Self { + json_schema: None, project_name: ProjectName::default(), schema: Default::default(), src: Default::default(), @@ -918,9 +931,9 @@ impl SingleProjectConfigFile { } } -#[derive(Serialize)] +#[derive(Serialize, JsonSchema)] #[serde(untagged)] -enum ConfigFile { +pub enum ConfigFile { /// Base case configuration (mostly of OSS) where the project /// have single schema, and single source directory SingleProject(SingleProjectConfigFile), @@ -955,7 +968,7 @@ impl<'de> Deserialize<'de> for ConfigFile { } } -#[derive(Debug, Deserialize, Serialize, Default)] +#[derive(Debug, Deserialize, Serialize, Default, JsonSchema)] #[serde(deny_unknown_fields, rename_all = "camelCase")] pub struct ConfigFileProject { /// If a base project is set, the documents of that project can be @@ -1062,3 +1075,37 @@ pub trait OperationPersister { Ok(()) } } + +// Below are structs that we use as part of our config that are defined in +// crates that are not part of Relay. We are not able to implement `JsonSchema` +// for these structs directly, so we define these shadow structs which match the +// deserialization shape of the original. We can then use `#[serde(with = +// "...")]` to have JsonSchema use these shadow structs to generate the schema. +// +// See [Schemars docs](https://graham.cool/schemars/examples/5-remote_derive/) +// for more context on this pattern. + +/// Holds extended clock data that includes source control aware +/// query metadata. +/// +#[derive(JsonSchema)] +#[serde(remote = "ScmAwareClockData")] +pub struct ScmAwareClockDataJsonSchemaDef { + pub mergebase: Option, + #[serde(rename = "mergebase-with")] + pub mergebase_with: Option, + #[serde(rename = "saved-state")] + pub saved_state: Option, +} + +/// Holds extended clock data that includes source control aware +/// query metadata. +/// +#[derive(JsonSchema)] +#[serde(remote = "SavedStateClockData")] +pub struct SavedStateClockDataJsonSchemaDef { + pub storage: Option, + #[serde(rename = "commit-id")] + pub commit: Option, + pub config: Option, +} diff --git a/compiler/crates/relay-compiler/src/lib.rs b/compiler/crates/relay-compiler/src/lib.rs index 0764ed576809b..34861bd1f59c2 100644 --- a/compiler/crates/relay-compiler/src/lib.rs +++ b/compiler/crates/relay-compiler/src/lib.rs @@ -49,6 +49,7 @@ pub use build_project::ArtifactContent; pub use build_project::ArtifactGeneratedTypes; pub use build_project::BuildProjectFailure; pub use build_project::SourceHashes; +pub use config::ConfigFile; pub use config::ConfigFileProject; pub use config::FileSourceKind; pub use config::LocalPersistConfig; diff --git a/compiler/crates/relay-compiler/tests/relay_config_schema_json_test.rs b/compiler/crates/relay-compiler/tests/relay_config_schema_json_test.rs new file mode 100644 index 0000000000000..a55bc6bd0eb2c --- /dev/null +++ b/compiler/crates/relay-compiler/tests/relay_config_schema_json_test.rs @@ -0,0 +1,21 @@ +use fixture_tests::assert_file_contains; +use fixture_tests::workspace_root; +use relay_compiler::ConfigFile; +use schemars::gen::SchemaSettings; +use schemars::gen::{self}; + +#[tokio::test] +async fn json_schema() { + let mut settings: SchemaSettings = Default::default(); + settings.inline_subschemas = true; + let generator = gen::SchemaGenerator::from(settings); + let schema = generator.into_root_schema_for::(); + let actual = serde_json::to_string_pretty(&schema).unwrap(); + let expected = include_str!("../../../relay-compiler-config-schema.json"); + let source_file_path = file!(); + + let expected_file_path = workspace_root() + .join(source_file_path) + .with_file_name("../../../relay-compiler-config-schema.json"); + assert_file_contains(&actual, expected_file_path, expected) +} diff --git a/compiler/crates/relay-config/Cargo.toml b/compiler/crates/relay-config/Cargo.toml index 882f42d1c1455..a379fe87cb6ca 100644 --- a/compiler/crates/relay-config/Cargo.toml +++ b/compiler/crates/relay-config/Cargo.toml @@ -9,6 +9,7 @@ repository = "https://github.com/facebook/relay" license = "MIT" [dependencies] +schemars = { version = "0.8.21", features = ["indexmap2"] } common = { path = "../common" } fnv = "1.0" indexmap = { version = "2.2.6", features = ["arbitrary", "rayon", "serde"] } @@ -16,5 +17,8 @@ intern = { path = "../intern" } pathdiff = "0.2" regex = "1.9.2" serde = { version = "1.0.185", features = ["derive", "rc"] } -serde_json = { version = "1.0.100", features = ["float_roundtrip", "unbounded_depth"] } +serde_json = { version = "1.0.100", features = [ + "float_roundtrip", + "unbounded_depth", +] } strum = { version = "0.26.2", features = ["derive"] } diff --git a/compiler/crates/relay-config/src/connection_interface.rs b/compiler/crates/relay-config/src/connection_interface.rs index 48de084f7db6b..446b23883f13f 100644 --- a/compiler/crates/relay-config/src/connection_interface.rs +++ b/compiler/crates/relay-config/src/connection_interface.rs @@ -7,11 +7,12 @@ use intern::string_key::Intern; use intern::string_key::StringKey; +use schemars::JsonSchema; use serde::Deserialize; use serde::Serialize; /// Configuration where Relay should expect some fields in the schema. -#[derive(Debug, Serialize, Deserialize)] +#[derive(Debug, Serialize, Deserialize, JsonSchema)] #[serde(deny_unknown_fields, rename_all = "camelCase")] pub struct ConnectionInterface { pub cursor: StringKey, diff --git a/compiler/crates/relay-config/src/defer_stream_interface.rs b/compiler/crates/relay-config/src/defer_stream_interface.rs index 58474cc97be10..448df933a4083 100644 --- a/compiler/crates/relay-config/src/defer_stream_interface.rs +++ b/compiler/crates/relay-config/src/defer_stream_interface.rs @@ -8,11 +8,12 @@ use common::ArgumentName; use common::DirectiveName; use intern::string_key::Intern; +use schemars::JsonSchema; use serde::Deserialize; use serde::Serialize; /// Configuration where Relay should expect some fields in the schema. -#[derive(Copy, Clone, Debug, Serialize, Deserialize)] +#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema)] #[serde(deny_unknown_fields, rename_all = "camelCase")] pub struct DeferStreamInterface { pub defer_name: DirectiveName, diff --git a/compiler/crates/relay-config/src/diagnostic_report_config.rs b/compiler/crates/relay-config/src/diagnostic_report_config.rs index 93f7dccf4c81d..0365a0245c9bc 100644 --- a/compiler/crates/relay-config/src/diagnostic_report_config.rs +++ b/compiler/crates/relay-config/src/diagnostic_report_config.rs @@ -6,11 +6,12 @@ */ use common::DiagnosticSeverity; +use schemars::JsonSchema; use serde::Deserialize; use serde::Serialize; /// Levels for reporting errors in the compiler. -#[derive(Copy, Clone, Debug, Deserialize, Serialize)] +#[derive(Copy, Clone, Debug, Deserialize, Serialize, JsonSchema)] #[serde(rename_all = "lowercase")] pub enum DiagnosticLevel { /// Report only errors @@ -35,7 +36,7 @@ impl From for DiagnosticSeverity { } /// Configuration for all diagnostic reporting in the compiler -#[derive(Copy, Clone, Debug, Deserialize, Serialize)] +#[derive(Copy, Clone, Debug, Deserialize, Serialize, JsonSchema)] #[serde(rename_all = "camelCase")] pub struct DiagnosticReportConfig { /// Threshold for diagnostics to be critical to the compiler's execution. diff --git a/compiler/crates/relay-config/src/js_module_format.rs b/compiler/crates/relay-config/src/js_module_format.rs index fe6203e4eb0a0..4441706824cda 100644 --- a/compiler/crates/relay-config/src/js_module_format.rs +++ b/compiler/crates/relay-config/src/js_module_format.rs @@ -5,11 +5,12 @@ * LICENSE file in the root directory of this source tree. */ +use schemars::JsonSchema; use serde::Deserialize; use serde::Serialize; /// Formatting style for generated files. -#[derive(Copy, Clone, Debug, Deserialize, Serialize)] +#[derive(Copy, Clone, Debug, Deserialize, Serialize, JsonSchema)] #[serde(rename_all = "lowercase")] #[derive(Default)] pub enum JsModuleFormat { diff --git a/compiler/crates/relay-config/src/module_import_config.rs b/compiler/crates/relay-config/src/module_import_config.rs index b1ed8dfbaf9fb..c2ccc6205f98c 100644 --- a/compiler/crates/relay-config/src/module_import_config.rs +++ b/compiler/crates/relay-config/src/module_import_config.rs @@ -6,11 +6,12 @@ */ use intern::string_key::StringKey; +use schemars::JsonSchema; use serde::Deserialize; use serde::Serialize; /// Configuration for @module. -#[derive(Debug, Deserialize, Serialize, Default, Copy, Clone)] +#[derive(Debug, Deserialize, Serialize, Default, Copy, Clone, JsonSchema)] #[serde(deny_unknown_fields, rename_all = "camelCase")] pub struct ModuleImportConfig { /// Defines the custom import statement to be generated on the @@ -19,7 +20,17 @@ pub struct ModuleImportConfig { pub dynamic_module_provider: Option, } -#[derive(Debug, Deserialize, Serialize, Eq, Clone, Copy, PartialEq, Hash)] +#[derive( + Debug, + Deserialize, + Serialize, + Eq, + Clone, + Copy, + PartialEq, + Hash, + JsonSchema +)] #[serde(tag = "mode")] pub enum DynamicModuleProvider { /// Generates a module provider using JSResource diff --git a/compiler/crates/relay-config/src/non_node_id_fields_config.rs b/compiler/crates/relay-config/src/non_node_id_fields_config.rs index a0623e72c2d4f..2564df6fb5c22 100644 --- a/compiler/crates/relay-config/src/non_node_id_fields_config.rs +++ b/compiler/crates/relay-config/src/non_node_id_fields_config.rs @@ -8,11 +8,12 @@ use std::collections::HashMap; use intern::string_key::StringKey; +use schemars::JsonSchema; use serde::Deserialize; use serde::Serialize; /// Configuration of Relay's validation for `id` fields outside of the `Node` interface. -#[derive(Debug, Default, Serialize, Deserialize)] +#[derive(Debug, Default, Serialize, Deserialize, JsonSchema)] #[serde(deny_unknown_fields, rename_all = "camelCase")] pub struct NonNodeIdFieldsConfig { /// A map of parent type names to allowed type names for fields named `id` diff --git a/compiler/crates/relay-config/src/project_config.rs b/compiler/crates/relay-config/src/project_config.rs index d1293ed63b40c..23010ea367072 100644 --- a/compiler/crates/relay-config/src/project_config.rs +++ b/compiler/crates/relay-config/src/project_config.rs @@ -23,6 +23,7 @@ use indexmap::IndexMap; use intern::string_key::Intern; use intern::string_key::StringKey; use regex::Regex; +use schemars::JsonSchema; use serde::de::Error; use serde::Deserialize; use serde::Deserializer; @@ -42,7 +43,7 @@ use crate::TypegenLanguage; type FnvIndexMap = IndexMap; -#[derive(Clone, Debug, Serialize, Deserialize)] +#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)] #[serde(deny_unknown_fields, rename_all = "camelCase")] pub struct RemotePersistConfig { /// URL to send a POST request to to persist. @@ -81,6 +82,7 @@ where } #[derive(Debug, Clone, Serialize, Deserialize)] +#[derive(JsonSchema)] pub enum LocalPersistAlgorithm { MD5, SHA1, @@ -94,7 +96,7 @@ impl Default for LocalPersistAlgorithm { } } -#[derive(Debug, Clone, Serialize, Deserialize)] +#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)] #[serde(deny_unknown_fields)] pub struct LocalPersistConfig { pub file: PathBuf, @@ -106,7 +108,7 @@ pub struct LocalPersistConfig { pub include_query_text: bool, } -#[derive(Debug, Serialize, Clone)] +#[derive(Debug, Serialize, Clone, JsonSchema)] #[serde(untagged)] pub enum PersistConfig { Remote(RemotePersistConfig), @@ -155,7 +157,7 @@ It also cannot be a local persist configuration due to: } } -#[derive(Clone, Debug)] +#[derive(Clone, Debug, JsonSchema)] pub enum SchemaLocation { File(PathBuf), Directory(PathBuf), @@ -175,7 +177,7 @@ impl Debug for ExtraArtifactsConfig { } } -#[derive(Debug, Serialize, Deserialize)] +#[derive(Debug, Serialize, Deserialize, JsonSchema)] #[serde(rename_all = "camelCase")] pub struct SchemaConfig { #[serde(default)] diff --git a/compiler/crates/relay-config/src/project_name.rs b/compiler/crates/relay-config/src/project_name.rs index c6b59747f52e0..5ddd96e859715 100644 --- a/compiler/crates/relay-config/src/project_name.rs +++ b/compiler/crates/relay-config/src/project_name.rs @@ -10,12 +10,14 @@ use std::fmt; use intern::string_key::Intern; use intern::string_key::StringKey; use intern::Lookup; +use schemars::JsonSchema; use serde::Deserialize; use serde::Deserializer; use serde::Serialize; use serde::Serializer; -#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)] +#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, JsonSchema)] +#[schemars(untagged)] pub enum ProjectName { Default, Named(StringKey), diff --git a/compiler/crates/relay-config/src/resolvers_schema_module_config.rs b/compiler/crates/relay-config/src/resolvers_schema_module_config.rs index 39576387b6afa..ed05c4c3c6b46 100644 --- a/compiler/crates/relay-config/src/resolvers_schema_module_config.rs +++ b/compiler/crates/relay-config/src/resolvers_schema_module_config.rs @@ -7,11 +7,12 @@ use std::path::PathBuf; +use schemars::JsonSchema; use serde::Deserialize; use serde::Serialize; /// Configuration for resolvers_schema_module generation -#[derive(Default, Serialize, Deserialize, Debug)] +#[derive(Default, Serialize, Deserialize, Debug, JsonSchema)] #[serde(deny_unknown_fields, rename_all = "camelCase")] pub struct ResolversSchemaModuleConfig { #[serde(default)] diff --git a/compiler/crates/relay-config/src/typegen_config.rs b/compiler/crates/relay-config/src/typegen_config.rs index d5c9e79627336..d9297683ea10f 100644 --- a/compiler/crates/relay-config/src/typegen_config.rs +++ b/compiler/crates/relay-config/src/typegen_config.rs @@ -11,6 +11,7 @@ use common::ScalarName; use fnv::FnvBuildHasher; use indexmap::IndexMap; use intern::string_key::StringKey; +use schemars::JsonSchema; use serde::Deserialize; use serde::Serialize; use strum::EnumIter; @@ -25,7 +26,8 @@ type FnvIndexMap = IndexMap; Clone, Serialize, Deserialize, - PartialEq + PartialEq, + JsonSchema )] #[serde(deny_unknown_fields, rename_all = "lowercase")] pub enum TypegenLanguage { @@ -44,21 +46,21 @@ impl TypegenLanguage { } } -#[derive(Debug, Serialize, Deserialize, Clone)] +#[derive(Debug, Serialize, Deserialize, Clone, JsonSchema)] #[serde(untagged)] pub enum CustomScalarType { Name(StringKey), Path(CustomScalarTypeImport), } -#[derive(Debug, Serialize, Deserialize, Clone)] +#[derive(Debug, Serialize, Deserialize, Clone, JsonSchema)] pub struct CustomScalarTypeImport { pub name: StringKey, pub path: PathBuf, } -#[derive(Debug, Serialize, Deserialize)] +#[derive(Debug, Serialize, Deserialize, JsonSchema)] #[serde(deny_unknown_fields, rename_all = "camelCase")] pub struct TypegenConfig { /// The desired output language, "flow" or "typescript". diff --git a/compiler/relay-compiler-config-schema.json b/compiler/relay-compiler-config-schema.json new file mode 100644 index 0000000000000..d6276291068e3 --- /dev/null +++ b/compiler/relay-compiler-config-schema.json @@ -0,0 +1,4829 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "ConfigFile", + "anyOf": [ + { + "description": "Base case configuration (mostly of OSS) where the project have single schema, and single source directory", + "type": "object", + "required": [ + "language" + ], + "properties": { + "$schema": { + "description": "The user may hard-code the JSON Schema for their version of the config.", + "default": null, + "type": [ + "string", + "null" + ] + }, + "artifactDirectory": { + "description": "A specific directory to output all artifacts to. When enabling this the babel plugin needs `artifactDirectory` set as well.", + "default": null, + "type": [ + "string", + "null" + ] + }, + "codegenCommand": { + "description": "Name of the command that runs the relay compiler", + "default": null, + "type": [ + "string", + "null" + ] + }, + "customScalarTypes": { + "description": "A map from GraphQL scalar types to a custom JS type, example: { \"Url\": \"String\" } { \"Url\": {\"name:: \"MyURL\", \"path\": \"../src/MyUrlTypes\"} }", + "default": {}, + "type": "object", + "additionalProperties": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "object", + "required": [ + "name", + "path" + ], + "properties": { + "name": { + "type": "string" + }, + "path": { + "type": "string" + } + } + } + ] + } + }, + "eagerEsModules": { + "description": "This option enables emitting es modules artifacts.", + "default": false, + "type": "boolean" + }, + "enumModuleSuffix": { + "title": "For Flow type generation", + "description": "When set, enum values are imported from a module with this suffix. For example, an enum Foo and this property set to \".test\" would be imported from \"Foo.test\". Note: an empty string is allowed and different from not setting the value, in the example above it would just import from \"Foo\".", + "type": [ + "string", + "null" + ] + }, + "excludes": { + "description": "Directories to ignore under src default: ['**/node_modules/**', '**/__mocks__/**', '**/__generated__/**'],", + "default": [ + "**/node_modules/**", + "**/__mocks__/**", + "**/__generated__/**" + ], + "type": "array", + "items": { + "type": "string" + } + }, + "experimentalEmitSemanticNullabilityTypes": { + "description": "EXPERIMENTAL: If your environment is configured to handles errors out of band, either via a network layer which discards responses with errors, or via enabling strict error handling in the runtime, you can enable this flag to have Relay generate non-null types for fields which are marked as semantically non-null in the schema.\n\nCurrently semantically non-null fields must be specified in your schema using the `@semanticNonNull` directive as specified in: https://github.com/apollographql/specs/pull/42", + "default": false, + "type": "boolean" + }, + "extensions": { + "description": "\\[DEPRECATED\\] This is deprecated field, we're not using it in the V13. Adding to the config, to show the warning, and not a parse error.", + "default": [], + "type": "array", + "items": { + "type": "string" + } + }, + "featureFlags": { + "default": null, + "type": [ + "object", + "null" + ], + "properties": { + "actor_change_support": { + "default": { + "kind": "disabled" + }, + "oneOf": [ + { + "description": "Fully disabled: developers may not use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "disabled" + ] + } + } + }, + { + "description": "Fully enabled: developers may use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "enabled" + ] + } + } + }, + { + "description": "Partially enabled: developers may only use this feature on the listed items (fragments, fields, types).", + "type": "object", + "required": [ + "allowlist", + "kind" + ], + "properties": { + "allowlist": { + "type": "array", + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "kind": { + "type": "string", + "enum": [ + "limited" + ] + } + } + }, + { + "description": "Partially enabled: used for gradual rollout of the feature", + "type": "object", + "required": [ + "kind", + "rollout" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "rollout" + ] + }, + "rollout": { + "description": "A utility to enable gradual rollout of large codegen changes. Can be constructed as the Default which passes or a percentage between 0 and 100.", + "type": [ + "integer", + "null" + ], + "format": "uint8", + "minimum": 0.0 + } + } + } + ] + }, + "allow_required_in_mutation_response": { + "description": "@required with an action of THROW is read-time feature that is not compatible with our mutation APIs. We are in the process of removing any existing examples, but this flag is part of a process of removing any existing examples.", + "default": { + "kind": "disabled" + }, + "oneOf": [ + { + "description": "Fully disabled: developers may not use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "disabled" + ] + } + } + }, + { + "description": "Fully enabled: developers may use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "enabled" + ] + } + } + }, + { + "description": "Partially enabled: developers may only use this feature on the listed items (fragments, fields, types).", + "type": "object", + "required": [ + "allowlist", + "kind" + ], + "properties": { + "allowlist": { + "type": "array", + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "kind": { + "type": "string", + "enum": [ + "limited" + ] + } + } + }, + { + "description": "Partially enabled: used for gradual rollout of the feature", + "type": "object", + "required": [ + "kind", + "rollout" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "rollout" + ] + }, + "rollout": { + "description": "A utility to enable gradual rollout of large codegen changes. Can be constructed as the Default which passes or a percentage between 0 and 100.", + "type": [ + "integer", + "null" + ], + "format": "uint8", + "minimum": 0.0 + } + } + } + ] + }, + "allow_resolver_non_nullable_return_type": { + "description": "Allow non-nullable return types from resolvers.", + "default": { + "kind": "disabled" + }, + "oneOf": [ + { + "description": "Fully disabled: developers may not use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "disabled" + ] + } + } + }, + { + "description": "Fully enabled: developers may use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "enabled" + ] + } + } + }, + { + "description": "Partially enabled: developers may only use this feature on the listed items (fragments, fields, types).", + "type": "object", + "required": [ + "allowlist", + "kind" + ], + "properties": { + "allowlist": { + "type": "array", + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "kind": { + "type": "string", + "enum": [ + "limited" + ] + } + } + }, + { + "description": "Partially enabled: used for gradual rollout of the feature", + "type": "object", + "required": [ + "kind", + "rollout" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "rollout" + ] + }, + "rollout": { + "description": "A utility to enable gradual rollout of large codegen changes. Can be constructed as the Default which passes or a percentage between 0 and 100.", + "type": [ + "integer", + "null" + ], + "format": "uint8", + "minimum": 0.0 + } + } + } + ] + }, + "allow_resolvers_in_mutation_response": { + "description": "Relay Resolvers are a read-time feature that are not actually handled in our mutation APIs. We are in the process of removing any existing examples, but this flag is part of a process of removing any existing examples.", + "default": { + "kind": "disabled" + }, + "oneOf": [ + { + "description": "Fully disabled: developers may not use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "disabled" + ] + } + } + }, + { + "description": "Fully enabled: developers may use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "enabled" + ] + } + } + }, + { + "description": "Partially enabled: developers may only use this feature on the listed items (fragments, fields, types).", + "type": "object", + "required": [ + "allowlist", + "kind" + ], + "properties": { + "allowlist": { + "type": "array", + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "kind": { + "type": "string", + "enum": [ + "limited" + ] + } + } + }, + { + "description": "Partially enabled: used for gradual rollout of the feature", + "type": "object", + "required": [ + "kind", + "rollout" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "rollout" + ] + }, + "rollout": { + "description": "A utility to enable gradual rollout of large codegen changes. Can be constructed as the Default which passes or a percentage between 0 and 100.", + "type": [ + "integer", + "null" + ], + "format": "uint8", + "minimum": 0.0 + } + } + } + ] + }, + "compact_query_text": { + "description": "Print queries in compact form", + "default": { + "kind": "disabled" + }, + "oneOf": [ + { + "description": "Fully disabled: developers may not use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "disabled" + ] + } + } + }, + { + "description": "Fully enabled: developers may use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "enabled" + ] + } + } + }, + { + "description": "Partially enabled: developers may only use this feature on the listed items (fragments, fields, types).", + "type": "object", + "required": [ + "allowlist", + "kind" + ], + "properties": { + "allowlist": { + "type": "array", + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "kind": { + "type": "string", + "enum": [ + "limited" + ] + } + } + }, + { + "description": "Partially enabled: used for gradual rollout of the feature", + "type": "object", + "required": [ + "kind", + "rollout" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "rollout" + ] + }, + "rollout": { + "description": "A utility to enable gradual rollout of large codegen changes. Can be constructed as the Default which passes or a percentage between 0 and 100.", + "type": [ + "integer", + "null" + ], + "format": "uint8", + "minimum": 0.0 + } + } + } + ] + }, + "disable_edge_type_name_validation_on_declerative_connection_directives": { + "description": "Disable validation of the `edgeTypeName` argument on `@prependNode` and `@appendNode`.", + "default": { + "kind": "disabled" + }, + "oneOf": [ + { + "description": "Fully disabled: developers may not use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "disabled" + ] + } + } + }, + { + "description": "Fully enabled: developers may use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "enabled" + ] + } + } + }, + { + "description": "Partially enabled: developers may only use this feature on the listed items (fragments, fields, types).", + "type": "object", + "required": [ + "allowlist", + "kind" + ], + "properties": { + "allowlist": { + "type": "array", + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "kind": { + "type": "string", + "enum": [ + "limited" + ] + } + } + }, + { + "description": "Partially enabled: used for gradual rollout of the feature", + "type": "object", + "required": [ + "kind", + "rollout" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "rollout" + ] + }, + "rollout": { + "description": "A utility to enable gradual rollout of large codegen changes. Can be constructed as the Default which passes or a percentage between 0 and 100.", + "type": [ + "integer", + "null" + ], + "format": "uint8", + "minimum": 0.0 + } + } + } + ] + }, + "disable_resolver_reader_ast": { + "description": "Mirror of `enable_resolver_normalization_ast` excludes resolver metadata from reader ast", + "default": false, + "type": "boolean" + }, + "disable_schema_validation": { + "description": "Disable validating the composite schema (server, client schema extensions, Relay Resolvers) after its built.", + "default": false, + "type": "boolean" + }, + "disallow_required_on_non_null_fields": { + "description": "Disallow the `@required` directive on fields that are already non-null in the schema.", + "default": false, + "type": "boolean" + }, + "emit_normalization_nodes_for_client_edges": { + "description": "Create normalization nodes for client edges to client objects", + "default": true, + "type": "boolean" + }, + "enable_3d_branch_arg_generation": { + "default": false, + "type": "boolean" + }, + "enable_catch_directive_transform": { + "default": { + "kind": "disabled" + }, + "oneOf": [ + { + "description": "Fully disabled: developers may not use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "disabled" + ] + } + } + }, + { + "description": "Fully enabled: developers may use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "enabled" + ] + } + } + }, + { + "description": "Partially enabled: developers may only use this feature on the listed items (fragments, fields, types).", + "type": "object", + "required": [ + "allowlist", + "kind" + ], + "properties": { + "allowlist": { + "type": "array", + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "kind": { + "type": "string", + "enum": [ + "limited" + ] + } + } + }, + { + "description": "Partially enabled: used for gradual rollout of the feature", + "type": "object", + "required": [ + "kind", + "rollout" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "rollout" + ] + }, + "rollout": { + "description": "A utility to enable gradual rollout of large codegen changes. Can be constructed as the Default which passes or a percentage between 0 and 100.", + "type": [ + "integer", + "null" + ], + "format": "uint8", + "minimum": 0.0 + } + } + } + ] + }, + "enable_fragment_aliases": { + "description": "Enable support for the experimental `@alias` directive on fragment spreads.", + "default": { + "kind": "disabled" + }, + "oneOf": [ + { + "description": "Fully disabled: developers may not use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "disabled" + ] + } + } + }, + { + "description": "Fully enabled: developers may use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "enabled" + ] + } + } + }, + { + "description": "Partially enabled: developers may only use this feature on the listed items (fragments, fields, types).", + "type": "object", + "required": [ + "allowlist", + "kind" + ], + "properties": { + "allowlist": { + "type": "array", + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "kind": { + "type": "string", + "enum": [ + "limited" + ] + } + } + }, + { + "description": "Partially enabled: used for gradual rollout of the feature", + "type": "object", + "required": [ + "kind", + "rollout" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "rollout" + ] + }, + "rollout": { + "description": "A utility to enable gradual rollout of large codegen changes. Can be constructed as the Default which passes or a percentage between 0 and 100.", + "type": [ + "integer", + "null" + ], + "format": "uint8", + "minimum": 0.0 + } + } + } + ] + }, + "enable_fragment_argument_transform": { + "description": "Add support for parsing and transforming variable definitions on fragment definitions and arguments on fragment spreads.", + "default": false, + "type": "boolean" + }, + "enable_relay_resolver_mutations": { + "description": "Allow relay resolvers to extend the Mutation type", + "default": false, + "type": "boolean" + }, + "enable_relay_resolver_transform": { + "default": false, + "type": "boolean" + }, + "enable_resolver_normalization_ast": { + "description": "Fully build the normalization AST for Resolvers", + "default": false, + "type": "boolean" + }, + "enable_strict_custom_scalars": { + "description": "Perform strict validations when custom scalar types are used", + "default": false, + "type": "boolean" + }, + "enforce_fragment_alias_where_ambiguous": { + "description": "Enforce that you must add `@alias` to a fragment if it may not match, due to type mismatch or `@skip`/`@include`", + "default": { + "kind": "disabled" + }, + "oneOf": [ + { + "description": "Fully disabled: developers may not use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "disabled" + ] + } + } + }, + { + "description": "Fully enabled: developers may use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "enabled" + ] + } + } + }, + { + "description": "Partially enabled: developers may only use this feature on the listed items (fragments, fields, types).", + "type": "object", + "required": [ + "allowlist", + "kind" + ], + "properties": { + "allowlist": { + "type": "array", + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "kind": { + "type": "string", + "enum": [ + "limited" + ] + } + } + }, + { + "description": "Partially enabled: used for gradual rollout of the feature", + "type": "object", + "required": [ + "kind", + "rollout" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "rollout" + ] + }, + "rollout": { + "description": "A utility to enable gradual rollout of large codegen changes. Can be constructed as the Default which passes or a percentage between 0 and 100.", + "type": [ + "integer", + "null" + ], + "format": "uint8", + "minimum": 0.0 + } + } + } + ] + }, + "no_inline": { + "description": "For now, this also disallows fragments with variable definitions This also makes @module to opt in using @no_inline internally NOTE that the presence of a fragment in this list only controls whether a fragment is *allowed* to use @no_inline: whether the fragment is inlined or not depends on whether it actually uses that directive.", + "default": { + "kind": "disabled" + }, + "oneOf": [ + { + "description": "Fully disabled: developers may not use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "disabled" + ] + } + } + }, + { + "description": "Fully enabled: developers may use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "enabled" + ] + } + } + }, + { + "description": "Partially enabled: developers may only use this feature on the listed items (fragments, fields, types).", + "type": "object", + "required": [ + "allowlist", + "kind" + ], + "properties": { + "allowlist": { + "type": "array", + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "kind": { + "type": "string", + "enum": [ + "limited" + ] + } + } + }, + { + "description": "Partially enabled: used for gradual rollout of the feature", + "type": "object", + "required": [ + "kind", + "rollout" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "rollout" + ] + }, + "rollout": { + "description": "A utility to enable gradual rollout of large codegen changes. Can be constructed as the Default which passes or a percentage between 0 and 100.", + "type": [ + "integer", + "null" + ], + "format": "uint8", + "minimum": 0.0 + } + } + } + ] + }, + "prefer_fetchable_in_refetch_queries": { + "description": "Feature flag to prefer `fetch_MyType()` generatior over `node()` query generator in @refetchable transform", + "default": false, + "type": "boolean" + }, + "relay_resolver_enable_interface_output_type": { + "default": { + "kind": "disabled" + }, + "oneOf": [ + { + "description": "Fully disabled: developers may not use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "disabled" + ] + } + } + }, + { + "description": "Fully enabled: developers may use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "enabled" + ] + } + } + }, + { + "description": "Partially enabled: developers may only use this feature on the listed items (fragments, fields, types).", + "type": "object", + "required": [ + "allowlist", + "kind" + ], + "properties": { + "allowlist": { + "type": "array", + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "kind": { + "type": "string", + "enum": [ + "limited" + ] + } + } + }, + { + "description": "Partially enabled: used for gradual rollout of the feature", + "type": "object", + "required": [ + "kind", + "rollout" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "rollout" + ] + }, + "rollout": { + "description": "A utility to enable gradual rollout of large codegen changes. Can be constructed as the Default which passes or a percentage between 0 and 100.", + "type": [ + "integer", + "null" + ], + "format": "uint8", + "minimum": 0.0 + } + } + } + ] + }, + "skip_printing_nulls": { + "default": { + "kind": "disabled" + }, + "oneOf": [ + { + "description": "Fully disabled: developers may not use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "disabled" + ] + } + } + }, + { + "description": "Fully enabled: developers may use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "enabled" + ] + } + } + }, + { + "description": "Partially enabled: developers may only use this feature on the listed items (fragments, fields, types).", + "type": "object", + "required": [ + "allowlist", + "kind" + ], + "properties": { + "allowlist": { + "type": "array", + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "kind": { + "type": "string", + "enum": [ + "limited" + ] + } + } + }, + { + "description": "Partially enabled: used for gradual rollout of the feature", + "type": "object", + "required": [ + "kind", + "rollout" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "rollout" + ] + }, + "rollout": { + "description": "A utility to enable gradual rollout of large codegen changes. Can be constructed as the Default which passes or a percentage between 0 and 100.", + "type": [ + "integer", + "null" + ], + "format": "uint8", + "minimum": 0.0 + } + } + } + ] + }, + "text_artifacts": { + "description": "Enable generation of text artifacts used to generate full query strings later.", + "default": { + "kind": "disabled" + }, + "oneOf": [ + { + "description": "Fully disabled: developers may not use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "disabled" + ] + } + } + }, + { + "description": "Fully enabled: developers may use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "enabled" + ] + } + } + }, + { + "description": "Partially enabled: developers may only use this feature on the listed items (fragments, fields, types).", + "type": "object", + "required": [ + "allowlist", + "kind" + ], + "properties": { + "allowlist": { + "type": "array", + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "kind": { + "type": "string", + "enum": [ + "limited" + ] + } + } + }, + { + "description": "Partially enabled: used for gradual rollout of the feature", + "type": "object", + "required": [ + "kind", + "rollout" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "rollout" + ] + }, + "rollout": { + "description": "A utility to enable gradual rollout of large codegen changes. Can be constructed as the Default which passes or a percentage between 0 and 100.", + "type": [ + "integer", + "null" + ], + "format": "uint8", + "minimum": 0.0 + } + } + } + ] + } + }, + "additionalProperties": false + }, + "include": { + "description": "\\[DEPRECATED\\] This is deprecated field, we're not using it in the V13. Adding to the config, to show the warning, and not a parse error.", + "default": [], + "type": "array", + "items": { + "type": "string" + } + }, + "isDevVariableName": { + "description": "We may generate some content in the artifacts that's stripped in production if __DEV__ variable is set This config option is here to define the name of that special variable", + "default": null, + "type": [ + "string", + "null" + ] + }, + "jsModuleFormat": { + "description": "Formatting style for generated files.", + "default": "commonjs", + "oneOf": [ + { + "description": "Common JS style, e.g. `require('../path/MyModule')`", + "type": "string", + "enum": [ + "commonjs" + ] + }, + { + "description": "Facebook style, e.g. `require('MyModule')`", + "type": "string", + "enum": [ + "haste" + ] + } + ] + }, + "language": { + "description": "The desired output language, \"flow\" or \"typescript\".", + "type": "string", + "enum": [ + "javascript", + "typescript", + "flow" + ] + }, + "moduleImportConfig": { + "description": "Configuration for @module", + "default": { + "dynamicModuleProvider": null + }, + "type": "object", + "properties": { + "dynamicModuleProvider": { + "description": "Defines the custom import statement to be generated on the `ModuleImport` node in ASTs, used for dynamically loading components at runtime.", + "anyOf": [ + { + "oneOf": [ + { + "description": "Generates a module provider using JSResource", + "type": "object", + "required": [ + "mode" + ], + "properties": { + "mode": { + "type": "string", + "enum": [ + "JSResource" + ] + } + } + }, + { + "description": "Generates a custom JS import, Use `<$module>` as the placeholder for the actual module. e.g. `\"() => import('<$module>')\"`", + "type": "object", + "required": [ + "mode", + "statement" + ], + "properties": { + "mode": { + "type": "string", + "enum": [ + "Custom" + ] + }, + "statement": { + "type": "string" + } + } + } + ] + }, + { + "type": "null" + } + ] + } + }, + "additionalProperties": false + }, + "noFutureProofEnums": { + "description": "This option controls whether or not a catch-all entry is added to enum type definitions for values that may be added in the future. Enabling this means you will have to update your application whenever the GraphQL server schema adds new enum values to prevent it from breaking.", + "default": false, + "type": "boolean" + }, + "optionalInputFields": { + "title": "For Flow type generation", + "description": "When set, generated input types will have the listed fields optional even if the schema defines them as required.", + "default": [], + "type": "array", + "items": { + "type": "string" + } + }, + "persistConfig": { + "description": "Query Persist Configuration It contains URL and addition parameters that will be included with the request (think API_KEY, APP_ID, etc...)", + "default": null, + "anyOf": [ + { + "anyOf": [ + { + "type": "object", + "required": [ + "url" + ], + "properties": { + "concurrency": { + "default": null, + "type": [ + "integer", + "null" + ], + "format": "uint", + "minimum": 0.0 + }, + "headers": { + "description": "Additional headers to send", + "default": {}, + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "includeQueryText": { + "default": false, + "type": "boolean" + }, + "params": { + "description": "The document will be in a POST parameter `text`. This map can contain additional parameters to send.", + "default": {}, + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "url": { + "description": "URL to send a POST request to to persist.", + "type": "string" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "file" + ], + "properties": { + "algorithm": { + "default": "MD5", + "type": "string", + "enum": [ + "MD5", + "SHA1", + "SHA256" + ] + }, + "file": { + "type": "string" + }, + "include_query_text": { + "default": false, + "type": "boolean" + } + }, + "additionalProperties": false + } + ] + }, + { + "type": "null" + } + ] + }, + "requireCustomScalarTypes": { + "description": "Require all GraphQL scalar types mapping to be defined, will throw if a GraphQL scalar type doesn't have a JS type", + "default": false, + "type": "boolean" + }, + "resolversSchemaModule": { + "description": "Configuration for resolvers_schema_module generation", + "default": null, + "type": [ + "object", + "null" + ], + "properties": { + "applyToNormalizationAst": { + "default": false, + "type": "boolean" + }, + "path": { + "default": "", + "type": "string" + } + }, + "additionalProperties": false + }, + "schema": { + "description": "Path to schema.graphql", + "default": "", + "type": "string" + }, + "schemaConfig": { + "description": "Extra configuration for the schema itself.", + "default": { + "connectionInterface": { + "cursor": "cursor", + "edges": "edges", + "endCursor": "endCursor", + "hasNextPage": "hasNextPage", + "hasPreviousPage": "hasPreviousPage", + "node": "node", + "pageInfo": "pageInfo", + "startCursor": "startCursor" + }, + "deferStreamInterface": { + "deferName": "defer", + "ifArg": "if", + "initialCountArg": "initialCount", + "labelArg": "label", + "streamName": "stream", + "useCustomizedBatchArg": "useCustomizedBatch" + }, + "nodeInterfaceIdField": "id", + "nodeInterfaceIdVariableName": "id", + "nonNodeIdFields": null, + "unselectableDirectiveName": "unselectable" + }, + "type": "object", + "properties": { + "connectionInterface": { + "description": "Configuration where Relay should expect some fields in the schema.", + "default": { + "cursor": "cursor", + "edges": "edges", + "endCursor": "endCursor", + "hasNextPage": "hasNextPage", + "hasPreviousPage": "hasPreviousPage", + "node": "node", + "pageInfo": "pageInfo", + "startCursor": "startCursor" + }, + "type": "object", + "required": [ + "cursor", + "edges", + "endCursor", + "hasNextPage", + "hasPreviousPage", + "node", + "pageInfo", + "startCursor" + ], + "properties": { + "cursor": { + "type": "string" + }, + "edges": { + "type": "string" + }, + "endCursor": { + "type": "string" + }, + "hasNextPage": { + "type": "string" + }, + "hasPreviousPage": { + "type": "string" + }, + "node": { + "type": "string" + }, + "pageInfo": { + "type": "string" + }, + "startCursor": { + "type": "string" + } + }, + "additionalProperties": false + }, + "deferStreamInterface": { + "description": "Configuration where Relay should expect some fields in the schema.", + "default": { + "deferName": "defer", + "ifArg": "if", + "initialCountArg": "initialCount", + "labelArg": "label", + "streamName": "stream", + "useCustomizedBatchArg": "useCustomizedBatch" + }, + "type": "object", + "required": [ + "deferName", + "ifArg", + "initialCountArg", + "labelArg", + "streamName", + "useCustomizedBatchArg" + ], + "properties": { + "deferName": { + "description": "Wrapper struct for clarity rather than having StringKey everywhere.", + "type": "string" + }, + "ifArg": { + "type": "string" + }, + "initialCountArg": { + "type": "string" + }, + "labelArg": { + "type": "string" + }, + "streamName": { + "description": "Wrapper struct for clarity rather than having StringKey everywhere.", + "type": "string" + }, + "useCustomizedBatchArg": { + "type": "string" + } + }, + "additionalProperties": false + }, + "nodeInterfaceIdField": { + "description": "The name of the `id` field that exists on the `Node` interface.", + "default": "id", + "type": "string" + }, + "nodeInterfaceIdVariableName": { + "description": "The name of the variable expected by the `node` query.", + "default": "id", + "type": "string" + }, + "nonNodeIdFields": { + "description": "Configuration of Relay's validation for `id` fields outside of the `Node` interface.", + "default": null, + "type": [ + "object", + "null" + ], + "properties": { + "allowedIdTypes": { + "description": "A map of parent type names to allowed type names for fields named `id`", + "default": {}, + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "additionalProperties": false + }, + "unselectableDirectiveName": { + "description": "The name of the directive indicating fields that cannot be selected", + "default": "unselectable", + "type": "string" + } + } + }, + "schemaExtensions": { + "description": "List of directories with schema extensions.", + "default": [], + "type": "array", + "items": { + "type": "string" + } + }, + "src": { + "description": "Root directory of application code", + "default": "", + "type": "string" + }, + "typegenPhase": { + "description": "Added in 13.1.1 to customize Final/Compat mode in the single project config file Removed in 14.0.0", + "default": null + }, + "typescriptExcludeUndefinedFromNullableUnion": { + "description": "Keep the previous compiler behavior by outputting an union of the raw type and null, and not the **correct** behavior of an union with the raw type, null and undefined.", + "default": false, + "type": "boolean" + }, + "useImportTypeSyntax": { + "title": "For Typescript type generation", + "description": "Whether to use the `import type` syntax introduced in Typescript version 3.8. This will prevent warnings from `importsNotUsedAsValues`.", + "default": false, + "type": "boolean" + } + }, + "additionalProperties": false + }, + { + "description": "Relay can support multiple projects with multiple schemas and different options (output, typegen, etc...). This MultiProjectConfigFile is responsible for configuring these type of projects (complex)", + "type": "object", + "required": [ + "projects", + "sources" + ], + "properties": { + "$schema": { + "description": "The user may hard-code the JSON Schema for their version of the config.", + "type": [ + "string", + "null" + ] + }, + "codegenCommand": { + "default": null, + "type": [ + "string", + "null" + ] + }, + "excludes": { + "description": "Glob patterns that should not be part of the sources even if they are in the source set directories.", + "default": [ + "**/node_modules/**", + "**/__mocks__/**", + "**/__generated__/**" + ], + "type": "array", + "items": { + "type": "string" + } + }, + "featureFlags": { + "default": { + "actor_change_support": { + "kind": "disabled" + }, + "allow_required_in_mutation_response": { + "kind": "disabled" + }, + "allow_resolver_non_nullable_return_type": { + "kind": "disabled" + }, + "allow_resolvers_in_mutation_response": { + "kind": "disabled" + }, + "compact_query_text": { + "kind": "disabled" + }, + "disable_edge_type_name_validation_on_declerative_connection_directives": { + "kind": "disabled" + }, + "disable_resolver_reader_ast": false, + "disable_schema_validation": false, + "disallow_required_on_non_null_fields": false, + "emit_normalization_nodes_for_client_edges": false, + "enable_3d_branch_arg_generation": false, + "enable_catch_directive_transform": { + "kind": "disabled" + }, + "enable_fragment_aliases": { + "kind": "disabled" + }, + "enable_fragment_argument_transform": false, + "enable_relay_resolver_mutations": false, + "enable_relay_resolver_transform": false, + "enable_resolver_normalization_ast": false, + "enable_strict_custom_scalars": false, + "enforce_fragment_alias_where_ambiguous": { + "kind": "disabled" + }, + "no_inline": { + "kind": "disabled" + }, + "prefer_fetchable_in_refetch_queries": false, + "relay_resolver_enable_interface_output_type": { + "kind": "disabled" + }, + "skip_printing_nulls": { + "kind": "disabled" + }, + "text_artifacts": { + "kind": "disabled" + } + }, + "type": "object", + "properties": { + "actor_change_support": { + "default": { + "kind": "disabled" + }, + "oneOf": [ + { + "description": "Fully disabled: developers may not use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "disabled" + ] + } + } + }, + { + "description": "Fully enabled: developers may use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "enabled" + ] + } + } + }, + { + "description": "Partially enabled: developers may only use this feature on the listed items (fragments, fields, types).", + "type": "object", + "required": [ + "allowlist", + "kind" + ], + "properties": { + "allowlist": { + "type": "array", + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "kind": { + "type": "string", + "enum": [ + "limited" + ] + } + } + }, + { + "description": "Partially enabled: used for gradual rollout of the feature", + "type": "object", + "required": [ + "kind", + "rollout" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "rollout" + ] + }, + "rollout": { + "description": "A utility to enable gradual rollout of large codegen changes. Can be constructed as the Default which passes or a percentage between 0 and 100.", + "type": [ + "integer", + "null" + ], + "format": "uint8", + "minimum": 0.0 + } + } + } + ] + }, + "allow_required_in_mutation_response": { + "description": "@required with an action of THROW is read-time feature that is not compatible with our mutation APIs. We are in the process of removing any existing examples, but this flag is part of a process of removing any existing examples.", + "default": { + "kind": "disabled" + }, + "oneOf": [ + { + "description": "Fully disabled: developers may not use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "disabled" + ] + } + } + }, + { + "description": "Fully enabled: developers may use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "enabled" + ] + } + } + }, + { + "description": "Partially enabled: developers may only use this feature on the listed items (fragments, fields, types).", + "type": "object", + "required": [ + "allowlist", + "kind" + ], + "properties": { + "allowlist": { + "type": "array", + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "kind": { + "type": "string", + "enum": [ + "limited" + ] + } + } + }, + { + "description": "Partially enabled: used for gradual rollout of the feature", + "type": "object", + "required": [ + "kind", + "rollout" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "rollout" + ] + }, + "rollout": { + "description": "A utility to enable gradual rollout of large codegen changes. Can be constructed as the Default which passes or a percentage between 0 and 100.", + "type": [ + "integer", + "null" + ], + "format": "uint8", + "minimum": 0.0 + } + } + } + ] + }, + "allow_resolver_non_nullable_return_type": { + "description": "Allow non-nullable return types from resolvers.", + "default": { + "kind": "disabled" + }, + "oneOf": [ + { + "description": "Fully disabled: developers may not use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "disabled" + ] + } + } + }, + { + "description": "Fully enabled: developers may use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "enabled" + ] + } + } + }, + { + "description": "Partially enabled: developers may only use this feature on the listed items (fragments, fields, types).", + "type": "object", + "required": [ + "allowlist", + "kind" + ], + "properties": { + "allowlist": { + "type": "array", + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "kind": { + "type": "string", + "enum": [ + "limited" + ] + } + } + }, + { + "description": "Partially enabled: used for gradual rollout of the feature", + "type": "object", + "required": [ + "kind", + "rollout" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "rollout" + ] + }, + "rollout": { + "description": "A utility to enable gradual rollout of large codegen changes. Can be constructed as the Default which passes or a percentage between 0 and 100.", + "type": [ + "integer", + "null" + ], + "format": "uint8", + "minimum": 0.0 + } + } + } + ] + }, + "allow_resolvers_in_mutation_response": { + "description": "Relay Resolvers are a read-time feature that are not actually handled in our mutation APIs. We are in the process of removing any existing examples, but this flag is part of a process of removing any existing examples.", + "default": { + "kind": "disabled" + }, + "oneOf": [ + { + "description": "Fully disabled: developers may not use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "disabled" + ] + } + } + }, + { + "description": "Fully enabled: developers may use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "enabled" + ] + } + } + }, + { + "description": "Partially enabled: developers may only use this feature on the listed items (fragments, fields, types).", + "type": "object", + "required": [ + "allowlist", + "kind" + ], + "properties": { + "allowlist": { + "type": "array", + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "kind": { + "type": "string", + "enum": [ + "limited" + ] + } + } + }, + { + "description": "Partially enabled: used for gradual rollout of the feature", + "type": "object", + "required": [ + "kind", + "rollout" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "rollout" + ] + }, + "rollout": { + "description": "A utility to enable gradual rollout of large codegen changes. Can be constructed as the Default which passes or a percentage between 0 and 100.", + "type": [ + "integer", + "null" + ], + "format": "uint8", + "minimum": 0.0 + } + } + } + ] + }, + "compact_query_text": { + "description": "Print queries in compact form", + "default": { + "kind": "disabled" + }, + "oneOf": [ + { + "description": "Fully disabled: developers may not use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "disabled" + ] + } + } + }, + { + "description": "Fully enabled: developers may use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "enabled" + ] + } + } + }, + { + "description": "Partially enabled: developers may only use this feature on the listed items (fragments, fields, types).", + "type": "object", + "required": [ + "allowlist", + "kind" + ], + "properties": { + "allowlist": { + "type": "array", + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "kind": { + "type": "string", + "enum": [ + "limited" + ] + } + } + }, + { + "description": "Partially enabled: used for gradual rollout of the feature", + "type": "object", + "required": [ + "kind", + "rollout" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "rollout" + ] + }, + "rollout": { + "description": "A utility to enable gradual rollout of large codegen changes. Can be constructed as the Default which passes or a percentage between 0 and 100.", + "type": [ + "integer", + "null" + ], + "format": "uint8", + "minimum": 0.0 + } + } + } + ] + }, + "disable_edge_type_name_validation_on_declerative_connection_directives": { + "description": "Disable validation of the `edgeTypeName` argument on `@prependNode` and `@appendNode`.", + "default": { + "kind": "disabled" + }, + "oneOf": [ + { + "description": "Fully disabled: developers may not use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "disabled" + ] + } + } + }, + { + "description": "Fully enabled: developers may use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "enabled" + ] + } + } + }, + { + "description": "Partially enabled: developers may only use this feature on the listed items (fragments, fields, types).", + "type": "object", + "required": [ + "allowlist", + "kind" + ], + "properties": { + "allowlist": { + "type": "array", + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "kind": { + "type": "string", + "enum": [ + "limited" + ] + } + } + }, + { + "description": "Partially enabled: used for gradual rollout of the feature", + "type": "object", + "required": [ + "kind", + "rollout" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "rollout" + ] + }, + "rollout": { + "description": "A utility to enable gradual rollout of large codegen changes. Can be constructed as the Default which passes or a percentage between 0 and 100.", + "type": [ + "integer", + "null" + ], + "format": "uint8", + "minimum": 0.0 + } + } + } + ] + }, + "disable_resolver_reader_ast": { + "description": "Mirror of `enable_resolver_normalization_ast` excludes resolver metadata from reader ast", + "default": false, + "type": "boolean" + }, + "disable_schema_validation": { + "description": "Disable validating the composite schema (server, client schema extensions, Relay Resolvers) after its built.", + "default": false, + "type": "boolean" + }, + "disallow_required_on_non_null_fields": { + "description": "Disallow the `@required` directive on fields that are already non-null in the schema.", + "default": false, + "type": "boolean" + }, + "emit_normalization_nodes_for_client_edges": { + "description": "Create normalization nodes for client edges to client objects", + "default": true, + "type": "boolean" + }, + "enable_3d_branch_arg_generation": { + "default": false, + "type": "boolean" + }, + "enable_catch_directive_transform": { + "default": { + "kind": "disabled" + }, + "oneOf": [ + { + "description": "Fully disabled: developers may not use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "disabled" + ] + } + } + }, + { + "description": "Fully enabled: developers may use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "enabled" + ] + } + } + }, + { + "description": "Partially enabled: developers may only use this feature on the listed items (fragments, fields, types).", + "type": "object", + "required": [ + "allowlist", + "kind" + ], + "properties": { + "allowlist": { + "type": "array", + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "kind": { + "type": "string", + "enum": [ + "limited" + ] + } + } + }, + { + "description": "Partially enabled: used for gradual rollout of the feature", + "type": "object", + "required": [ + "kind", + "rollout" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "rollout" + ] + }, + "rollout": { + "description": "A utility to enable gradual rollout of large codegen changes. Can be constructed as the Default which passes or a percentage between 0 and 100.", + "type": [ + "integer", + "null" + ], + "format": "uint8", + "minimum": 0.0 + } + } + } + ] + }, + "enable_fragment_aliases": { + "description": "Enable support for the experimental `@alias` directive on fragment spreads.", + "default": { + "kind": "disabled" + }, + "oneOf": [ + { + "description": "Fully disabled: developers may not use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "disabled" + ] + } + } + }, + { + "description": "Fully enabled: developers may use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "enabled" + ] + } + } + }, + { + "description": "Partially enabled: developers may only use this feature on the listed items (fragments, fields, types).", + "type": "object", + "required": [ + "allowlist", + "kind" + ], + "properties": { + "allowlist": { + "type": "array", + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "kind": { + "type": "string", + "enum": [ + "limited" + ] + } + } + }, + { + "description": "Partially enabled: used for gradual rollout of the feature", + "type": "object", + "required": [ + "kind", + "rollout" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "rollout" + ] + }, + "rollout": { + "description": "A utility to enable gradual rollout of large codegen changes. Can be constructed as the Default which passes or a percentage between 0 and 100.", + "type": [ + "integer", + "null" + ], + "format": "uint8", + "minimum": 0.0 + } + } + } + ] + }, + "enable_fragment_argument_transform": { + "description": "Add support for parsing and transforming variable definitions on fragment definitions and arguments on fragment spreads.", + "default": false, + "type": "boolean" + }, + "enable_relay_resolver_mutations": { + "description": "Allow relay resolvers to extend the Mutation type", + "default": false, + "type": "boolean" + }, + "enable_relay_resolver_transform": { + "default": false, + "type": "boolean" + }, + "enable_resolver_normalization_ast": { + "description": "Fully build the normalization AST for Resolvers", + "default": false, + "type": "boolean" + }, + "enable_strict_custom_scalars": { + "description": "Perform strict validations when custom scalar types are used", + "default": false, + "type": "boolean" + }, + "enforce_fragment_alias_where_ambiguous": { + "description": "Enforce that you must add `@alias` to a fragment if it may not match, due to type mismatch or `@skip`/`@include`", + "default": { + "kind": "disabled" + }, + "oneOf": [ + { + "description": "Fully disabled: developers may not use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "disabled" + ] + } + } + }, + { + "description": "Fully enabled: developers may use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "enabled" + ] + } + } + }, + { + "description": "Partially enabled: developers may only use this feature on the listed items (fragments, fields, types).", + "type": "object", + "required": [ + "allowlist", + "kind" + ], + "properties": { + "allowlist": { + "type": "array", + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "kind": { + "type": "string", + "enum": [ + "limited" + ] + } + } + }, + { + "description": "Partially enabled: used for gradual rollout of the feature", + "type": "object", + "required": [ + "kind", + "rollout" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "rollout" + ] + }, + "rollout": { + "description": "A utility to enable gradual rollout of large codegen changes. Can be constructed as the Default which passes or a percentage between 0 and 100.", + "type": [ + "integer", + "null" + ], + "format": "uint8", + "minimum": 0.0 + } + } + } + ] + }, + "no_inline": { + "description": "For now, this also disallows fragments with variable definitions This also makes @module to opt in using @no_inline internally NOTE that the presence of a fragment in this list only controls whether a fragment is *allowed* to use @no_inline: whether the fragment is inlined or not depends on whether it actually uses that directive.", + "default": { + "kind": "disabled" + }, + "oneOf": [ + { + "description": "Fully disabled: developers may not use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "disabled" + ] + } + } + }, + { + "description": "Fully enabled: developers may use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "enabled" + ] + } + } + }, + { + "description": "Partially enabled: developers may only use this feature on the listed items (fragments, fields, types).", + "type": "object", + "required": [ + "allowlist", + "kind" + ], + "properties": { + "allowlist": { + "type": "array", + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "kind": { + "type": "string", + "enum": [ + "limited" + ] + } + } + }, + { + "description": "Partially enabled: used for gradual rollout of the feature", + "type": "object", + "required": [ + "kind", + "rollout" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "rollout" + ] + }, + "rollout": { + "description": "A utility to enable gradual rollout of large codegen changes. Can be constructed as the Default which passes or a percentage between 0 and 100.", + "type": [ + "integer", + "null" + ], + "format": "uint8", + "minimum": 0.0 + } + } + } + ] + }, + "prefer_fetchable_in_refetch_queries": { + "description": "Feature flag to prefer `fetch_MyType()` generatior over `node()` query generator in @refetchable transform", + "default": false, + "type": "boolean" + }, + "relay_resolver_enable_interface_output_type": { + "default": { + "kind": "disabled" + }, + "oneOf": [ + { + "description": "Fully disabled: developers may not use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "disabled" + ] + } + } + }, + { + "description": "Fully enabled: developers may use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "enabled" + ] + } + } + }, + { + "description": "Partially enabled: developers may only use this feature on the listed items (fragments, fields, types).", + "type": "object", + "required": [ + "allowlist", + "kind" + ], + "properties": { + "allowlist": { + "type": "array", + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "kind": { + "type": "string", + "enum": [ + "limited" + ] + } + } + }, + { + "description": "Partially enabled: used for gradual rollout of the feature", + "type": "object", + "required": [ + "kind", + "rollout" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "rollout" + ] + }, + "rollout": { + "description": "A utility to enable gradual rollout of large codegen changes. Can be constructed as the Default which passes or a percentage between 0 and 100.", + "type": [ + "integer", + "null" + ], + "format": "uint8", + "minimum": 0.0 + } + } + } + ] + }, + "skip_printing_nulls": { + "default": { + "kind": "disabled" + }, + "oneOf": [ + { + "description": "Fully disabled: developers may not use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "disabled" + ] + } + } + }, + { + "description": "Fully enabled: developers may use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "enabled" + ] + } + } + }, + { + "description": "Partially enabled: developers may only use this feature on the listed items (fragments, fields, types).", + "type": "object", + "required": [ + "allowlist", + "kind" + ], + "properties": { + "allowlist": { + "type": "array", + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "kind": { + "type": "string", + "enum": [ + "limited" + ] + } + } + }, + { + "description": "Partially enabled: used for gradual rollout of the feature", + "type": "object", + "required": [ + "kind", + "rollout" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "rollout" + ] + }, + "rollout": { + "description": "A utility to enable gradual rollout of large codegen changes. Can be constructed as the Default which passes or a percentage between 0 and 100.", + "type": [ + "integer", + "null" + ], + "format": "uint8", + "minimum": 0.0 + } + } + } + ] + }, + "text_artifacts": { + "description": "Enable generation of text artifacts used to generate full query strings later.", + "default": { + "kind": "disabled" + }, + "oneOf": [ + { + "description": "Fully disabled: developers may not use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "disabled" + ] + } + } + }, + { + "description": "Fully enabled: developers may use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "enabled" + ] + } + } + }, + { + "description": "Partially enabled: developers may only use this feature on the listed items (fragments, fields, types).", + "type": "object", + "required": [ + "allowlist", + "kind" + ], + "properties": { + "allowlist": { + "type": "array", + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "kind": { + "type": "string", + "enum": [ + "limited" + ] + } + } + }, + { + "description": "Partially enabled: used for gradual rollout of the feature", + "type": "object", + "required": [ + "kind", + "rollout" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "rollout" + ] + }, + "rollout": { + "description": "A utility to enable gradual rollout of large codegen changes. Can be constructed as the Default which passes or a percentage between 0 and 100.", + "type": [ + "integer", + "null" + ], + "format": "uint8", + "minimum": 0.0 + } + } + } + ] + } + }, + "additionalProperties": false + }, + "generatedSources": { + "description": "Similar to sources but not affected by excludes.", + "default": {}, + "type": "object", + "additionalProperties": { + "description": "Set of project names.", + "type": "array", + "items": { + "anyOf": [ + { + "type": "null" + }, + { + "type": "string" + } + ] + } + } + }, + "header": { + "default": [], + "type": "array", + "items": { + "type": "string" + } + }, + "isDevVariableName": { + "description": "Then name of the global __DEV__ variable to use in generated artifacts", + "type": [ + "string", + "null" + ] + }, + "name": { + "description": "Optional name for this config, might be used for logging or custom extra artifact generator code.", + "default": null, + "type": [ + "string", + "null" + ] + }, + "projects": { + "description": "Configuration of projects to compile.", + "type": "object", + "additionalProperties": { + "type": "object", + "required": [ + "language" + ], + "properties": { + "base": { + "description": "If a base project is set, the documents of that project can be referenced, but won't produce output artifacts. Extensions from the base project will be added as well and the schema of the base project should be a subset of the schema of this project.", + "default": null, + "anyOf": [ + { + "anyOf": [ + { + "type": "null" + }, + { + "type": "string" + } + ] + }, + { + "type": "null" + } + ] + }, + "codegenCommand": { + "default": null, + "type": [ + "string", + "null" + ] + }, + "customScalarTypes": { + "description": "A map from GraphQL scalar types to a custom JS type, example: { \"Url\": \"String\" } { \"Url\": {\"name:: \"MyURL\", \"path\": \"../src/MyUrlTypes\"} }", + "default": {}, + "type": "object", + "additionalProperties": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "object", + "required": [ + "name", + "path" + ], + "properties": { + "name": { + "type": "string" + }, + "path": { + "type": "string" + } + } + } + ] + } + }, + "diagnosticReportConfig": { + "description": "Configuration for all diagnostic reporting in the compiler", + "default": { + "criticalLevel": "error" + }, + "type": "object", + "required": [ + "criticalLevel" + ], + "properties": { + "criticalLevel": { + "description": "Threshold for diagnostics to be critical to the compiler's execution. All diagnostic with severities at and below this level will cause the compiler to fatally exit.", + "oneOf": [ + { + "description": "Report only errors", + "type": "string", + "enum": [ + "error" + ] + }, + { + "description": "Report diagnostics up to warnings", + "type": "string", + "enum": [ + "warning" + ] + }, + { + "description": "Report diagnostics up to informational diagnostics", + "type": "string", + "enum": [ + "info" + ] + }, + { + "description": "Report diagnostics up to hints", + "type": "string", + "enum": [ + "hint" + ] + } + ] + } + } + }, + "eagerEsModules": { + "description": "This option enables emitting es modules artifacts.", + "default": false, + "type": "boolean" + }, + "enumModuleSuffix": { + "title": "For Flow type generation", + "description": "When set, enum values are imported from a module with this suffix. For example, an enum Foo and this property set to \".test\" would be imported from \"Foo.test\". Note: an empty string is allowed and different from not setting the value, in the example above it would just import from \"Foo\".", + "type": [ + "string", + "null" + ] + }, + "experimentalEmitSemanticNullabilityTypes": { + "description": "EXPERIMENTAL: If your environment is configured to handles errors out of band, either via a network layer which discards responses with errors, or via enabling strict error handling in the runtime, you can enable this flag to have Relay generate non-null types for fields which are marked as semantically non-null in the schema.\n\nCurrently semantically non-null fields must be specified in your schema using the `@semanticNonNull` directive as specified in: https://github.com/apollographql/specs/pull/42", + "default": false, + "type": "boolean" + }, + "extra": { + "description": "A placeholder for allowing extra information in the config file", + "default": null + }, + "extraArtifactsOutput": { + "description": "Some projects may need to generate extra artifacts. For those, we may need to provide an additional directory to put them. By default the will use `output` *if available", + "type": [ + "string", + "null" + ] + }, + "featureFlags": { + "default": null, + "type": [ + "object", + "null" + ], + "properties": { + "actor_change_support": { + "default": { + "kind": "disabled" + }, + "oneOf": [ + { + "description": "Fully disabled: developers may not use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "disabled" + ] + } + } + }, + { + "description": "Fully enabled: developers may use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "enabled" + ] + } + } + }, + { + "description": "Partially enabled: developers may only use this feature on the listed items (fragments, fields, types).", + "type": "object", + "required": [ + "allowlist", + "kind" + ], + "properties": { + "allowlist": { + "type": "array", + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "kind": { + "type": "string", + "enum": [ + "limited" + ] + } + } + }, + { + "description": "Partially enabled: used for gradual rollout of the feature", + "type": "object", + "required": [ + "kind", + "rollout" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "rollout" + ] + }, + "rollout": { + "description": "A utility to enable gradual rollout of large codegen changes. Can be constructed as the Default which passes or a percentage between 0 and 100.", + "type": [ + "integer", + "null" + ], + "format": "uint8", + "minimum": 0.0 + } + } + } + ] + }, + "allow_required_in_mutation_response": { + "description": "@required with an action of THROW is read-time feature that is not compatible with our mutation APIs. We are in the process of removing any existing examples, but this flag is part of a process of removing any existing examples.", + "default": { + "kind": "disabled" + }, + "oneOf": [ + { + "description": "Fully disabled: developers may not use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "disabled" + ] + } + } + }, + { + "description": "Fully enabled: developers may use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "enabled" + ] + } + } + }, + { + "description": "Partially enabled: developers may only use this feature on the listed items (fragments, fields, types).", + "type": "object", + "required": [ + "allowlist", + "kind" + ], + "properties": { + "allowlist": { + "type": "array", + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "kind": { + "type": "string", + "enum": [ + "limited" + ] + } + } + }, + { + "description": "Partially enabled: used for gradual rollout of the feature", + "type": "object", + "required": [ + "kind", + "rollout" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "rollout" + ] + }, + "rollout": { + "description": "A utility to enable gradual rollout of large codegen changes. Can be constructed as the Default which passes or a percentage between 0 and 100.", + "type": [ + "integer", + "null" + ], + "format": "uint8", + "minimum": 0.0 + } + } + } + ] + }, + "allow_resolver_non_nullable_return_type": { + "description": "Allow non-nullable return types from resolvers.", + "default": { + "kind": "disabled" + }, + "oneOf": [ + { + "description": "Fully disabled: developers may not use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "disabled" + ] + } + } + }, + { + "description": "Fully enabled: developers may use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "enabled" + ] + } + } + }, + { + "description": "Partially enabled: developers may only use this feature on the listed items (fragments, fields, types).", + "type": "object", + "required": [ + "allowlist", + "kind" + ], + "properties": { + "allowlist": { + "type": "array", + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "kind": { + "type": "string", + "enum": [ + "limited" + ] + } + } + }, + { + "description": "Partially enabled: used for gradual rollout of the feature", + "type": "object", + "required": [ + "kind", + "rollout" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "rollout" + ] + }, + "rollout": { + "description": "A utility to enable gradual rollout of large codegen changes. Can be constructed as the Default which passes or a percentage between 0 and 100.", + "type": [ + "integer", + "null" + ], + "format": "uint8", + "minimum": 0.0 + } + } + } + ] + }, + "allow_resolvers_in_mutation_response": { + "description": "Relay Resolvers are a read-time feature that are not actually handled in our mutation APIs. We are in the process of removing any existing examples, but this flag is part of a process of removing any existing examples.", + "default": { + "kind": "disabled" + }, + "oneOf": [ + { + "description": "Fully disabled: developers may not use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "disabled" + ] + } + } + }, + { + "description": "Fully enabled: developers may use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "enabled" + ] + } + } + }, + { + "description": "Partially enabled: developers may only use this feature on the listed items (fragments, fields, types).", + "type": "object", + "required": [ + "allowlist", + "kind" + ], + "properties": { + "allowlist": { + "type": "array", + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "kind": { + "type": "string", + "enum": [ + "limited" + ] + } + } + }, + { + "description": "Partially enabled: used for gradual rollout of the feature", + "type": "object", + "required": [ + "kind", + "rollout" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "rollout" + ] + }, + "rollout": { + "description": "A utility to enable gradual rollout of large codegen changes. Can be constructed as the Default which passes or a percentage between 0 and 100.", + "type": [ + "integer", + "null" + ], + "format": "uint8", + "minimum": 0.0 + } + } + } + ] + }, + "compact_query_text": { + "description": "Print queries in compact form", + "default": { + "kind": "disabled" + }, + "oneOf": [ + { + "description": "Fully disabled: developers may not use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "disabled" + ] + } + } + }, + { + "description": "Fully enabled: developers may use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "enabled" + ] + } + } + }, + { + "description": "Partially enabled: developers may only use this feature on the listed items (fragments, fields, types).", + "type": "object", + "required": [ + "allowlist", + "kind" + ], + "properties": { + "allowlist": { + "type": "array", + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "kind": { + "type": "string", + "enum": [ + "limited" + ] + } + } + }, + { + "description": "Partially enabled: used for gradual rollout of the feature", + "type": "object", + "required": [ + "kind", + "rollout" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "rollout" + ] + }, + "rollout": { + "description": "A utility to enable gradual rollout of large codegen changes. Can be constructed as the Default which passes or a percentage between 0 and 100.", + "type": [ + "integer", + "null" + ], + "format": "uint8", + "minimum": 0.0 + } + } + } + ] + }, + "disable_edge_type_name_validation_on_declerative_connection_directives": { + "description": "Disable validation of the `edgeTypeName` argument on `@prependNode` and `@appendNode`.", + "default": { + "kind": "disabled" + }, + "oneOf": [ + { + "description": "Fully disabled: developers may not use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "disabled" + ] + } + } + }, + { + "description": "Fully enabled: developers may use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "enabled" + ] + } + } + }, + { + "description": "Partially enabled: developers may only use this feature on the listed items (fragments, fields, types).", + "type": "object", + "required": [ + "allowlist", + "kind" + ], + "properties": { + "allowlist": { + "type": "array", + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "kind": { + "type": "string", + "enum": [ + "limited" + ] + } + } + }, + { + "description": "Partially enabled: used for gradual rollout of the feature", + "type": "object", + "required": [ + "kind", + "rollout" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "rollout" + ] + }, + "rollout": { + "description": "A utility to enable gradual rollout of large codegen changes. Can be constructed as the Default which passes or a percentage between 0 and 100.", + "type": [ + "integer", + "null" + ], + "format": "uint8", + "minimum": 0.0 + } + } + } + ] + }, + "disable_resolver_reader_ast": { + "description": "Mirror of `enable_resolver_normalization_ast` excludes resolver metadata from reader ast", + "default": false, + "type": "boolean" + }, + "disable_schema_validation": { + "description": "Disable validating the composite schema (server, client schema extensions, Relay Resolvers) after its built.", + "default": false, + "type": "boolean" + }, + "disallow_required_on_non_null_fields": { + "description": "Disallow the `@required` directive on fields that are already non-null in the schema.", + "default": false, + "type": "boolean" + }, + "emit_normalization_nodes_for_client_edges": { + "description": "Create normalization nodes for client edges to client objects", + "default": true, + "type": "boolean" + }, + "enable_3d_branch_arg_generation": { + "default": false, + "type": "boolean" + }, + "enable_catch_directive_transform": { + "default": { + "kind": "disabled" + }, + "oneOf": [ + { + "description": "Fully disabled: developers may not use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "disabled" + ] + } + } + }, + { + "description": "Fully enabled: developers may use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "enabled" + ] + } + } + }, + { + "description": "Partially enabled: developers may only use this feature on the listed items (fragments, fields, types).", + "type": "object", + "required": [ + "allowlist", + "kind" + ], + "properties": { + "allowlist": { + "type": "array", + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "kind": { + "type": "string", + "enum": [ + "limited" + ] + } + } + }, + { + "description": "Partially enabled: used for gradual rollout of the feature", + "type": "object", + "required": [ + "kind", + "rollout" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "rollout" + ] + }, + "rollout": { + "description": "A utility to enable gradual rollout of large codegen changes. Can be constructed as the Default which passes or a percentage between 0 and 100.", + "type": [ + "integer", + "null" + ], + "format": "uint8", + "minimum": 0.0 + } + } + } + ] + }, + "enable_fragment_aliases": { + "description": "Enable support for the experimental `@alias` directive on fragment spreads.", + "default": { + "kind": "disabled" + }, + "oneOf": [ + { + "description": "Fully disabled: developers may not use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "disabled" + ] + } + } + }, + { + "description": "Fully enabled: developers may use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "enabled" + ] + } + } + }, + { + "description": "Partially enabled: developers may only use this feature on the listed items (fragments, fields, types).", + "type": "object", + "required": [ + "allowlist", + "kind" + ], + "properties": { + "allowlist": { + "type": "array", + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "kind": { + "type": "string", + "enum": [ + "limited" + ] + } + } + }, + { + "description": "Partially enabled: used for gradual rollout of the feature", + "type": "object", + "required": [ + "kind", + "rollout" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "rollout" + ] + }, + "rollout": { + "description": "A utility to enable gradual rollout of large codegen changes. Can be constructed as the Default which passes or a percentage between 0 and 100.", + "type": [ + "integer", + "null" + ], + "format": "uint8", + "minimum": 0.0 + } + } + } + ] + }, + "enable_fragment_argument_transform": { + "description": "Add support for parsing and transforming variable definitions on fragment definitions and arguments on fragment spreads.", + "default": false, + "type": "boolean" + }, + "enable_relay_resolver_mutations": { + "description": "Allow relay resolvers to extend the Mutation type", + "default": false, + "type": "boolean" + }, + "enable_relay_resolver_transform": { + "default": false, + "type": "boolean" + }, + "enable_resolver_normalization_ast": { + "description": "Fully build the normalization AST for Resolvers", + "default": false, + "type": "boolean" + }, + "enable_strict_custom_scalars": { + "description": "Perform strict validations when custom scalar types are used", + "default": false, + "type": "boolean" + }, + "enforce_fragment_alias_where_ambiguous": { + "description": "Enforce that you must add `@alias` to a fragment if it may not match, due to type mismatch or `@skip`/`@include`", + "default": { + "kind": "disabled" + }, + "oneOf": [ + { + "description": "Fully disabled: developers may not use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "disabled" + ] + } + } + }, + { + "description": "Fully enabled: developers may use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "enabled" + ] + } + } + }, + { + "description": "Partially enabled: developers may only use this feature on the listed items (fragments, fields, types).", + "type": "object", + "required": [ + "allowlist", + "kind" + ], + "properties": { + "allowlist": { + "type": "array", + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "kind": { + "type": "string", + "enum": [ + "limited" + ] + } + } + }, + { + "description": "Partially enabled: used for gradual rollout of the feature", + "type": "object", + "required": [ + "kind", + "rollout" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "rollout" + ] + }, + "rollout": { + "description": "A utility to enable gradual rollout of large codegen changes. Can be constructed as the Default which passes or a percentage between 0 and 100.", + "type": [ + "integer", + "null" + ], + "format": "uint8", + "minimum": 0.0 + } + } + } + ] + }, + "no_inline": { + "description": "For now, this also disallows fragments with variable definitions This also makes @module to opt in using @no_inline internally NOTE that the presence of a fragment in this list only controls whether a fragment is *allowed* to use @no_inline: whether the fragment is inlined or not depends on whether it actually uses that directive.", + "default": { + "kind": "disabled" + }, + "oneOf": [ + { + "description": "Fully disabled: developers may not use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "disabled" + ] + } + } + }, + { + "description": "Fully enabled: developers may use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "enabled" + ] + } + } + }, + { + "description": "Partially enabled: developers may only use this feature on the listed items (fragments, fields, types).", + "type": "object", + "required": [ + "allowlist", + "kind" + ], + "properties": { + "allowlist": { + "type": "array", + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "kind": { + "type": "string", + "enum": [ + "limited" + ] + } + } + }, + { + "description": "Partially enabled: used for gradual rollout of the feature", + "type": "object", + "required": [ + "kind", + "rollout" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "rollout" + ] + }, + "rollout": { + "description": "A utility to enable gradual rollout of large codegen changes. Can be constructed as the Default which passes or a percentage between 0 and 100.", + "type": [ + "integer", + "null" + ], + "format": "uint8", + "minimum": 0.0 + } + } + } + ] + }, + "prefer_fetchable_in_refetch_queries": { + "description": "Feature flag to prefer `fetch_MyType()` generatior over `node()` query generator in @refetchable transform", + "default": false, + "type": "boolean" + }, + "relay_resolver_enable_interface_output_type": { + "default": { + "kind": "disabled" + }, + "oneOf": [ + { + "description": "Fully disabled: developers may not use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "disabled" + ] + } + } + }, + { + "description": "Fully enabled: developers may use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "enabled" + ] + } + } + }, + { + "description": "Partially enabled: developers may only use this feature on the listed items (fragments, fields, types).", + "type": "object", + "required": [ + "allowlist", + "kind" + ], + "properties": { + "allowlist": { + "type": "array", + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "kind": { + "type": "string", + "enum": [ + "limited" + ] + } + } + }, + { + "description": "Partially enabled: used for gradual rollout of the feature", + "type": "object", + "required": [ + "kind", + "rollout" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "rollout" + ] + }, + "rollout": { + "description": "A utility to enable gradual rollout of large codegen changes. Can be constructed as the Default which passes or a percentage between 0 and 100.", + "type": [ + "integer", + "null" + ], + "format": "uint8", + "minimum": 0.0 + } + } + } + ] + }, + "skip_printing_nulls": { + "default": { + "kind": "disabled" + }, + "oneOf": [ + { + "description": "Fully disabled: developers may not use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "disabled" + ] + } + } + }, + { + "description": "Fully enabled: developers may use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "enabled" + ] + } + } + }, + { + "description": "Partially enabled: developers may only use this feature on the listed items (fragments, fields, types).", + "type": "object", + "required": [ + "allowlist", + "kind" + ], + "properties": { + "allowlist": { + "type": "array", + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "kind": { + "type": "string", + "enum": [ + "limited" + ] + } + } + }, + { + "description": "Partially enabled: used for gradual rollout of the feature", + "type": "object", + "required": [ + "kind", + "rollout" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "rollout" + ] + }, + "rollout": { + "description": "A utility to enable gradual rollout of large codegen changes. Can be constructed as the Default which passes or a percentage between 0 and 100.", + "type": [ + "integer", + "null" + ], + "format": "uint8", + "minimum": 0.0 + } + } + } + ] + }, + "text_artifacts": { + "description": "Enable generation of text artifacts used to generate full query strings later.", + "default": { + "kind": "disabled" + }, + "oneOf": [ + { + "description": "Fully disabled: developers may not use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "disabled" + ] + } + } + }, + { + "description": "Fully enabled: developers may use this feature", + "type": "object", + "required": [ + "kind" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "enabled" + ] + } + } + }, + { + "description": "Partially enabled: developers may only use this feature on the listed items (fragments, fields, types).", + "type": "object", + "required": [ + "allowlist", + "kind" + ], + "properties": { + "allowlist": { + "type": "array", + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "kind": { + "type": "string", + "enum": [ + "limited" + ] + } + } + }, + { + "description": "Partially enabled: used for gradual rollout of the feature", + "type": "object", + "required": [ + "kind", + "rollout" + ], + "properties": { + "kind": { + "type": "string", + "enum": [ + "rollout" + ] + }, + "rollout": { + "description": "A utility to enable gradual rollout of large codegen changes. Can be constructed as the Default which passes or a percentage between 0 and 100.", + "type": [ + "integer", + "null" + ], + "format": "uint8", + "minimum": 0.0 + } + } + } + ] + } + }, + "additionalProperties": false + }, + "jsModuleFormat": { + "description": "Formatting style for generated files.", + "default": "commonjs", + "oneOf": [ + { + "description": "Common JS style, e.g. `require('../path/MyModule')`", + "type": "string", + "enum": [ + "commonjs" + ] + }, + { + "description": "Facebook style, e.g. `require('MyModule')`", + "type": "string", + "enum": [ + "haste" + ] + } + ] + }, + "language": { + "description": "The desired output language, \"flow\" or \"typescript\".", + "type": "string", + "enum": [ + "javascript", + "typescript", + "flow" + ] + }, + "moduleImportConfig": { + "description": "Configuration for @module.", + "default": { + "dynamicModuleProvider": null + }, + "type": "object", + "properties": { + "dynamicModuleProvider": { + "description": "Defines the custom import statement to be generated on the `ModuleImport` node in ASTs, used for dynamically loading components at runtime.", + "anyOf": [ + { + "oneOf": [ + { + "description": "Generates a module provider using JSResource", + "type": "object", + "required": [ + "mode" + ], + "properties": { + "mode": { + "type": "string", + "enum": [ + "JSResource" + ] + } + } + }, + { + "description": "Generates a custom JS import, Use `<$module>` as the placeholder for the actual module. e.g. `\"() => import('<$module>')\"`", + "type": "object", + "required": [ + "mode", + "statement" + ], + "properties": { + "mode": { + "type": "string", + "enum": [ + "Custom" + ] + }, + "statement": { + "type": "string" + } + } + } + ] + }, + { + "type": "null" + } + ] + } + }, + "additionalProperties": false + }, + "noFutureProofEnums": { + "description": "This option controls whether or not a catch-all entry is added to enum type definitions for values that may be added in the future. Enabling this means you will have to update your application whenever the GraphQL server schema adds new enum values to prevent it from breaking.", + "default": false, + "type": "boolean" + }, + "optionalInputFields": { + "title": "For Flow type generation", + "description": "When set, generated input types will have the listed fields optional even if the schema defines them as required.", + "default": [], + "type": "array", + "items": { + "type": "string" + } + }, + "output": { + "description": "A project without an output directory will put the generated files in a __generated__ directory next to the input file. All files in these directories should be generated by the Relay compiler, so that the compiler can cleanup extra files.", + "default": null, + "type": [ + "string", + "null" + ] + }, + "persist": { + "description": "If this option is set, the compiler will persist queries using this config.", + "anyOf": [ + { + "anyOf": [ + { + "type": "object", + "required": [ + "url" + ], + "properties": { + "concurrency": { + "default": null, + "type": [ + "integer", + "null" + ], + "format": "uint", + "minimum": 0.0 + }, + "headers": { + "description": "Additional headers to send", + "default": {}, + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "includeQueryText": { + "default": false, + "type": "boolean" + }, + "params": { + "description": "The document will be in a POST parameter `text`. This map can contain additional parameters to send.", + "default": {}, + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "url": { + "description": "URL to send a POST request to to persist.", + "type": "string" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "file" + ], + "properties": { + "algorithm": { + "default": "MD5", + "type": "string", + "enum": [ + "MD5", + "SHA1", + "SHA256" + ] + }, + "file": { + "type": "string" + }, + "include_query_text": { + "default": false, + "type": "boolean" + } + }, + "additionalProperties": false + } + ] + }, + { + "type": "null" + } + ] + }, + "requireCustomScalarTypes": { + "description": "Require all GraphQL scalar types mapping to be defined, will throw if a GraphQL scalar type doesn't have a JS type", + "default": false, + "type": "boolean" + }, + "resolversSchemaModule": { + "description": "Configuration for resolvers_schema_module generation", + "default": null, + "type": [ + "object", + "null" + ], + "properties": { + "applyToNormalizationAst": { + "default": false, + "type": "boolean" + }, + "path": { + "default": "", + "type": "string" + } + }, + "additionalProperties": false + }, + "rollout": { + "description": "A generic rollout state for larger codegen changes. The default is to pass, otherwise it should be a number between 0 and 100 as a percentage.", + "default": null, + "type": [ + "integer", + "null" + ], + "format": "uint8", + "minimum": 0.0 + }, + "schema": { + "description": "Path to the schema.graphql or a directory containing a schema broken up in multiple *.graphql files. Exactly 1 of these options needs to be defined.", + "type": [ + "string", + "null" + ] + }, + "schemaConfig": { + "default": { + "connectionInterface": { + "cursor": "cursor", + "edges": "edges", + "endCursor": "endCursor", + "hasNextPage": "hasNextPage", + "hasPreviousPage": "hasPreviousPage", + "node": "node", + "pageInfo": "pageInfo", + "startCursor": "startCursor" + }, + "deferStreamInterface": { + "deferName": "defer", + "ifArg": "if", + "initialCountArg": "initialCount", + "labelArg": "label", + "streamName": "stream", + "useCustomizedBatchArg": "useCustomizedBatch" + }, + "nodeInterfaceIdField": "id", + "nodeInterfaceIdVariableName": "id", + "nonNodeIdFields": null, + "unselectableDirectiveName": "unselectable" + }, + "type": "object", + "properties": { + "connectionInterface": { + "description": "Configuration where Relay should expect some fields in the schema.", + "default": { + "cursor": "cursor", + "edges": "edges", + "endCursor": "endCursor", + "hasNextPage": "hasNextPage", + "hasPreviousPage": "hasPreviousPage", + "node": "node", + "pageInfo": "pageInfo", + "startCursor": "startCursor" + }, + "type": "object", + "required": [ + "cursor", + "edges", + "endCursor", + "hasNextPage", + "hasPreviousPage", + "node", + "pageInfo", + "startCursor" + ], + "properties": { + "cursor": { + "type": "string" + }, + "edges": { + "type": "string" + }, + "endCursor": { + "type": "string" + }, + "hasNextPage": { + "type": "string" + }, + "hasPreviousPage": { + "type": "string" + }, + "node": { + "type": "string" + }, + "pageInfo": { + "type": "string" + }, + "startCursor": { + "type": "string" + } + }, + "additionalProperties": false + }, + "deferStreamInterface": { + "description": "Configuration where Relay should expect some fields in the schema.", + "default": { + "deferName": "defer", + "ifArg": "if", + "initialCountArg": "initialCount", + "labelArg": "label", + "streamName": "stream", + "useCustomizedBatchArg": "useCustomizedBatch" + }, + "type": "object", + "required": [ + "deferName", + "ifArg", + "initialCountArg", + "labelArg", + "streamName", + "useCustomizedBatchArg" + ], + "properties": { + "deferName": { + "description": "Wrapper struct for clarity rather than having StringKey everywhere.", + "type": "string" + }, + "ifArg": { + "type": "string" + }, + "initialCountArg": { + "type": "string" + }, + "labelArg": { + "type": "string" + }, + "streamName": { + "description": "Wrapper struct for clarity rather than having StringKey everywhere.", + "type": "string" + }, + "useCustomizedBatchArg": { + "type": "string" + } + }, + "additionalProperties": false + }, + "nodeInterfaceIdField": { + "description": "The name of the `id` field that exists on the `Node` interface.", + "default": "id", + "type": "string" + }, + "nodeInterfaceIdVariableName": { + "description": "The name of the variable expected by the `node` query.", + "default": "id", + "type": "string" + }, + "nonNodeIdFields": { + "description": "Configuration of Relay's validation for `id` fields outside of the `Node` interface.", + "default": null, + "type": [ + "object", + "null" + ], + "properties": { + "allowedIdTypes": { + "description": "A map of parent type names to allowed type names for fields named `id`", + "default": {}, + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "additionalProperties": false + }, + "unselectableDirectiveName": { + "description": "The name of the directive indicating fields that cannot be selected", + "default": "unselectable", + "type": "string" + } + } + }, + "schemaDir": { + "type": [ + "string", + "null" + ] + }, + "schemaExtensions": { + "description": "Directory containing *.graphql files with schema extensions.", + "default": [], + "type": "array", + "items": { + "type": "string" + } + }, + "shardOutput": { + "description": "If `output` is provided and `shard_output` is `true`, shard the files by putting them under `{output_dir}/{source_relative_path}`", + "default": false, + "type": "boolean" + }, + "shardStripRegex": { + "description": "Regex to match and strip parts of the `source_relative_path`", + "default": null, + "type": [ + "string", + "null" + ] + }, + "testPathRegex": { + "description": "Optional regex to restrict @relay_test_operation to directories matching this regex. Defaults to no limitations.", + "default": null, + "type": [ + "string", + "null" + ] + }, + "typescriptExcludeUndefinedFromNullableUnion": { + "description": "Keep the previous compiler behavior by outputting an union of the raw type and null, and not the **correct** behavior of an union with the raw type, null and undefined.", + "default": false, + "type": "boolean" + }, + "useImportTypeSyntax": { + "title": "For Typescript type generation", + "description": "Whether to use the `import type` syntax introduced in Typescript version 3.8. This will prevent warnings from `importsNotUsedAsValues`.", + "default": false, + "type": "boolean" + }, + "variableNamesComment": { + "description": "Generates a `// @relayVariables name1 name2` header in generated operation files", + "default": false, + "type": "boolean" + } + }, + "additionalProperties": false + } + }, + "root": { + "description": "Root directory relative to the config file. Defaults to the directory where the config is located.", + "default": null, + "type": [ + "string", + "null" + ] + }, + "savedStateConfig": { + "description": "Watchman saved state config.", + "type": [ + "object", + "null" + ], + "properties": { + "mergebase": { + "type": [ + "string", + "null" + ] + }, + "mergebase-with": { + "type": [ + "string", + "null" + ] + }, + "saved-state": { + "description": "Holds extended clock data that includes source control aware query metadata. ", + "type": [ + "object", + "null" + ], + "properties": { + "commit-id": { + "type": [ + "string", + "null" + ] + }, + "config": true, + "storage": { + "type": [ + "string", + "null" + ] + } + } + } + } + }, + "sources": { + "description": "A mapping from directory paths (relative to the root) to a source set. If a path is a subdirectory of another path, the more specific path wins.", + "type": "object", + "additionalProperties": { + "anyOf": [ + { + "anyOf": [ + { + "type": "null" + }, + { + "type": "string" + } + ] + }, + { + "type": "array", + "items": { + "anyOf": [ + { + "type": "null" + }, + { + "type": "string" + } + ] + } + } + ] + } + } + }, + "additionalProperties": false + } + ] +} \ No newline at end of file diff --git a/compiler/test-project/relay.config.json b/compiler/test-project/relay.config.json index 129bba0a20239..8b2242c7bbdb2 100644 --- a/compiler/test-project/relay.config.json +++ b/compiler/test-project/relay.config.json @@ -1,4 +1,5 @@ { + "$schema": "../relay-compiler-config-schema.json", "root": "../..", "header": [ "Copyright (c) Meta Platforms, Inc. and affiliates.", diff --git a/gulpfile.js b/gulpfile.js index 86e4aef8152ad..0d99319a7e6ef 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -360,6 +360,13 @@ const relayCompiler = gulp.parallel( }) .pipe(gulp.dest(path.join(DIST, 'relay-compiler'))); }, + function copyCompilerConfigSchema() { + return gulp + .src(['relay-compiler-config-schema.json'], { + cwd: path.join('compiler'), + }) + .pipe(gulp.dest(path.join(DIST, 'relay-compiler'))); + }, function copyCompilerBins() { return gulp .src('**', {