mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-15 01:12:56 +03:00
make FieldMapping enum again (#705)
<!-- Thank you for submitting this PR! :) --> ## Description <!-- Questions to consider answering: 1. What user-facing changes are being made? 2. What are issues related to this PR? (Consider adding `(close #<issue-no>)` to the PR title) 3. What is the conceptual design behind this PR? 4. How can this PR be tested/verified? 5. Does the PR have limitations? 6. Does the PR introduce breaking changes? --> This PR reverts the changes to `FieldMapping` and introduces the `argument_mapping` in `ColumnMapping` instead. V3_GIT_ORIGIN_REV_ID: badca2416b1a1b82d1a596aa60bf7a39b3b6152a
This commit is contained in:
parent
b3641238a9
commit
9f3b8370c1
@ -2510,14 +2510,14 @@
|
||||
},
|
||||
"Name": {
|
||||
"column": {
|
||||
"name": "Name"
|
||||
},
|
||||
"name": "Name",
|
||||
"argumentMapping": {
|
||||
"length": "string_length"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
|
@ -313,16 +313,18 @@ pub fn resolve_data_connector_type_mapping(
|
||||
for field_name in type_representation.fields.keys() {
|
||||
let (resolved_field_mapping_column, resolved_argument_mappings) =
|
||||
if let Some(field_mapping) = unconsumed_field_mappings.remove(field_name) {
|
||||
(
|
||||
&field_mapping.column.name,
|
||||
field_mapping.argument_mapping.clone(),
|
||||
)
|
||||
match field_mapping {
|
||||
open_dds::types::FieldMapping::Column(column_mapping) => (
|
||||
&column_mapping.name,
|
||||
column_mapping.argument_mapping.clone().unwrap_or_default(),
|
||||
),
|
||||
}
|
||||
} else {
|
||||
// If no mapping is defined for a field, implicitly create a mapping
|
||||
// with the same column name as the field.
|
||||
(
|
||||
DataConnectorColumnName::ref_cast(&field_name.0 .0),
|
||||
ArgumentMapping(BTreeMap::new()),
|
||||
ArgumentMapping::default(),
|
||||
)
|
||||
};
|
||||
let source_column = get_column(ndc_object_type, field_name, resolved_field_mapping_column)?;
|
||||
|
@ -150,14 +150,14 @@
|
||||
"fieldMapping": {
|
||||
"biography": {
|
||||
"column": {
|
||||
"name": "biography"
|
||||
},
|
||||
"name": "biography",
|
||||
"argumentMapping": {
|
||||
"ai_model": "model"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@ -1204,24 +1204,18 @@
|
||||
"OperatorName": {
|
||||
"type": "string"
|
||||
},
|
||||
"OpenDdSubgraph": {
|
||||
"$id": "https://hasura.io/jsonschemas/metadata/OpenDdSubgraph",
|
||||
"title": "OpenDdSubgraph",
|
||||
"GraphqlApolloFederationConfig": {
|
||||
"$id": "https://hasura.io/jsonschemas/metadata/GraphqlApolloFederationConfig",
|
||||
"title": "GraphqlApolloFederationConfig",
|
||||
"description": "Configuration for the GraphQL schema of Hasura features for Apollo Federation.",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"name",
|
||||
"objects"
|
||||
"enableRootFields"
|
||||
],
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string",
|
||||
"pattern": "^(?!__)[_a-zA-Z][_a-zA-Z0-9]*$"
|
||||
},
|
||||
"objects": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/OpenDdSubgraphObject"
|
||||
}
|
||||
"enableRootFields": {
|
||||
"description": "Adds the `_entities` and `_services` root fields required for Apollo Federation.",
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
@ -1611,6 +1605,9 @@
|
||||
"FieldMapping": {
|
||||
"$id": "https://hasura.io/jsonschemas/metadata/FieldMapping",
|
||||
"title": "FieldMapping",
|
||||
"oneOf": [
|
||||
{
|
||||
"description": "Source field directly maps to some column in the data connector.",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"column"
|
||||
@ -1618,17 +1615,11 @@
|
||||
"properties": {
|
||||
"column": {
|
||||
"$ref": "#/definitions/ColumnFieldMapping"
|
||||
},
|
||||
"argumentMapping": {
|
||||
"default": {},
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/ArgumentMapping"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
||||
]
|
||||
},
|
||||
"ColumnFieldMapping": {
|
||||
"$id": "https://hasura.io/jsonschemas/metadata/ColumnFieldMapping",
|
||||
@ -1646,13 +1637,22 @@
|
||||
"$ref": "#/definitions/DataConnectorColumnName"
|
||||
}
|
||||
]
|
||||
},
|
||||
"argumentMapping": {
|
||||
"description": "Arguments to the column field",
|
||||
"anyOf": [
|
||||
{
|
||||
"$ref": "#/definitions/ArgumentMapping"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
"DataConnectorColumnName": {
|
||||
"$id": "https://hasura.io/jsonschemas/metadata/DataConnectorColumnName",
|
||||
"title": "DataConnectorColumnName",
|
||||
"description": "The name of a column in a data connector.",
|
||||
"type": "string"
|
||||
},
|
||||
@ -2129,13 +2129,44 @@
|
||||
"default": {},
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/ArgumentMapping"
|
||||
"$ref": "#/definitions/ArgumentMapping2"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
"ArgumentMapping2": {
|
||||
"$id": "https://hasura.io/jsonschemas/metadata/ArgumentMapping",
|
||||
"title": "ArgumentMapping",
|
||||
"description": "Mapping of a comand or model argument name to the corresponding argument name used in the data connector. The key of this object is the argument name used in the command or model and the value is the argument name used in the data connector.",
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"$ref": "#/definitions/DataConnectorArgumentName"
|
||||
}
|
||||
},
|
||||
"OpenDdSubgraph": {
|
||||
"$id": "https://hasura.io/jsonschemas/metadata/OpenDdSubgraph",
|
||||
"title": "OpenDdSubgraph",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"name",
|
||||
"objects"
|
||||
],
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string",
|
||||
"pattern": "^(?!__)[_a-zA-Z][_a-zA-Z0-9]*$"
|
||||
},
|
||||
"objects": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/OpenDdSubgraphObject"
|
||||
}
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
"OrderableField": {
|
||||
"$id": "https://hasura.io/jsonschemas/metadata/OrderableField",
|
||||
"title": "OrderableField",
|
||||
@ -2495,7 +2526,7 @@
|
||||
"default": {},
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/ArgumentMapping"
|
||||
"$ref": "#/definitions/ArgumentMapping2"
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -3809,22 +3840,6 @@
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
"GraphqlApolloFederationConfig": {
|
||||
"$id": "https://hasura.io/jsonschemas/metadata/GraphqlApolloFederationConfig",
|
||||
"title": "GraphqlApolloFederationConfig",
|
||||
"description": "Configuration for the GraphQL schema of Hasura features for Apollo Federation.",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"enableRootFields"
|
||||
],
|
||||
"properties": {
|
||||
"enableRootFields": {
|
||||
"description": "Adds the `_entities` and `_services` root fields required for Apollo Federation.",
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
||||
}
|
||||
}
|
@ -340,14 +340,14 @@ impl ObjectType {
|
||||
"fieldMapping": {
|
||||
"biography": {
|
||||
"column": {
|
||||
"name": "biography"
|
||||
},
|
||||
"name": "biography",
|
||||
"argumentMapping": {
|
||||
"ai_model": "model"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@ -420,10 +420,9 @@ impl Deref for FieldMappings {
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[serde(deny_unknown_fields)]
|
||||
#[schemars(title = "FieldMapping")]
|
||||
pub struct FieldMapping {
|
||||
pub column: ColumnFieldMapping,
|
||||
#[opendd(default, json_schema(default_exp = "serde_json::json!({})"))]
|
||||
pub argument_mapping: ArgumentMapping,
|
||||
pub enum FieldMapping {
|
||||
/// Source field directly maps to some column in the data connector.
|
||||
Column(ColumnFieldMapping),
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema, opendds_derive::OpenDd)]
|
||||
@ -434,6 +433,9 @@ pub struct FieldMapping {
|
||||
pub struct ColumnFieldMapping {
|
||||
/// The name of the target column
|
||||
pub name: DataConnectorColumnName, // TODO: Map field arguments
|
||||
|
||||
/// Arguments to the column field
|
||||
pub argument_mapping: Option<ArgumentMapping>,
|
||||
}
|
||||
|
||||
#[repr(transparent)]
|
||||
|
Loading…
Reference in New Issue
Block a user