Skip to content

Commit

Permalink
add rust docs for all top level enums in relay compiler
Browse files Browse the repository at this point in the history
Reviewed By: captbaritone

Differential Revision: D65613155

fbshipit-source-id: 768bf7c16754a2db72f8596c3d5dac80a3a3819e
  • Loading branch information
lynnshaoyu authored and facebook-github-bot committed Nov 8, 2024
1 parent 402aa97 commit bdbe7e0
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 3 deletions.
18 changes: 18 additions & 0 deletions compiler/crates/relay-compiler/relay-compiler-config-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1577,8 +1577,10 @@
"default": null,
"anyOf": [
{
"description": "Configuration for how the Relay Compiler should persist GraphQL queries.",
"anyOf": [
{
"description": "This variant represents a remote persistence configuration, where GraphQL queries are sent to a remote endpoint for persistence.",
"type": "object",
"required": [
"url"
Expand Down Expand Up @@ -1621,6 +1623,7 @@
"additionalProperties": false
},
{
"description": "This variant represents a local persistence configuration, where GraphQL queries are persisted to a local JSON file.\n\nWhen this variant is used, the compiler will attempt to read the local file as a hash map, add new queries to the map, and then serialize and write the resulting map to the configured path.",
"type": "object",
"required": [
"file"
Expand Down Expand Up @@ -3354,11 +3357,14 @@
"description": "Set of project names.",
"type": "array",
"items": {
"description": "Represents the name of a project in the Relay configuration.",
"anyOf": [
{
"description": "No project name is specified.",
"type": "null"
},
{
"description": "A project name.\n\nThis should match one the keys in the `projects` map in the Relay compiler config.",
"type": "string"
}
]
Expand Down Expand Up @@ -3408,11 +3414,14 @@
"default": null,
"anyOf": [
{
"description": "Represents the name of a project in the Relay configuration.",
"anyOf": [
{
"description": "No project name is specified.",
"type": "null"
},
{
"description": "A project name.\n\nThis should match one the keys in the `projects` map in the Relay compiler config.",
"type": "string"
}
]
Expand Down Expand Up @@ -5018,8 +5027,10 @@
"description": "If this option is set, the compiler will persist queries using this config.",
"anyOf": [
{
"description": "Configuration for how the Relay Compiler should persist GraphQL queries.",
"anyOf": [
{
"description": "This variant represents a remote persistence configuration, where GraphQL queries are sent to a remote endpoint for persistence.",
"type": "object",
"required": [
"url"
Expand Down Expand Up @@ -5062,6 +5073,7 @@
"additionalProperties": false
},
{
"description": "This variant represents a local persistence configuration, where GraphQL queries are persisted to a local JSON file.\n\nWhen this variant is used, the compiler will attempt to read the local file as a hash map, add new queries to the map, and then serialize and write the resulting map to the configured path.",
"type": "object",
"required": [
"file"
Expand Down Expand Up @@ -5460,23 +5472,29 @@
"additionalProperties": {
"anyOf": [
{
"description": "Represents the name of a project in the Relay configuration.",
"anyOf": [
{
"description": "No project name is specified.",
"type": "null"
},
{
"description": "A project name.\n\nThis should match one the keys in the `projects` map in the Relay compiler config.",
"type": "string"
}
]
},
{
"type": "array",
"items": {
"description": "Represents the name of a project in the Relay configuration.",
"anyOf": [
{
"description": "No project name is specified.",
"type": "null"
},
{
"description": "A project name.\n\nThis should match one the keys in the `projects` map in the Relay compiler config.",
"type": "string"
}
]
Expand Down
9 changes: 6 additions & 3 deletions compiler/crates/relay-compiler/src/artifact_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,16 @@ pub struct ArtifactRecord {
#[derive(Default, Serialize, Deserialize, Debug, Clone)]
pub struct ArtifactMap(pub DashMap<ArtifactSourceKey, Vec<ArtifactRecord>>);

/// An enum used to identify the source type a relay compiler artifact is generated from.
///
/// Artifacts can be derived from source types such as executable definitions, resolvers, or schemas.
#[derive(Serialize, Deserialize, Debug, Clone, Eq, PartialEq, Hash)]
pub enum ArtifactSourceKey {
/// Derieved from a GraphQL Executable Definition
/// Derived from a GraphQL Executable Definition, such as a Query, Mutation, or Fragment.
ExecutableDefinition(ExecutableDefinitionName),
/// Derieved from a RelayResolver docblock
/// Derived from a RelayResolver docblock.
ResolverHash(ResolverSourceHash),
/// Derived from GraphQL Schema
/// Derived from GraphQL Schema.
Schema(),
}

Expand Down
9 changes: 9 additions & 0 deletions compiler/crates/relay-config/src/project_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,16 @@ pub struct LocalPersistConfig {
pub include_query_text: bool,
}

/// Configuration for how the Relay Compiler should persist GraphQL queries.
#[derive(Debug, Serialize, Clone, JsonSchema)]
#[serde(untagged)]
pub enum PersistConfig {
/// This variant represents a remote persistence configuration, where GraphQL queries are sent to a remote endpoint for persistence.
Remote(RemotePersistConfig),
/// This variant represents a local persistence configuration, where GraphQL queries are persisted to a local JSON file.
///
/// When this variant is used, the compiler will attempt to read the local file as a hash map,
/// add new queries to the map, and then serialize and write the resulting map to the configured path.
Local(LocalPersistConfig),
}

Expand Down Expand Up @@ -157,9 +163,12 @@ It also cannot be a local persist configuration due to:
}
}

/// Specifies the type of location of a GraphQL schema, and the path to the schema location.
#[derive(Clone, Debug, JsonSchema)]
pub enum SchemaLocation {
/// A single file containing the schema.
File(PathBuf),
/// A directory containing multiple schema files.
Directory(PathBuf),
}

Expand Down
5 changes: 5 additions & 0 deletions compiler/crates/relay-config/src/project_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,15 @@ use serde::Deserializer;
use serde::Serialize;
use serde::Serializer;

/// Represents the name of a project in the Relay configuration.
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, JsonSchema, Ord, PartialOrd)]
#[schemars(untagged)]
pub enum ProjectName {
/// No project name is specified.
Default,
/// A project name.
///
/// This should match one the keys in the `projects` map in the Relay compiler config.
Named(StringKey),
}

Expand Down

0 comments on commit bdbe7e0

Please sign in to comment.