From 42dddff655e54a89608213f1a22512c06f35fedf Mon Sep 17 00:00:00 2001 From: Jesse Hallett Date: Thu, 4 Apr 2024 18:02:54 -0400 Subject: [PATCH] rename "native query" to "native procedure"; remove read-only native procedures (#29) Going forward "native query" will refer to a thing defined by an aggregation pipeline (not an arbitrary MongoDB command) that will appear in the data graph as a function. (Maybe we will add support for native queries that appear as collections at some point, but we've been asked to specifically implement the function case.) What was previously called a "native query" is now called a "native procedure". It maps exclusively to a procedure in the data graph. The read-write/read-only switch is gone - procedures will only be used for mutations. https://hasurahq.atlassian.net/browse/MDB-102 --- crates/configuration/src/configuration.rs | 27 ++++---- crates/configuration/src/directory.rs | 10 +-- crates/configuration/src/lib.rs | 2 +- ...{native_queries.rs => native_procedure.rs} | 28 +++------ .../src/interface_types/mongo_config.rs | 4 +- .../src/procedure/interpolated_command.rs | 62 +++++++++---------- .../mongodb-agent-common/src/procedure/mod.rs | 14 ++--- .../src/query/execute_native_query_request.rs | 31 ---------- crates/mongodb-agent-common/src/query/mod.rs | 20 +----- crates/mongodb-agent-common/src/state.rs | 2 +- crates/mongodb-connector/src/mutation.rs | 8 +-- crates/mongodb-connector/src/schema.rs | 60 ++++-------------- .../insert_artist.json | 3 +- .../chinook/native_queries/hello.json | 26 -------- .../ddn/subgraphs/chinook/commands/Hello.hml | 53 ---------------- .../chinook/commands/InsertArtist.hml | 2 +- .../chinook/dataconnectors/mongodb.hml | 15 +---- 17 files changed, 89 insertions(+), 278 deletions(-) rename crates/configuration/src/{native_queries.rs => native_procedure.rs} (74%) delete mode 100644 crates/mongodb-agent-common/src/query/execute_native_query_request.rs rename fixtures/connector/chinook/{native_queries => native_procedures}/insert_artist.json (87%) delete mode 100644 fixtures/connector/chinook/native_queries/hello.json delete mode 100644 fixtures/ddn/subgraphs/chinook/commands/Hello.hml diff --git a/crates/configuration/src/configuration.rs b/crates/configuration/src/configuration.rs index f62e6c39..1bcd622d 100644 --- a/crates/configuration/src/configuration.rs +++ b/crates/configuration/src/configuration.rs @@ -5,7 +5,7 @@ use itertools::Itertools; use schemars::JsonSchema; use serde::Deserialize; -use crate::{native_queries::NativeQuery, read_directory, schema::ObjectType, Schema}; +use crate::{native_procedure::NativeProcedure, read_directory, schema::ObjectType, Schema}; #[derive(Clone, Debug, Default, Deserialize, JsonSchema)] #[serde(rename_all = "camelCase")] @@ -13,20 +13,20 @@ pub struct Configuration { /// Descriptions of collections and types used in the database pub schema: Schema, - /// Native queries allow arbitrary MongoDB aggregation pipelines where types of results are + /// Native procedures allow arbitrary MongoDB commands where types of results are /// specified via user configuration. #[serde(default, skip_serializing_if = "BTreeMap::is_empty")] - pub native_queries: BTreeMap, + pub native_procedures: BTreeMap, } impl Configuration { pub fn validate( schema: Schema, - native_queries: BTreeMap, + native_procedures: BTreeMap, ) -> anyhow::Result { let config = Configuration { schema, - native_queries, + native_procedures, }; { @@ -55,14 +55,14 @@ impl Configuration { read_directory(configuration_dir).await } - /// Returns object types collected from schema and native queries + /// Returns object types collected from schema and native procedures pub fn object_types(&self) -> impl Iterator { let object_types_from_schema = self.schema.object_types.iter(); - let object_types_from_native_queries = self - .native_queries + let object_types_from_native_procedures = self + .native_procedures .values() - .flat_map(|native_query| &native_query.object_types); - object_types_from_schema.chain(object_types_from_native_queries) + .flat_map(|native_procedure| &native_procedure.object_types); + object_types_from_schema.chain(object_types_from_native_procedures) } } @@ -87,9 +87,9 @@ mod tests { .into_iter() .collect(), }; - let native_queries = [( + let native_procedures = [( "hello".to_owned(), - NativeQuery { + NativeProcedure { object_types: [( "Album".to_owned(), ObjectType { @@ -104,12 +104,11 @@ mod tests { arguments: Default::default(), selection_criteria: Default::default(), description: Default::default(), - mode: Default::default(), }, )] .into_iter() .collect(); - let result = Configuration::validate(schema, native_queries); + let result = Configuration::validate(schema, native_procedures); let error_msg = result.unwrap_err().to_string(); assert!(error_msg.contains("multiple definitions")); assert!(error_msg.contains("Album")); diff --git a/crates/configuration/src/directory.rs b/crates/configuration/src/directory.rs index fcac3d6c..035a5488 100644 --- a/crates/configuration/src/directory.rs +++ b/crates/configuration/src/directory.rs @@ -12,7 +12,7 @@ use tokio_stream::wrappers::ReadDirStream; use crate::{with_name::WithName, Configuration, Schema}; pub const SCHEMA_DIRNAME: &str = "schema"; -pub const NATIVE_QUERIES_DIRNAME: &str = "native_queries"; +pub const NATIVE_PROCEDURES_DIRNAME: &str = "native_procedures"; pub const CONFIGURATION_EXTENSIONS: [(&str, FileFormat); 3] = [("json", JSON), ("yaml", YAML), ("yml", YAML)]; @@ -38,16 +38,16 @@ pub async fn read_directory( .unwrap_or_default(); let schema = schemas.into_values().fold(Schema::default(), Schema::merge); - let native_queries = read_subdir_configs(&dir.join(NATIVE_QUERIES_DIRNAME)) + let native_procedures = read_subdir_configs(&dir.join(NATIVE_PROCEDURES_DIRNAME)) .await? .unwrap_or_default(); - Configuration::validate(schema, native_queries) + Configuration::validate(schema, native_procedures) } /// Parse all files in a directory with one of the allowed configuration extensions according to -/// the given type argument. For example if `T` is `NativeQuery` this function assumes that all -/// json and yaml files in the given directory should be parsed as native query configurations. +/// the given type argument. For example if `T` is `NativeProcedure` this function assumes that all +/// json and yaml files in the given directory should be parsed as native procedure configurations. /// /// Assumes that every configuration file has a `name` field. async fn read_subdir_configs(subdir: &Path) -> anyhow::Result>> diff --git a/crates/configuration/src/lib.rs b/crates/configuration/src/lib.rs index 20c2822a..bbd87477 100644 --- a/crates/configuration/src/lib.rs +++ b/crates/configuration/src/lib.rs @@ -1,6 +1,6 @@ mod configuration; mod directory; -pub mod native_queries; +pub mod native_procedure; pub mod schema; mod with_name; diff --git a/crates/configuration/src/native_queries.rs b/crates/configuration/src/native_procedure.rs similarity index 74% rename from crates/configuration/src/native_queries.rs rename to crates/configuration/src/native_procedure.rs index 705a3c86..3aff80ba 100644 --- a/crates/configuration/src/native_queries.rs +++ b/crates/configuration/src/native_procedure.rs @@ -8,21 +8,23 @@ use crate::schema::{ObjectField, ObjectType, Type}; /// An arbitrary database command using MongoDB's runCommand API. /// See https://www.mongodb.com/docs/manual/reference/method/db.runCommand/ +/// +/// Native Procedures appear as "procedures" in your data graph. #[derive(Clone, Debug, Deserialize, JsonSchema)] #[serde(rename_all = "camelCase")] -pub struct NativeQuery { +pub struct NativeProcedure { /// You may define object types here to reference in `result_type`. Any types defined here will /// be merged with the definitions in `schema.json`. This allows you to maintain hand-written - /// types for native queries without having to edit a generated `schema.json` file. + /// types for native procedures without having to edit a generated `schema.json` file. #[serde(default, skip_serializing_if = "BTreeMap::is_empty")] pub object_types: BTreeMap, - /// Type of data returned by the query. You may reference object types defined in the + /// Type of data returned by the procedure. You may reference object types defined in the /// `object_types` list in this definition, or you may reference object types from /// `schema.json`. pub result_type: Type, - /// Arguments to be supplied for each query invocation. These will be substituted into the + /// Arguments to be supplied for each procedure invocation. These will be substituted into the /// given `command`. /// /// Argument values are standard JSON mapped from GraphQL input types, not Extended JSON. @@ -38,7 +40,7 @@ pub struct NativeQuery { /// See https://www.mongodb.com/docs/manual/reference/mongodb-extended-json/ /// /// Keys and values in the command may contain placeholders of the form `{{variableName}}` - /// which will be substituted when the native query is executed according to the given + /// which will be substituted when the native procedure is executed according to the given /// arguments. /// /// Placeholders must be inside quotes so that the command can be stored in JSON format. If the @@ -75,22 +77,6 @@ pub struct NativeQuery { #[serde(default, skip_serializing_if = "Option::is_none")] pub description: Option, - - /// Set to `readWrite` if this native query might modify data in the database. When refreshing - /// a dataconnector native queries will appear in the corresponding `DataConnectorLink` - /// definition as `functions` if they are read-only, or as `procedures` if they are read-write. - /// Functions are intended to map to GraphQL Query fields, while procedures map to Mutation - /// fields. - #[serde(default)] - pub mode: Mode, -} - -#[derive(Clone, Copy, Default, Debug, PartialEq, Eq, Deserialize, JsonSchema)] -#[serde(rename_all = "camelCase")] -pub enum Mode { - #[default] - ReadOnly, - ReadWrite, } type Object = serde_json::Map; diff --git a/crates/mongodb-agent-common/src/interface_types/mongo_config.rs b/crates/mongodb-agent-common/src/interface_types/mongo_config.rs index 0801dd0c..e4a43c11 100644 --- a/crates/mongodb-agent-common/src/interface_types/mongo_config.rs +++ b/crates/mongodb-agent-common/src/interface_types/mongo_config.rs @@ -1,6 +1,6 @@ use std::collections::BTreeMap; -use configuration::{native_queries::NativeQuery, schema::ObjectType}; +use configuration::{native_procedure::NativeProcedure, schema::ObjectType}; use mongodb::Client; #[derive(Clone, Debug)] @@ -10,6 +10,6 @@ pub struct MongoConfig { /// Name of the database to connect to pub database: String, - pub native_queries: BTreeMap, + pub native_procedures: BTreeMap, pub object_types: BTreeMap, } diff --git a/crates/mongodb-agent-common/src/procedure/interpolated_command.rs b/crates/mongodb-agent-common/src/procedure/interpolated_command.rs index 76ff4304..a2a6354a 100644 --- a/crates/mongodb-agent-common/src/procedure/interpolated_command.rs +++ b/crates/mongodb-agent-common/src/procedure/interpolated_command.rs @@ -7,7 +7,7 @@ use super::ProcedureError; type Result = std::result::Result; -/// Parse native query commands, and interpolate arguments. +/// Parse native procedure commands, and interpolate arguments. pub fn interpolated_command( command: &bson::Document, arguments: &BTreeMap, @@ -69,19 +69,19 @@ fn interpolate_document( /// /// if the type of the variable `recordId` is `int`. fn interpolate_string(string: &str, arguments: &BTreeMap) -> Result { - let parts = parse_native_query(string); + let parts = parse_native_procedure(string); if parts.len() == 1 { let mut parts = parts; match parts.remove(0) { - NativeQueryPart::Text(string) => Ok(Bson::String(string)), - NativeQueryPart::Parameter(param) => resolve_argument(¶m, arguments), + NativeProcedurePart::Text(string) => Ok(Bson::String(string)), + NativeProcedurePart::Parameter(param) => resolve_argument(¶m, arguments), } } else { let interpolated_parts: Vec = parts .into_iter() .map(|part| match part { - NativeQueryPart::Text(string) => Ok(string), - NativeQueryPart::Parameter(param) => { + NativeProcedurePart::Text(string) => Ok(string), + NativeProcedurePart::Parameter(param) => { let argument_value = resolve_argument(¶m, arguments)?; match argument_value { Bson::String(string) => Ok(string), @@ -101,30 +101,30 @@ fn resolve_argument(argument_name: &str, arguments: &BTreeMap) -> Ok(argument.clone()) } -/// A part of a Native Query text, either raw text or a parameter. +/// A part of a Native Procedure command text, either raw text or a parameter. #[derive(Debug, Clone, PartialEq, Eq)] -enum NativeQueryPart { +enum NativeProcedurePart { /// A raw text part Text(String), /// A parameter Parameter(String), } -/// Parse a string or key in a native query into parts where variables have the syntax +/// Parse a string or key in a native procedure into parts where variables have the syntax /// `{{}}`. -fn parse_native_query(string: &str) -> Vec { - let vec: Vec> = string +fn parse_native_procedure(string: &str) -> Vec { + let vec: Vec> = string .split("{{") .filter(|part| !part.is_empty()) .map(|part| match part.split_once("}}") { - None => vec![NativeQueryPart::Text(part.to_string())], + None => vec![NativeProcedurePart::Text(part.to_string())], Some((var, text)) => { if text.is_empty() { - vec![NativeQueryPart::Parameter(var.trim().to_owned())] + vec![NativeProcedurePart::Parameter(var.trim().to_owned())] } else { vec![ - NativeQueryPart::Parameter(var.trim().to_owned()), - NativeQueryPart::Text(text.to_string()), + NativeProcedurePart::Parameter(var.trim().to_owned()), + NativeProcedurePart::Text(text.to_string()), ] } } @@ -135,7 +135,7 @@ fn parse_native_query(string: &str) -> Vec { #[cfg(test)] mod tests { - use configuration::native_queries::NativeQuery; + use configuration::native_procedure::NativeProcedure; use pretty_assertions::assert_eq; use serde_json::json; @@ -148,7 +148,7 @@ mod tests { #[test] fn interpolates_non_string_type() -> anyhow::Result<()> { - let native_query_input = json!({ + let native_procedure_input = json!({ "resultType": { "object": "InsertArtist" }, "arguments": { "id": { "type": { "scalar": "int" } }, @@ -169,13 +169,13 @@ mod tests { .into_iter() .collect(); - let native_query: NativeQuery = serde_json::from_value(native_query_input)?; + let native_procedure: NativeProcedure = serde_json::from_value(native_procedure_input)?; let arguments = resolve_arguments( - &native_query.object_types, - &native_query.arguments, + &native_procedure.object_types, + &native_procedure.arguments, input_arguments, )?; - let command = interpolated_command(&native_query.command, &arguments)?; + let command = interpolated_command(&native_procedure.command, &arguments)?; assert_eq!( command, @@ -192,7 +192,7 @@ mod tests { #[test] fn interpolates_array_argument() -> anyhow::Result<()> { - let native_query_input = json!({ + let native_procedure_input = json!({ "name": "insertArtist", "resultType": { "object": "InsertArtist" }, "objectTypes": { @@ -221,13 +221,13 @@ mod tests { .into_iter() .collect(); - let native_query: NativeQuery = serde_json::from_value(native_query_input)?; + let native_procedure: NativeProcedure = serde_json::from_value(native_procedure_input)?; let arguments = resolve_arguments( - &native_query.object_types, - &native_query.arguments, + &native_procedure.object_types, + &native_procedure.arguments, input_arguments, )?; - let command = interpolated_command(&native_query.command, &arguments)?; + let command = interpolated_command(&native_procedure.command, &arguments)?; assert_eq!( command, @@ -250,7 +250,7 @@ mod tests { #[test] fn interpolates_arguments_within_string() -> anyhow::Result<()> { - let native_query_input = json!({ + let native_procedure_input = json!({ "name": "insert", "resultType": { "object": "Insert" }, "arguments": { @@ -269,13 +269,13 @@ mod tests { .into_iter() .collect(); - let native_query: NativeQuery = serde_json::from_value(native_query_input)?; + let native_procedure: NativeProcedure = serde_json::from_value(native_procedure_input)?; let arguments = resolve_arguments( - &native_query.object_types, - &native_query.arguments, + &native_procedure.object_types, + &native_procedure.arguments, input_arguments, )?; - let command = interpolated_command(&native_query.command, &arguments)?; + let command = interpolated_command(&native_procedure.command, &arguments)?; assert_eq!( command, diff --git a/crates/mongodb-agent-common/src/procedure/mod.rs b/crates/mongodb-agent-common/src/procedure/mod.rs index 8c994418..9e6ff281 100644 --- a/crates/mongodb-agent-common/src/procedure/mod.rs +++ b/crates/mongodb-agent-common/src/procedure/mod.rs @@ -4,7 +4,7 @@ mod interpolated_command; use std::borrow::Cow; use std::collections::BTreeMap; -use configuration::native_queries::NativeQuery; +use configuration::native_procedure::NativeProcedure; use configuration::schema::{ObjectField, ObjectType, Type}; use mongodb::options::SelectionCriteria; use mongodb::{bson, Database}; @@ -25,16 +25,16 @@ pub struct Procedure<'a> { } impl<'a> Procedure<'a> { - pub fn from_native_query( - native_query: &'a NativeQuery, + pub fn from_native_procedure( + native_procedure: &'a NativeProcedure, arguments: BTreeMap, ) -> Self { Procedure { arguments, - command: Cow::Borrowed(&native_query.command), - parameters: Cow::Borrowed(&native_query.arguments), - result_type: native_query.result_type.clone(), - selection_criteria: native_query.selection_criteria.as_ref().map(Cow::Borrowed), + command: Cow::Borrowed(&native_procedure.command), + parameters: Cow::Borrowed(&native_procedure.arguments), + result_type: native_procedure.result_type.clone(), + selection_criteria: native_procedure.selection_criteria.as_ref().map(Cow::Borrowed), } } diff --git a/crates/mongodb-agent-common/src/query/execute_native_query_request.rs b/crates/mongodb-agent-common/src/query/execute_native_query_request.rs deleted file mode 100644 index ff603dd0..00000000 --- a/crates/mongodb-agent-common/src/query/execute_native_query_request.rs +++ /dev/null @@ -1,31 +0,0 @@ -use configuration::native_queries::NativeQuery; -use dc_api::JsonResponse; -use dc_api_types::{QueryResponse, ResponseFieldValue, RowSet}; -use mongodb::Database; - -use crate::interface_types::MongoAgentError; - -pub async fn handle_native_query_request( - native_query: NativeQuery, - database: Database, -) -> Result, MongoAgentError> { - let result = database - .run_command(native_query.command, native_query.selection_criteria) - .await?; - let result_json = - serde_json::to_value(result).map_err(|err| MongoAgentError::AdHoc(err.into()))?; - - // A function returs a single row with a single column called `__value` - // https://hasura.github.io/ndc-spec/specification/queries/functions.html - let response_row = [( - "__value".to_owned(), - ResponseFieldValue::Column(result_json), - )] - .into_iter() - .collect(); - - Ok(JsonResponse::Value(QueryResponse::Single(RowSet { - aggregates: None, - rows: Some(vec![response_row]), - }))) -} diff --git a/crates/mongodb-agent-common/src/query/mod.rs b/crates/mongodb-agent-common/src/query/mod.rs index 3f5c5df5..abbe37ed 100644 --- a/crates/mongodb-agent-common/src/query/mod.rs +++ b/crates/mongodb-agent-common/src/query/mod.rs @@ -1,7 +1,6 @@ pub mod arguments; mod column_ref; mod constants; -mod execute_native_query_request; mod execute_query_request; mod foreach; mod make_selector; @@ -20,10 +19,7 @@ pub use self::{ make_sort::make_sort, pipeline::{is_response_faceted, pipeline_for_non_foreach, pipeline_for_query_request}, }; -use crate::{ - interface_types::{MongoAgentError, MongoConfig}, - query::execute_native_query_request::handle_native_query_request, -}; +use crate::interface_types::{MongoAgentError, MongoConfig}; pub fn collection_name(query_request_target: &Target) -> String { query_request_target.name().join(".") @@ -36,20 +32,6 @@ pub async fn handle_query_request( tracing::debug!(?config, query_request = %serde_json::to_string(&query_request).unwrap(), "executing query"); let database = config.client.database(&config.database); - - let target = &query_request.target; - let target_name = { - let name = target.name(); - if name.len() == 1 { - Some(&name[0]) - } else { - None - } - }; - if let Some(native_query) = target_name.and_then(|name| config.native_queries.get(name)) { - return handle_native_query_request(native_query.clone(), database).await; - } - let collection = database.collection::(&collection_name(&query_request.target)); execute_query_request(&collection, query_request).await diff --git a/crates/mongodb-agent-common/src/state.rs b/crates/mongodb-agent-common/src/state.rs index 7bc2df3a..692fcbbb 100644 --- a/crates/mongodb-agent-common/src/state.rs +++ b/crates/mongodb-agent-common/src/state.rs @@ -30,7 +30,7 @@ pub async fn try_init_state_from_uri( Ok(MongoConfig { client, database: database_name, - native_queries: configuration.native_queries.clone(), + native_procedures: configuration.native_procedures.clone(), object_types: configuration .object_types() .map(|(name, object_type)| (name.clone(), object_type.clone())) diff --git a/crates/mongodb-connector/src/mutation.rs b/crates/mongodb-connector/src/mutation.rs index 76953ddc..5525dcb6 100644 --- a/crates/mongodb-connector/src/mutation.rs +++ b/crates/mongodb-connector/src/mutation.rs @@ -41,10 +41,10 @@ fn look_up_procedures( MutationOperation::Procedure { name, arguments, .. } => { - let native_query = config.native_queries.get(&name); - native_query - .ok_or(name) - .map(|native_query| Procedure::from_native_query(native_query, arguments)) + let native_procedure = config.native_procedures.get(&name); + native_procedure.ok_or(name).map(|native_procedure| { + Procedure::from_native_procedure(native_procedure, arguments) + }) } }) .partition_result(); diff --git a/crates/mongodb-connector/src/schema.rs b/crates/mongodb-connector/src/schema.rs index f3e9f715..c0950aa4 100644 --- a/crates/mongodb-connector/src/schema.rs +++ b/crates/mongodb-connector/src/schema.rs @@ -1,16 +1,14 @@ -use std::collections::BTreeMap; use lazy_static::lazy_static; +use std::collections::BTreeMap; -use configuration::{ - native_queries::{self, NativeQuery}, - schema, Configuration, -}; +use configuration::{native_procedure::NativeProcedure, schema, Configuration}; use ndc_sdk::{connector, models}; use crate::capabilities; lazy_static! { - pub static ref SCALAR_TYPES: BTreeMap = capabilities::scalar_types(); + pub static ref SCALAR_TYPES: BTreeMap = + capabilities::scalar_types(); } pub async fn get_schema( @@ -20,25 +18,17 @@ pub async fn get_schema( let collections = schema.collections.iter().map(map_collection).collect(); let object_types = config.object_types().map(map_object_type).collect(); - let functions = config - .native_queries - .iter() - .filter(|(_, q)| q.mode == native_queries::Mode::ReadOnly) - .map(native_query_to_function) - .collect(); - let procedures = config - .native_queries + .native_procedures .iter() - .filter(|(_, q)| q.mode == native_queries::Mode::ReadWrite) - .map(native_query_to_procedure) + .map(native_procedure_to_procedure) .collect(); Ok(models::SchemaResponse { collections, object_types, scalar_types: SCALAR_TYPES.clone(), - functions, + functions: Default::default(), procedures, }) } @@ -107,34 +97,10 @@ fn map_collection((name, collection): (&String, &schema::Collection)) -> models: } } -/// For read-only native queries -fn native_query_to_function((query_name, query): (&String, &NativeQuery)) -> models::FunctionInfo { - let arguments = query - .arguments - .iter() - .map(|(name, field)| { - ( - name.clone(), - models::ArgumentInfo { - argument_type: map_type(&field.r#type), - description: field.description.clone(), - }, - ) - }) - .collect(); - models::FunctionInfo { - name: query_name.clone(), - description: query.description.clone(), - arguments, - result_type: map_type(&query.result_type), - } -} - -/// For read-write native queries -fn native_query_to_procedure( - (query_name, query): (&String, &NativeQuery), +fn native_procedure_to_procedure( + (procedure_name, procedure): (&String, &NativeProcedure), ) -> models::ProcedureInfo { - let arguments = query + let arguments = procedure .arguments .iter() .map(|(name, field)| { @@ -148,9 +114,9 @@ fn native_query_to_procedure( }) .collect(); models::ProcedureInfo { - name: query_name.clone(), - description: query.description.clone(), + name: procedure_name.clone(), + description: procedure.description.clone(), arguments, - result_type: map_type(&query.result_type), + result_type: map_type(&procedure.result_type), } } diff --git a/fixtures/connector/chinook/native_queries/insert_artist.json b/fixtures/connector/chinook/native_procedures/insert_artist.json similarity index 87% rename from fixtures/connector/chinook/native_queries/insert_artist.json rename to fixtures/connector/chinook/native_procedures/insert_artist.json index 7ff29310..17b5dfc7 100644 --- a/fixtures/connector/chinook/native_queries/insert_artist.json +++ b/fixtures/connector/chinook/native_procedures/insert_artist.json @@ -1,7 +1,6 @@ { "name": "insertArtist", - "description": "Example of a database update using a native query", - "mode": "readWrite", + "description": "Example of a database update using a native procedure", "resultType": { "object": "InsertArtist" }, diff --git a/fixtures/connector/chinook/native_queries/hello.json b/fixtures/connector/chinook/native_queries/hello.json deleted file mode 100644 index c88d253f..00000000 --- a/fixtures/connector/chinook/native_queries/hello.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "name": "hello", - "description": "Example of a read-only native query", - "objectTypes": { - "HelloResult": { - "fields": { - "ok": { - "type": { - "scalar": "int" - } - }, - "readOnly": { - "type": { - "scalar": "bool" - } - } - } - } - }, - "resultType": { - "object": "HelloResult" - }, - "command": { - "hello": 1 - } -} diff --git a/fixtures/ddn/subgraphs/chinook/commands/Hello.hml b/fixtures/ddn/subgraphs/chinook/commands/Hello.hml deleted file mode 100644 index cfdebd65..00000000 --- a/fixtures/ddn/subgraphs/chinook/commands/Hello.hml +++ /dev/null @@ -1,53 +0,0 @@ -kind: Command -version: v1 -definition: - name: hello - description: Example of a read-only native query - outputType: HelloResult - arguments: [] - source: - dataConnectorName: mongodb - dataConnectorCommand: - function: hello - typeMapping: - HelloResult: - fieldMapping: - ok: { column: ok } - readOnly: { column: readOnly } - graphql: - rootFieldName: hello - rootFieldKind: Query - ---- -kind: CommandPermissions -version: v1 -definition: - commandName: hello - permissions: - - role: admin - allowExecution: true - ---- -kind: ObjectType -version: v1 -definition: - name: HelloResult - graphql: - typeName: HelloResult - fields: - - name: ok - type: Int! - - name: readOnly - type: Boolean! - ---- -kind: TypePermissions -version: v1 -definition: - typeName: HelloResult - permissions: - - role: admin - output: - allowedFields: - - ok - - readOnly diff --git a/fixtures/ddn/subgraphs/chinook/commands/InsertArtist.hml b/fixtures/ddn/subgraphs/chinook/commands/InsertArtist.hml index 663e9199..54bad1db 100644 --- a/fixtures/ddn/subgraphs/chinook/commands/InsertArtist.hml +++ b/fixtures/ddn/subgraphs/chinook/commands/InsertArtist.hml @@ -2,7 +2,7 @@ kind: Command version: v1 definition: name: insertArtist - description: Example of a database update using a native query + description: Example of a database update using a native procedure outputType: InsertArtist arguments: - name: id diff --git a/fixtures/ddn/subgraphs/chinook/dataconnectors/mongodb.hml b/fixtures/ddn/subgraphs/chinook/dataconnectors/mongodb.hml index 37db817e..ebb9727d 100644 --- a/fixtures/ddn/subgraphs/chinook/dataconnectors/mongodb.hml +++ b/fixtures/ddn/subgraphs/chinook/dataconnectors/mongodb.hml @@ -905,12 +905,6 @@ definition: underlying_type: type: named name: ObjectId - HelloResult: - fields: - ok: - type: { type: named, name: Int } - readOnly: - type: { type: named, name: Boolean } InsertArtist: fields: ok: @@ -1006,15 +1000,10 @@ definition: unique_columns: - _id foreign_keys: {} - functions: - - name: hello - description: Example of a read-only native query - result_type: { type: named, name: HelloResult } - arguments: {} - command: { hello: 1 } + functions: [] procedures: - name: insertArtist - description: Example of a database update using a native query + description: Example of a database update using a native procedure result_type: { type: named, name: InsertArtist } arguments: id: { type: { type: named, name: Int } }