diff --git a/compiler/crates/relay-compiler/src/config.rs b/compiler/crates/relay-compiler/src/config.rs index 298bfe3eb053..1b9e0af0038a 100644 --- a/compiler/crates/relay-compiler/src/config.rs +++ b/compiler/crates/relay-compiler/src/config.rs @@ -702,7 +702,7 @@ pub struct MultiProjectConfigFile { feature_flags: FeatureFlags, /// Watchman saved state config. - #[schemars(skip)] // TODO: Fix me + #[schemars(with = "Option")] saved_state_config: Option, /// Then name of the global __DEV__ variable to use in generated artifacts @@ -1053,3 +1053,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/relay-compiler-config-schema.json b/compiler/relay-compiler-config-schema.json index 9d840bcf9fa9..02b31646c78a 100644 --- a/compiler/relay-compiler-config-schema.json +++ b/compiler/relay-compiler-config-schema.json @@ -4471,6 +4471,49 @@ "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",