mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-14 08:02:15 +03:00
Revert "Reapply "subscriptions: Unhide OpenDd Metadata and lift from unstability" " (#1256)
I am sorry @rakeshkky , we will merge this again once we've done a release, I promise. Reverts hasura/v3-engine#1254 V3_GIT_ORIGIN_REV_ID: 74236d25d4e84658717531a55d87c8d3371b553c
This commit is contained in:
parent
30d38fa599
commit
927268ae03
@ -19,6 +19,7 @@
|
||||
pub enum UnstableFeature {
|
||||
EnableOrderByExpressions,
|
||||
EnableNdcV02Support,
|
||||
EnableSubscriptions,
|
||||
EnableJsonApi,
|
||||
EnableAggregationPredicates,
|
||||
}
|
||||
@ -36,6 +37,9 @@ pub fn resolve_unstable_features(
|
||||
UnstableFeature::EnableNdcV02Support => {
|
||||
features.enable_ndc_v02_support = true;
|
||||
}
|
||||
UnstableFeature::EnableSubscriptions => {
|
||||
features.enable_subscriptions = true;
|
||||
}
|
||||
UnstableFeature::EnableJsonApi => {
|
||||
features.enable_jsonapi = true;
|
||||
}
|
||||
|
@ -456,6 +456,7 @@ pub fn test_execute_explain(
|
||||
unstable_features: metadata_resolve::configuration::UnstableFeatures {
|
||||
enable_order_by_expressions: false,
|
||||
enable_ndc_v02_support: true,
|
||||
enable_subscriptions: false,
|
||||
enable_jsonapi: false,
|
||||
..Default::default()
|
||||
},
|
||||
@ -517,6 +518,7 @@ pub(crate) fn test_metadata_resolve_configuration() -> metadata_resolve::configu
|
||||
unstable_features: metadata_resolve::configuration::UnstableFeatures {
|
||||
enable_order_by_expressions: false,
|
||||
enable_ndc_v02_support: true,
|
||||
enable_subscriptions: true,
|
||||
enable_jsonapi: false,
|
||||
..Default::default()
|
||||
},
|
||||
|
@ -59,7 +59,12 @@ pub(crate) async fn start_websocket_server() -> TestServer {
|
||||
let metadata_path = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join(METADATA_PATH);
|
||||
let raw_metadata = std::fs::read_to_string(metadata_path).unwrap();
|
||||
let metadata = open_dds::Metadata::from_json_str(&raw_metadata).unwrap();
|
||||
let metadata_resolve_configuration = metadata_resolve::configuration::Configuration::default();
|
||||
let metadata_resolve_configuration = metadata_resolve::configuration::Configuration {
|
||||
unstable_features: metadata_resolve::configuration::UnstableFeatures {
|
||||
enable_subscriptions: true,
|
||||
..Default::default()
|
||||
},
|
||||
};
|
||||
let (resolved_metadata, _warnings) =
|
||||
metadata_resolve::resolve(metadata, &metadata_resolve_configuration).unwrap();
|
||||
|
||||
|
@ -179,6 +179,7 @@ fn get_metadata_resolve_configuration() -> metadata_resolve::configuration::Conf
|
||||
let unstable_features = metadata_resolve::configuration::UnstableFeatures {
|
||||
enable_order_by_expressions: false,
|
||||
enable_ndc_v02_support: false,
|
||||
enable_subscriptions: true,
|
||||
enable_jsonapi: true,
|
||||
enable_aggregation_predicates: false,
|
||||
};
|
||||
|
@ -262,6 +262,7 @@ fn fallback_graphql_config() -> &'static graphql_config::GraphqlConfig {
|
||||
mutation: graphql_config::MutationGraphqlConfig {
|
||||
root_operation_type_name: GraphQlTypeName::from("Mutation"),
|
||||
},
|
||||
// TODO: Subscriptions are still unsupported. No need to consider them for now.
|
||||
subscription: None,
|
||||
apollo_federation: None,
|
||||
})
|
||||
|
@ -274,6 +274,7 @@ pub fn resolve(
|
||||
&order_by_expressions,
|
||||
&graphql_types,
|
||||
&graphql_config,
|
||||
configuration,
|
||||
)?;
|
||||
|
||||
all_issues.extend(issues);
|
||||
|
@ -11,6 +11,7 @@ use super::types::{
|
||||
SelectAggregateGraphQlDefinition, SelectManyGraphQlDefinition, SelectUniqueGraphQlDefinition,
|
||||
SubscriptionGraphQlDefinition, UniqueIdentifierField,
|
||||
};
|
||||
use crate::configuration::Configuration;
|
||||
use crate::helpers::types::{mk_name, store_new_graphql_type};
|
||||
use crate::stages::order_by_expressions::OrderByExpressions;
|
||||
use crate::stages::{data_connector_scalar_types, graphql_config, models, object_types};
|
||||
@ -35,6 +36,7 @@ pub(crate) fn resolve_model_graphql_api(
|
||||
aggregate_expression_name: &Option<Qualified<AggregateExpressionName>>,
|
||||
order_by_expressions: &OrderByExpressions,
|
||||
graphql_config: &graphql_config::GraphqlConfig,
|
||||
configuration: &Configuration,
|
||||
issues: &mut Vec<Warning>,
|
||||
) -> Result<ModelGraphQlApi, Error> {
|
||||
let model_name = &model.name;
|
||||
@ -92,7 +94,7 @@ pub(crate) fn resolve_model_graphql_api(
|
||||
let subscription = select_unique
|
||||
.subscription
|
||||
.as_ref()
|
||||
.map(resolve_subscription_graphql_api)
|
||||
.map(|s| resolve_subscription_graphql_api(s, configuration))
|
||||
.transpose()?;
|
||||
graphql_api
|
||||
.select_uniques
|
||||
@ -169,7 +171,7 @@ pub(crate) fn resolve_model_graphql_api(
|
||||
let subscription = gql_definition
|
||||
.subscription
|
||||
.as_ref()
|
||||
.map(resolve_subscription_graphql_api)
|
||||
.map(|s| resolve_subscription_graphql_api(s, configuration))
|
||||
.transpose()?;
|
||||
mk_name(gql_definition.query_root_field.as_str()).map(|f: ast::Name| {
|
||||
let select_many_description = if gql_definition.description.is_some() {
|
||||
@ -240,7 +242,7 @@ pub(crate) fn resolve_model_graphql_api(
|
||||
let subscription = graphql_aggregate
|
||||
.subscription
|
||||
.as_ref()
|
||||
.map(resolve_subscription_graphql_api)
|
||||
.map(|s| resolve_subscription_graphql_api(s, configuration))
|
||||
.transpose()?;
|
||||
|
||||
Some(SelectAggregateGraphQlDefinition {
|
||||
@ -334,8 +336,12 @@ fn is_model_used_in_any_aggregate_relationship(
|
||||
|
||||
fn resolve_subscription_graphql_api(
|
||||
subscription: &open_dds::models::SubscriptionGraphQlDefinition,
|
||||
configuration: &Configuration,
|
||||
) -> Result<SubscriptionGraphQlDefinition, Error> {
|
||||
// Subscriptions are currently unstable.
|
||||
if !configuration.unstable_features.enable_subscriptions {
|
||||
return Err(Error::UnstableFeatureSubscriptions);
|
||||
}
|
||||
let open_dds::models::SubscriptionGraphQlDefinition {
|
||||
root_field,
|
||||
description,
|
||||
|
@ -9,6 +9,7 @@ use std::collections::{BTreeMap, BTreeSet};
|
||||
use lang_graphql::ast::common as ast;
|
||||
use open_dds::{data_connector::DataConnectorName, models::ModelName, types::CustomTypeName};
|
||||
|
||||
use crate::configuration::Configuration;
|
||||
use crate::stages::{
|
||||
boolean_expressions, data_connector_scalar_types, graphql_config, models,
|
||||
object_boolean_expressions, object_relationships,
|
||||
@ -44,6 +45,7 @@ pub fn resolve(
|
||||
order_by_expressions: &order_by_expressions::OrderByExpressions,
|
||||
existing_graphql_types: &BTreeSet<ast::TypeName>,
|
||||
graphql_config: &graphql_config::GraphqlConfig,
|
||||
configuration: &Configuration,
|
||||
) -> Result<ModelsWithGraphqlOutput, Error> {
|
||||
let mut output = ModelsWithGraphqlOutput {
|
||||
models_with_graphql: IndexMap::new(),
|
||||
@ -97,6 +99,7 @@ pub fn resolve(
|
||||
&model.aggregate_expression,
|
||||
order_by_expressions,
|
||||
graphql_config,
|
||||
configuration,
|
||||
&mut output.issues,
|
||||
)?,
|
||||
None => types::ModelGraphQlApi::default(),
|
||||
|
@ -16,6 +16,7 @@ pub struct Configuration {
|
||||
pub struct UnstableFeatures {
|
||||
pub enable_order_by_expressions: bool,
|
||||
pub enable_ndc_v02_support: bool,
|
||||
pub enable_subscriptions: bool,
|
||||
pub enable_jsonapi: bool,
|
||||
pub enable_aggregation_predicates: bool,
|
||||
}
|
||||
|
@ -345,6 +345,8 @@ pub enum Error {
|
||||
CompatibilityError {
|
||||
warnings_as_errors: SeparatedBy<crate::Warning>,
|
||||
},
|
||||
#[error("Subscriptions are currently unstable. Please add 'subscriptions' to unstable features to enable them.")]
|
||||
UnstableFeatureSubscriptions,
|
||||
}
|
||||
|
||||
pub trait ShouldBeAnError {
|
||||
|
@ -83,6 +83,7 @@ fn read_test_configuration(
|
||||
let unstable_features = configuration::UnstableFeatures {
|
||||
enable_order_by_expressions: false,
|
||||
enable_ndc_v02_support: false,
|
||||
enable_subscriptions: false,
|
||||
enable_jsonapi: false,
|
||||
enable_aggregation_predicates: true,
|
||||
};
|
||||
|
@ -1948,16 +1948,6 @@
|
||||
"mutation": {
|
||||
"$ref": "#/definitions/MutationGraphqlConfig"
|
||||
},
|
||||
"subscription": {
|
||||
"anyOf": [
|
||||
{
|
||||
"$ref": "#/definitions/SubscriptionGraphqlConfig"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"apolloFederation": {
|
||||
"anyOf": [
|
||||
{
|
||||
@ -2332,17 +2322,6 @@
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"subscription": {
|
||||
"description": "Enable subscription on this aggregate root field.",
|
||||
"anyOf": [
|
||||
{
|
||||
"$ref": "#/definitions/SubscriptionGraphQlDefinition"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
@ -5266,17 +5245,6 @@
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"subscription": {
|
||||
"description": "Enable subscription on this select many root field.",
|
||||
"anyOf": [
|
||||
{
|
||||
"$ref": "#/definitions/SubscriptionGraphQlDefinition"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
@ -5305,11 +5273,6 @@
|
||||
"items": {
|
||||
"$ref": "#/definitions/ArgumentPreset"
|
||||
}
|
||||
},
|
||||
"allowSubscriptions": {
|
||||
"description": "Whether the role is allowed to subscribe to the root fields of this model.",
|
||||
"default": false,
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
@ -5356,82 +5319,6 @@
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"subscription": {
|
||||
"description": "Enable subscription on this select unique root field.",
|
||||
"anyOf": [
|
||||
{
|
||||
"$ref": "#/definitions/SubscriptionGraphQlDefinition"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
"SubscriptionGraphQlDefinition": {
|
||||
"$id": "https://hasura.io/jsonschemas/metadata/SubscriptionGraphQlDefinition",
|
||||
"title": "SubscriptionGraphQlDefinition",
|
||||
"description": "The definition of the GraphQL API for enabling subscription on query root fields.",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"rootField"
|
||||
],
|
||||
"properties": {
|
||||
"rootField": {
|
||||
"description": "The name of the subscription root field.",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/GraphQlFieldName"
|
||||
}
|
||||
]
|
||||
},
|
||||
"description": {
|
||||
"description": "The description of the subscription graphql definition. Gets added to the description of the subscription root field in the graphql schema.",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"deprecated": {
|
||||
"description": "Whether this subscription root field is deprecated. If set, the deprecation status is added to the subscription root field's graphql schema.",
|
||||
"anyOf": [
|
||||
{
|
||||
"$ref": "#/definitions/Deprecated"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"pollingIntervalMs": {
|
||||
"description": "Polling interval in milliseconds for the subscription.",
|
||||
"default": 1000,
|
||||
"type": "integer",
|
||||
"format": "uint64",
|
||||
"minimum": 0.0
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
"SubscriptionGraphqlConfig": {
|
||||
"$id": "https://hasura.io/jsonschemas/metadata/SubscriptionGraphqlConfig",
|
||||
"title": "SubscriptionGraphqlConfig",
|
||||
"description": "Configuration for the GraphQL schema of Hasura features for subscriptions.",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"rootOperationTypeName"
|
||||
],
|
||||
"properties": {
|
||||
"rootOperationTypeName": {
|
||||
"description": "The name of the root operation type name for subscriptions. Usually `subscription`.",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/GraphQlTypeName"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
|
@ -30,6 +30,8 @@ pub enum GraphqlConfig {
|
||||
pub struct GraphqlConfigV1 {
|
||||
pub query: QueryGraphqlConfig,
|
||||
pub mutation: MutationGraphqlConfig,
|
||||
#[opendd(hidden = true)]
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub subscription: Option<SubscriptionGraphqlConfig>,
|
||||
pub apollo_federation: Option<GraphqlApolloFederationConfig>,
|
||||
}
|
||||
|
@ -385,6 +385,7 @@ pub struct SelectUniqueGraphQlDefinition {
|
||||
/// If set, the deprecation status is added to the select unique root field's graphql schema.
|
||||
pub deprecated: Option<Deprecated>,
|
||||
/// Enable subscription on this select unique root field.
|
||||
#[opendd(hidden = true)]
|
||||
pub subscription: Option<SubscriptionGraphQlDefinition>,
|
||||
}
|
||||
|
||||
@ -402,10 +403,11 @@ pub struct SelectManyGraphQlDefinition {
|
||||
/// If set, the deprecation status is added to the select many root field's graphql schema.
|
||||
pub deprecated: Option<Deprecated>,
|
||||
/// Enable subscription on this select many root field.
|
||||
#[opendd(hidden = true)]
|
||||
pub subscription: Option<SubscriptionGraphQlDefinition>,
|
||||
}
|
||||
|
||||
/// The definition of the GraphQL API for enabling subscription on query root fields.
|
||||
/// The definition of the GraphQL API for enabling subscription on select_many or select_uniques root fields.
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, opendds_derive::OpenDd)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[opendd(json_schema(title = "SubscriptionGraphQlDefinition"))]
|
||||
@ -500,5 +502,6 @@ pub struct ModelAggregateGraphQlDefinition {
|
||||
/// If set, the deprecation status is added to the aggregate root field's graphql schema.
|
||||
pub deprecated: Option<Deprecated>,
|
||||
/// Enable subscription on this aggregate root field.
|
||||
#[opendd(hidden = true)]
|
||||
pub subscription: Option<SubscriptionGraphQlDefinition>,
|
||||
}
|
||||
|
@ -342,8 +342,12 @@ pub struct SelectPermission {
|
||||
/// Preset values for arguments for this role
|
||||
#[opendd(default, json_schema(default_exp = "serde_json::json!([])"))]
|
||||
pub argument_presets: Vec<ArgumentPreset>,
|
||||
/// Whether the role is allowed to subscribe to the root fields of this model.
|
||||
#[opendd(default, json_schema(default_exp = "serde_json::json!(false)"))]
|
||||
/// Whether to allow subscriptions for this role.
|
||||
#[opendd(
|
||||
hidden = true,
|
||||
default,
|
||||
json_schema(default_exp = "serde_json::json!(false)")
|
||||
)]
|
||||
pub allow_subscriptions: bool,
|
||||
}
|
||||
|
||||
|
@ -85,6 +85,7 @@ watch: start-docker-test-deps start-docker-run-deps
|
||||
--otlp-endpoint http://localhost:4317 \
|
||||
--authn-config-path static/auth/auth_config.json \
|
||||
--metadata-path static/sample-schema.json \
|
||||
--unstable-feature enable-subscriptions \
|
||||
--unstable-feature enable-json-api \
|
||||
--expose-internal-errors'
|
||||
|
||||
@ -174,5 +175,6 @@ run METADATA_PATH="static/sample-schema.json": start-docker-test-deps start-dock
|
||||
--otlp-endpoint http://localhost:4317 \
|
||||
--authn-config-path static/auth/auth_config.json \
|
||||
--metadata-path {{ METADATA_PATH }} \
|
||||
--unstable-feature enable-subscriptions \
|
||||
--unstable-feature enable-json-api \
|
||||
--expose-internal-errors
|
||||
|
Loading…
Reference in New Issue
Block a user