mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-09-20 15:09:02 +03:00
server: remove systemDefined field from CoreFieldInfo
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5028 GitOrigin-RevId: 168dc2aeae12258231ddb8300a0aa2fe5817927c
This commit is contained in:
parent
f6ea3168b6
commit
6b03f8b0af
@ -283,9 +283,8 @@ mkDescriptionWith descM defaultTxt = G.Description $ case descM of
|
||||
-- got removed in PDV. OTOH, I’m not sure how prevalent this feature
|
||||
-- actually is
|
||||
takeValidTables :: forall b. Backend b => TableCache b -> TableCache b
|
||||
takeValidTables = Map.filterWithKey graphQLTableFilter . Map.filter tableFilter
|
||||
takeValidTables = Map.filterWithKey graphQLTableFilter
|
||||
where
|
||||
tableFilter = not . isSystemDefined . _tciSystemDefined . _tiCoreInfo
|
||||
graphQLTableFilter tableName tableInfo =
|
||||
-- either the table name should be GraphQL compliant
|
||||
-- or it should have a GraphQL custom name set with it
|
||||
|
@ -334,11 +334,9 @@ unTrackExistingTableOrViewP1 ::
|
||||
m ()
|
||||
unTrackExistingTableOrViewP1 (UntrackTable source vn _) = do
|
||||
schemaCache <- askSchemaCache
|
||||
tableInfo <-
|
||||
void $
|
||||
unsafeTableInfo @b source vn (scSources schemaCache)
|
||||
`onNothing` throw400 AlreadyUntracked ("view/table already untracked : " <>> vn)
|
||||
when (isSystemDefined $ _tciSystemDefined $ _tiCoreInfo tableInfo) $
|
||||
throw400 NotSupported $ vn <<> " is system defined, cannot untrack"
|
||||
|
||||
unTrackExistingTableOrViewP2 ::
|
||||
forall b m.
|
||||
@ -499,7 +497,6 @@ buildTableCache = Inc.cache proc (source, sourceConfig, dbTablesMeta, tableBuild
|
||||
-<
|
||||
TableCoreInfo
|
||||
{ _tciName = name,
|
||||
_tciSystemDefined = SystemDefined False,
|
||||
_tciFieldInfoMap = columnMap,
|
||||
_tciPrimaryKey = primaryKey,
|
||||
_tciUniqueConstraints = _ptmiUniqueConstraints metadataTable,
|
||||
|
@ -36,7 +36,6 @@ module Hasura.RQL.Types.SchemaCache
|
||||
TableCoreInfo,
|
||||
tciName,
|
||||
tciDescription,
|
||||
tciSystemDefined,
|
||||
tciFieldInfoMap,
|
||||
tciPrimaryKey,
|
||||
tciUniqueConstraints,
|
||||
|
@ -71,7 +71,6 @@ module Hasura.RQL.Types.Table
|
||||
tciForeignKeys,
|
||||
tciName,
|
||||
tciPrimaryKey,
|
||||
tciSystemDefined,
|
||||
tciUniqueConstraints,
|
||||
tciUniqueOrPrimaryKeyConstraints,
|
||||
tciViewInfo,
|
||||
@ -854,7 +853,6 @@ instance Backend b => FromJSON (ForeignKey b) where
|
||||
data TableCoreInfoG (b :: BackendType) field primaryKeyColumn = TableCoreInfo
|
||||
{ _tciName :: TableName b,
|
||||
_tciDescription :: Maybe PG.PGDescription, -- TODO make into type family?
|
||||
_tciSystemDefined :: SystemDefined,
|
||||
_tciFieldInfoMap :: FieldInfoMap field,
|
||||
_tciPrimaryKey :: Maybe (PrimaryKey b primaryKeyColumn),
|
||||
-- | Does /not/ include the primary key; use 'tciUniqueOrPrimaryKeyConstraints' if you need both.
|
||||
|
@ -231,13 +231,13 @@ computeMetrics ::
|
||||
Maybe ActionCache ->
|
||||
Metrics
|
||||
computeMetrics sourceInfo _mtServiceTimings remoteSchemaMap actionCache =
|
||||
let _mtTables = countUserTables (isNothing . _tciViewInfo . _tiCoreInfo)
|
||||
_mtViews = countUserTables (isJust . _tciViewInfo . _tiCoreInfo)
|
||||
_mtEnumTables = countUserTables (isJust . _tciEnumValues . _tiCoreInfo)
|
||||
allRels = join $ Map.elems $ Map.map (getRels . _tciFieldInfoMap . _tiCoreInfo) userTables
|
||||
let _mtTables = countSourceTables (isNothing . _tciViewInfo . _tiCoreInfo)
|
||||
_mtViews = countSourceTables (isJust . _tciViewInfo . _tiCoreInfo)
|
||||
_mtEnumTables = countSourceTables (isJust . _tciEnumValues . _tiCoreInfo)
|
||||
allRels = join $ Map.elems $ Map.map (getRels . _tciFieldInfoMap . _tiCoreInfo) sourceTableCache
|
||||
(manualRels, autoRels) = L.partition riIsManual allRels
|
||||
_mtRelationships = RelationshipMetric (length manualRels) (length autoRels)
|
||||
rolePerms = join $ Map.elems $ Map.map permsOfTbl userTables
|
||||
rolePerms = join $ Map.elems $ Map.map permsOfTbl sourceTableCache
|
||||
_pmRoles = length $ L.uniques $ fst <$> rolePerms
|
||||
allPerms = snd <$> rolePerms
|
||||
_pmInsert = calcPerms _permIns allPerms
|
||||
@ -249,7 +249,7 @@ computeMetrics sourceInfo _mtServiceTimings remoteSchemaMap actionCache =
|
||||
_mtEventTriggers =
|
||||
Map.size $
|
||||
Map.filter (not . Map.null) $
|
||||
Map.map _tiEventTriggerInfoMap userTables
|
||||
Map.map _tiEventTriggerInfoMap sourceTableCache
|
||||
_mtRemoteSchemas = Map.size <$> remoteSchemaMap
|
||||
_mtFunctions = Map.size $ Map.filter (not . isSystemDefined . _fiSystemDefined) sourceFunctionCache
|
||||
_mtActions = computeActionsMetrics <$> actionCache
|
||||
@ -257,8 +257,7 @@ computeMetrics sourceInfo _mtServiceTimings remoteSchemaMap actionCache =
|
||||
where
|
||||
sourceTableCache = _siTables sourceInfo
|
||||
sourceFunctionCache = _siFunctions sourceInfo
|
||||
userTables = Map.filter (not . isSystemDefined . _tciSystemDefined . _tiCoreInfo) sourceTableCache
|
||||
countUserTables predicate = length . filter predicate $ Map.elems userTables
|
||||
countSourceTables predicate = length . filter predicate $ Map.elems sourceTableCache
|
||||
|
||||
calcPerms :: (RolePermInfo b -> Maybe a) -> [RolePermInfo b] -> Int
|
||||
calcPerms fn perms = length $ mapMaybe fn perms
|
||||
|
@ -23,7 +23,7 @@ import Hasura.RQL.IR.Root (RemoteRelationshipField)
|
||||
import Hasura.RQL.IR.Update (AnnotatedUpdateG (..))
|
||||
import Hasura.RQL.IR.Value (UnpreparedValue (..))
|
||||
import Hasura.RQL.Types.Column (ColumnInfo (..), ColumnMutability (..), ColumnType (..))
|
||||
import Hasura.RQL.Types.Common (Comment (..), FieldName (..), SystemDefined (..))
|
||||
import Hasura.RQL.Types.Common (Comment (..), FieldName (..))
|
||||
import Hasura.RQL.Types.Instances ()
|
||||
import Hasura.RQL.Types.Permission (AllowedRootFields (..))
|
||||
import Hasura.RQL.Types.Source (SourceInfo)
|
||||
@ -136,7 +136,6 @@ mkParser table cib =
|
||||
TableCoreInfo
|
||||
{ _tciName = table,
|
||||
_tciDescription = Nothing,
|
||||
_tciSystemDefined = SystemDefined False,
|
||||
_tciFieldInfoMap = fieldInfoMap,
|
||||
_tciPrimaryKey = Nothing,
|
||||
_tciUniqueConstraints = mempty,
|
||||
|
Loading…
Reference in New Issue
Block a user