mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-09-11 02:35:32 +03:00
Properly return schema information about views and PK mutability from the Super Connector
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8786 GitOrigin-RevId: b7cd0dd5736a408a269819ea76dfbe53455060ee
This commit is contained in:
parent
3332189756
commit
91c88b2109
@ -38,9 +38,8 @@ function determineScalarType(datatype: Datatype): ScalarTypeKey {
|
||||
}
|
||||
}
|
||||
|
||||
function getColumns(ast: any[], primaryKeys: string[]) : ColumnInfo[] {
|
||||
function getColumns(ast: any[]) : ColumnInfo[] {
|
||||
return ast.map(column => {
|
||||
const isPrimaryKey = primaryKeys.includes(column.name);
|
||||
const isAutoIncrement = column.definition.some((def: any) => def.type === "constraint" && def.autoIncrement === true);
|
||||
|
||||
return {
|
||||
@ -48,7 +47,7 @@ function getColumns(ast: any[], primaryKeys: string[]) : ColumnInfo[] {
|
||||
type: determineScalarType(column.datatype),
|
||||
nullable: nullableCast(column.definition),
|
||||
insertable: MUTATIONS,
|
||||
updatable: MUTATIONS && !isPrimaryKey,
|
||||
updatable: MUTATIONS,
|
||||
...(isAutoIncrement ? { value_generated: { type: "auto_increment" } } : {})
|
||||
};
|
||||
})
|
||||
@ -78,7 +77,7 @@ const formatTableInfo = (config: Config) => (info: TableInfoInternal): TableInfo
|
||||
...primaryKey,
|
||||
...foreignKey,
|
||||
description: info.sql,
|
||||
columns: getColumns(columnsDdl, primaryKeys),
|
||||
columns: getColumns(columnsDdl),
|
||||
insertable: MUTATIONS,
|
||||
updatable: MUTATIONS,
|
||||
deletable: MUTATIONS,
|
||||
|
@ -173,7 +173,7 @@ schemaInspectionTests = describe "Schema and Source Inspection" $ do
|
||||
nullable: false
|
||||
type: *_stIntegerType
|
||||
insertable: *supportsInserts
|
||||
updatable: false
|
||||
updatable: *supportsUpdates
|
||||
value_generated:
|
||||
type: auto_increment
|
||||
- name: *artistId
|
||||
|
@ -11,7 +11,7 @@
|
||||
"nullable": false,
|
||||
"description": "Genre primary key identifier",
|
||||
"insertable": true,
|
||||
"updatable": false,
|
||||
"updatable": true,
|
||||
"value_generated": { "type": "auto_increment" }
|
||||
},
|
||||
{
|
||||
@ -39,7 +39,7 @@
|
||||
"nullable": false,
|
||||
"description": "Media Type primary key identifier",
|
||||
"insertable": true,
|
||||
"updatable": false,
|
||||
"updatable": true,
|
||||
"value_generated": { "type": "auto_increment" }
|
||||
},
|
||||
{
|
||||
@ -67,7 +67,7 @@
|
||||
"nullable": false,
|
||||
"description": "Artist primary key identifier",
|
||||
"insertable": true,
|
||||
"updatable": false,
|
||||
"updatable": true,
|
||||
"value_generated": { "type": "auto_increment" }
|
||||
},
|
||||
{
|
||||
@ -103,7 +103,7 @@
|
||||
"nullable": false,
|
||||
"description": "Album primary key identifier",
|
||||
"insertable": true,
|
||||
"updatable": false,
|
||||
"updatable": true,
|
||||
"value_generated": { "type": "auto_increment" }
|
||||
},
|
||||
{
|
||||
@ -159,7 +159,7 @@
|
||||
"nullable": false,
|
||||
"description": "The ID of the track",
|
||||
"insertable": true,
|
||||
"updatable": false,
|
||||
"updatable": true,
|
||||
"value_generated": { "type": "auto_increment" }
|
||||
},
|
||||
{
|
||||
@ -251,7 +251,7 @@
|
||||
"nullable": false,
|
||||
"description": "Employee primary key identifier",
|
||||
"insertable": true,
|
||||
"updatable": false,
|
||||
"updatable": true,
|
||||
"value_generated": { "type": "auto_increment" }
|
||||
},
|
||||
{
|
||||
@ -391,7 +391,7 @@
|
||||
"nullable": false,
|
||||
"description": "Customer primary key identifier",
|
||||
"insertable": true,
|
||||
"updatable": false,
|
||||
"updatable": true,
|
||||
"value_generated": { "type": "auto_increment" }
|
||||
},
|
||||
{
|
||||
@ -515,7 +515,7 @@
|
||||
"nullable": false,
|
||||
"description": "Invoice primary key identifier",
|
||||
"insertable": true,
|
||||
"updatable": false,
|
||||
"updatable": true,
|
||||
"value_generated": { "type": "auto_increment" }
|
||||
},
|
||||
{
|
||||
@ -613,7 +613,7 @@
|
||||
"nullable": false,
|
||||
"description": "Invoice Line primary key identifier",
|
||||
"insertable": true,
|
||||
"updatable": false,
|
||||
"updatable": true,
|
||||
"value_generated": { "type": "auto_increment" }
|
||||
},
|
||||
{
|
||||
@ -665,7 +665,7 @@
|
||||
"nullable": false,
|
||||
"description": "Playlist primary key identifier",
|
||||
"insertable": true,
|
||||
"updatable": false,
|
||||
"updatable": true,
|
||||
"value_generated": { "type": "auto_increment" }
|
||||
},
|
||||
{
|
||||
@ -707,7 +707,7 @@
|
||||
"nullable": false,
|
||||
"description": "The ID of the playlist",
|
||||
"insertable": true,
|
||||
"updatable": false
|
||||
"updatable": true
|
||||
},
|
||||
{
|
||||
"name": "TrackId",
|
||||
@ -715,7 +715,7 @@
|
||||
"nullable": false,
|
||||
"description": "The ID of the track",
|
||||
"insertable": true,
|
||||
"updatable": false
|
||||
"updatable": true
|
||||
}
|
||||
],
|
||||
"insertable": true,
|
||||
|
Loading…
Reference in New Issue
Block a user