Skip to content

Commit

Permalink
Mark semantic nullability config option as experimental
Browse files Browse the repository at this point in the history
  • Loading branch information
captbaritone committed Jan 27, 2024
1 parent 2ce7b7d commit c84e0b4
Show file tree
Hide file tree
Showing 48 changed files with 55 additions and 51 deletions.
8 changes: 6 additions & 2 deletions compiler/crates/relay-config/src/typegen_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,17 @@ pub struct TypegenConfig {
#[serde(default)]
pub typescript_exclude_undefined_from_nullable_union: bool,

/// If your environment is configured to handles errors out of band, either via
/// 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.
///
/// Currently semantically non-null fields must be specified in your schema
/// using the `@semanticNonNull` directive as specified in:
/// https://github.com/apollographql/specs/pull/42
#[serde(default)]
pub emit_semantic_nullability_types: bool,
pub experimental_emit_semantic_nullability_types: bool,
}

#[derive(Default, Debug, Serialize, Deserialize, Clone, Copy)]
Expand Down
2 changes: 1 addition & 1 deletion compiler/crates/relay-typegen/src/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2434,7 +2434,7 @@ fn field_type(field: &Field, typegen_options: &'_ TypegenContext<'_>) -> TypeRef
if typegen_options
.project_config
.typegen_config
.emit_semantic_nullability_types
.experimental_emit_semantic_nullability_types
{
field.semantic_type()
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
==================================== INPUT ====================================
# relay:emit_semantic_nullability_types
# relay:experimental_emit_semantic_nullability_types
query MyQuery @raw_response_type {
opera {
composer {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# relay:emit_semantic_nullability_types
# relay:experimental_emit_semantic_nullability_types
query MyQuery @raw_response_type {
opera {
composer {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
==================================== INPUT ====================================
# relay:emit_semantic_nullability_types
# relay:experimental_emit_semantic_nullability_types
fragment MyFragment on Screen {
pixels
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# relay:emit_semantic_nullability_types
# relay:experimental_emit_semantic_nullability_types
fragment MyFragment on Screen {
pixels
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
==================================== INPUT ====================================
# relay:emit_semantic_nullability_types
# relay:experimental_emit_semantic_nullability_types
fragment MyFragment on ClientUser {
best_friend @waterfall {
name
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# relay:emit_semantic_nullability_types
# relay:experimental_emit_semantic_nullability_types
fragment MyFragment on ClientUser {
best_friend @waterfall {
name
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
==================================== INPUT ====================================
# relay:emit_semantic_nullability_types
# relay:experimental_emit_semantic_nullability_types
fragment MyFragment on ClientUser {
blob {
data
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# relay:emit_semantic_nullability_types
# relay:experimental_emit_semantic_nullability_types
fragment MyFragment on ClientUser {
blob {
data
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
==================================== INPUT ====================================
# relay:emit_semantic_nullability_types
# relay:experimental_emit_semantic_nullability_types
fragment MyFragment on ClientUser {
best_friend {
name
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# relay:emit_semantic_nullability_types
# relay:experimental_emit_semantic_nullability_types
fragment MyFragment on ClientUser {
best_friend {
name
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
==================================== INPUT ====================================
# relay:emit_semantic_nullability_types
# relay:experimental_emit_semantic_nullability_types
fragment MyFragment on ClientUser {
favorite_numbers
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# relay:emit_semantic_nullability_types
# relay:experimental_emit_semantic_nullability_types
fragment MyFragment on ClientUser {
favorite_numbers
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
==================================== INPUT ====================================
# relay:emit_semantic_nullability_types
# relay:experimental_emit_semantic_nullability_types
fragment MyFragment on ClientUser {
favorite_numbers
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# relay:emit_semantic_nullability_types
# relay:experimental_emit_semantic_nullability_types
fragment MyFragment on ClientUser {
favorite_numbers
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
==================================== INPUT ====================================
# relay:emit_semantic_nullability_types
# relay:experimental_emit_semantic_nullability_types
fragment MyFragment on ClientUser {
name
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# relay:emit_semantic_nullability_types
# relay:experimental_emit_semantic_nullability_types
fragment MyFragment on ClientUser {
name
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
==================================== INPUT ====================================
# Note: No comment here enabling `emit_semantic_nullability_types`
# Note: No comment here enabling `experimental_emit_semantic_nullability_types`
fragment MyFragment on ClientUser {
name
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Note: No comment here enabling `emit_semantic_nullability_types`
# Note: No comment here enabling `experimental_emit_semantic_nullability_types`
fragment MyFragment on ClientUser {
name
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
==================================== INPUT ====================================
# relay:emit_semantic_nullability_types
# relay:experimental_emit_semantic_nullability_types
fragment MyFragment on ClientUser {
name @required(action: LOG)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# relay:emit_semantic_nullability_types
# relay:experimental_emit_semantic_nullability_types
fragment MyFragment on ClientUser {
name @required(action: LOG)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
==================================== INPUT ====================================
# relay:emit_semantic_nullability_types
# relay:experimental_emit_semantic_nullability_types
fragment MyFragment on ClientUser {
name
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# relay:emit_semantic_nullability_types
# relay:experimental_emit_semantic_nullability_types
fragment MyFragment on ClientUser {
name
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/crates/relay-typegen/tests/generate_flow/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ pub async fn transform_fixture(fixture: &Fixture<'_>) -> Result<String, String>
typegen_config: TypegenConfig {
language: TypegenLanguage::Flow,
custom_scalar_types,
emit_semantic_nullability_types: fixture
experimental_emit_semantic_nullability_types: fixture
.content
.contains("# relay:emit_semantic_nullability_types"),
.contains("# relay:experimental_emit_semantic_nullability_types"),
..Default::default()
},
..Default::default()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
==================================== INPUT ====================================
# relay:emit_semantic_nullability_types
# relay:experimental_emit_semantic_nullability_types
query MyQuery @raw_response_type {
opera {
composer {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# relay:emit_semantic_nullability_types
# relay:experimental_emit_semantic_nullability_types
query MyQuery @raw_response_type {
opera {
composer {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
==================================== INPUT ====================================
# relay:emit_semantic_nullability_types
# relay:experimental_emit_semantic_nullability_types
fragment MyFragment on Screen {
pixels
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# relay:emit_semantic_nullability_types
# relay:experimental_emit_semantic_nullability_types
fragment MyFragment on Screen {
pixels
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
==================================== INPUT ====================================
# relay:emit_semantic_nullability_types
# relay:experimental_emit_semantic_nullability_types
fragment MyFragment on ClientUser {
best_friend @waterfall {
name
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# relay:emit_semantic_nullability_types
# relay:experimental_emit_semantic_nullability_types
fragment MyFragment on ClientUser {
best_friend @waterfall {
name
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
==================================== INPUT ====================================
# relay:emit_semantic_nullability_types
# relay:experimental_emit_semantic_nullability_types
fragment MyFragment on ClientUser {
blob {
data
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# relay:emit_semantic_nullability_types
# relay:experimental_emit_semantic_nullability_types
fragment MyFragment on ClientUser {
blob {
data
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
==================================== INPUT ====================================
# relay:emit_semantic_nullability_types
# relay:experimental_emit_semantic_nullability_types
fragment MyFragment on ClientUser {
best_friend {
name
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# relay:emit_semantic_nullability_types
# relay:experimental_emit_semantic_nullability_types
fragment MyFragment on ClientUser {
best_friend {
name
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
==================================== INPUT ====================================
# relay:emit_semantic_nullability_types
# relay:experimental_emit_semantic_nullability_types
fragment MyFragment on ClientUser {
favorite_numbers
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# relay:emit_semantic_nullability_types
# relay:experimental_emit_semantic_nullability_types
fragment MyFragment on ClientUser {
favorite_numbers
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
==================================== INPUT ====================================
# relay:emit_semantic_nullability_types
# relay:experimental_emit_semantic_nullability_types
fragment MyFragment on ClientUser {
favorite_numbers
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# relay:emit_semantic_nullability_types
# relay:experimental_emit_semantic_nullability_types
fragment MyFragment on ClientUser {
favorite_numbers
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
==================================== INPUT ====================================
# relay:emit_semantic_nullability_types
# relay:experimental_emit_semantic_nullability_types
fragment MyFragment on ClientUser {
name
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# relay:emit_semantic_nullability_types
# relay:experimental_emit_semantic_nullability_types
fragment MyFragment on ClientUser {
name
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
==================================== INPUT ====================================
# Note: No comment here enabling `emit_semantic_nullability_types`
# Note: No comment here enabling `experimental_emit_semantic_nullability_types`
fragment MyFragment on ClientUser {
name
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Note: No comment here enabling `emit_semantic_nullability_types`
# Note: No comment here enabling `experimental_emit_semantic_nullability_types`
fragment MyFragment on ClientUser {
name
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
==================================== INPUT ====================================
# relay:emit_semantic_nullability_types
# relay:experimental_emit_semantic_nullability_types
fragment MyFragment on ClientUser {
name @required(action: LOG)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# relay:emit_semantic_nullability_types
# relay:experimental_emit_semantic_nullability_types
fragment MyFragment on ClientUser {
name @required(action: LOG)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
==================================== INPUT ====================================
# relay:emit_semantic_nullability_types
# relay:experimental_emit_semantic_nullability_types
fragment MyFragment on ClientUser {
name
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# relay:emit_semantic_nullability_types
# relay:experimental_emit_semantic_nullability_types
fragment MyFragment on ClientUser {
name
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ pub async fn transform_fixture(fixture: &Fixture<'_>) -> Result<String, String>
use_import_type_syntax: fixture
.content
.contains("# typegen_config.use_import_type_syntax = true"),
emit_semantic_nullability_types: fixture
experimental_emit_semantic_nullability_types: fixture
.content
.contains("# relay:emit_semantic_nullability_types"),
.contains("# relay:experimental_emit_semantic_nullability_types"),
..Default::default()
},
feature_flags: Arc::new(FeatureFlags {
Expand Down

0 comments on commit c84e0b4

Please sign in to comment.