mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-14 08:02:15 +03:00
server: remove the execute
command from the graphql-engine
https://github.com/hasura/graphql-engine-mono/pull/2318 GitOrigin-RevId: a07b39469fa84a1ae3c913955872dcaade689c6e
This commit is contained in:
parent
dd88ad9631
commit
81df199169
@ -5,39 +5,32 @@ module Main where
|
||||
|
||||
import Hasura.Prelude
|
||||
|
||||
import qualified Control.Concurrent.Extended as C
|
||||
import qualified Data.ByteString.Char8 as BC
|
||||
import qualified Data.ByteString.Lazy as BL
|
||||
import qualified Data.ByteString.Lazy.Char8 as BLC
|
||||
import qualified Data.Environment as Env
|
||||
import qualified Database.PG.Query as Q
|
||||
import qualified System.Exit as Sys
|
||||
import qualified System.Metrics as EKG
|
||||
import qualified System.Posix.Signals as Signals
|
||||
import qualified Control.Concurrent.Extended as C
|
||||
import qualified Data.ByteString.Char8 as BC
|
||||
import qualified Data.Environment as Env
|
||||
import qualified Database.PG.Query as Q
|
||||
import qualified System.Exit as Sys
|
||||
import qualified System.Metrics as EKG
|
||||
import qualified System.Posix.Signals as Signals
|
||||
|
||||
import Control.Exception
|
||||
import Control.Monad.Trans.Managed (ManagedT (..), lowerManagedT)
|
||||
import Data.Int (Int64)
|
||||
import Data.Kind (Type)
|
||||
import Data.Text.Conversions (convertText)
|
||||
import Data.Time.Clock (getCurrentTime)
|
||||
import Data.Time.Clock.POSIX (getPOSIXTime)
|
||||
import GHC.TypeLits (Symbol)
|
||||
import Control.Monad.Trans.Managed (ManagedT (..), lowerManagedT)
|
||||
import Data.Int (Int64)
|
||||
import Data.Kind (Type)
|
||||
import Data.Text.Conversions (convertText)
|
||||
import Data.Time.Clock (getCurrentTime)
|
||||
import Data.Time.Clock.POSIX (getPOSIXTime)
|
||||
import GHC.TypeLits (Symbol)
|
||||
|
||||
import qualified Hasura.GC as GC
|
||||
import qualified Hasura.Tracing as Tracing
|
||||
import qualified Hasura.GC as GC
|
||||
|
||||
import Hasura.App
|
||||
import Hasura.Logging (Hasura, LogLevel (..),
|
||||
defaultEnabledEngineLogTypes)
|
||||
import Hasura.Metadata.Class
|
||||
import Hasura.Logging (Hasura, LogLevel (..), defaultEnabledEngineLogTypes)
|
||||
import Hasura.RQL.DDL.Schema
|
||||
import Hasura.RQL.DDL.Schema.Cache.Common
|
||||
import Hasura.RQL.Types
|
||||
import Hasura.Server.Init
|
||||
import Hasura.Server.Metrics (ServerMetricsSpec, createServerMetrics)
|
||||
import Hasura.Server.Migrate (downgradeCatalog)
|
||||
import Hasura.Server.Types (MaintenanceMode (..))
|
||||
import Hasura.Server.Metrics (ServerMetricsSpec, createServerMetrics)
|
||||
import Hasura.Server.Migrate (downgradeCatalog)
|
||||
import Hasura.Server.Version
|
||||
import Hasura.Server.Version.TH
|
||||
|
||||
@ -111,32 +104,6 @@ runApp env (HGEOptionsG rci metadataDbUrl hgeCmd) = do
|
||||
let cleanSuccessMsg = "successfully cleaned graphql-engine related data"
|
||||
either (printErrJExit MetadataCleanError) (const $ liftIO $ putStrLn cleanSuccessMsg) res
|
||||
|
||||
HCExecute -> do
|
||||
queryBs <- liftIO BL.getContents
|
||||
let sqlGenCtx = SQLGenCtx False False
|
||||
remoteSchemaPermsCtx = RemoteSchemaPermsDisabled
|
||||
pgLogger = print
|
||||
pgSourceResolver = mkPgSourceResolver pgLogger
|
||||
functionPermsCtx = FunctionPermissionsInferred
|
||||
maintenanceMode = MaintenanceModeDisabled
|
||||
serverConfigCtx =
|
||||
ServerConfigCtx functionPermsCtx remoteSchemaPermsCtx sqlGenCtx maintenanceMode mempty
|
||||
cacheBuildParams =
|
||||
CacheBuildParams _gcHttpManager pgSourceResolver serverConfigCtx
|
||||
runManagedT (mkMinimalPool _gcMetadataDbConnInfo) $ \metadataDbPool -> do
|
||||
res <- flip runPGMetadataStorageAppT (metadataDbPool, pgLogger) $
|
||||
runMetadataStorageT $ liftEitherM do
|
||||
(metadata, _) <- fetchMetadata
|
||||
runAsAdmin _gcHttpManager serverConfigCtx $ do
|
||||
schemaCache <- runCacheBuild cacheBuildParams $
|
||||
buildRebuildableSchemaCache env metadata
|
||||
execQuery env queryBs
|
||||
& Tracing.runTraceTWithReporter Tracing.noReporter "execute"
|
||||
& runMetadataT metadata
|
||||
& runCacheRWT schemaCache
|
||||
& fmap (\((res, _), _, _) -> res)
|
||||
either (printErrJExit ExecuteProcessError) (liftIO . BLC.putStrLn) res
|
||||
|
||||
HCDowngrade opts -> do
|
||||
let defaultSourceConfig = maybeDefaultPgConnInfo <&> \(dbUrlConf, _) ->
|
||||
let pgSourceConnInfo = PostgresSourceConnInfo dbUrlConf
|
||||
|
@ -57,7 +57,6 @@ import qualified Hasura.Tracing as Tracing
|
||||
import Data.IORef (readIORef)
|
||||
import Hasura.Backends.Postgres.Connection
|
||||
import Hasura.Base.Error
|
||||
import Hasura.EncJSON
|
||||
import Hasura.Eventing.Common
|
||||
import Hasura.Eventing.EventTrigger
|
||||
import Hasura.Eventing.ScheduledTrigger
|
||||
@ -77,7 +76,7 @@ import Hasura.RQL.DDL.Schema.Cache.Common
|
||||
import Hasura.RQL.DDL.Schema.Catalog
|
||||
import Hasura.RQL.Types
|
||||
import Hasura.RQL.Types.Run
|
||||
import Hasura.Server.API.Query (requiresAdmin, runQueryM)
|
||||
import Hasura.Server.API.Query (requiresAdmin)
|
||||
import Hasura.Server.App
|
||||
import Hasura.Server.Auth
|
||||
import Hasura.Server.CheckUpdates (checkForUpdates)
|
||||
@ -132,8 +131,6 @@ parseHGECommand =
|
||||
( progDesc "Export graphql-engine's metadata to stdout" ))
|
||||
<> command "clean" (info (pure HCClean)
|
||||
( progDesc "Clean graphql-engine's metadata to start afresh" ))
|
||||
<> command "execute" (info (pure HCExecute)
|
||||
( progDesc "Execute a query" ))
|
||||
<> command "downgrade" (info (HCDowngrade <$> downgradeOptionsParser)
|
||||
(progDesc "Downgrade the GraphQL Engine schema to the specified version"))
|
||||
<> command "version" (info (pure HCVersion)
|
||||
@ -826,30 +823,6 @@ runAsAdmin httpManager serverConfigCtx m = do
|
||||
let runCtx = RunCtx adminUserInfo httpManager serverConfigCtx
|
||||
runExceptT $ peelRun runCtx m
|
||||
|
||||
execQuery
|
||||
:: ( HasVersion
|
||||
, CacheRWM m
|
||||
, MonadIO m
|
||||
, MonadBaseControl IO m
|
||||
, MonadUnique m
|
||||
, HasHttpManagerM m
|
||||
, UserInfoM m
|
||||
, Tracing.MonadTrace m
|
||||
, HasServerConfigCtx m
|
||||
, MetadataM m
|
||||
, MonadMetadataStorageQueryAPI m
|
||||
, EB.MonadQueryTags m
|
||||
)
|
||||
=> Env.Environment
|
||||
-> BLC.ByteString
|
||||
-> m BLC.ByteString
|
||||
execQuery env queryBs = do
|
||||
query <- case A.decode queryBs of
|
||||
Just jVal -> decodeValue jVal
|
||||
Nothing -> throw400 InvalidJSON "invalid json"
|
||||
buildSchemaCacheStrict
|
||||
encJToLBS <$> runQueryM env query
|
||||
|
||||
instance (Monad m) => Tracing.HasReporter (PGMetadataStorageAppT m)
|
||||
|
||||
instance (Monad m) => HasResourceLimits (PGMetadataStorageAppT m) where
|
||||
|
@ -113,7 +113,6 @@ mkHGEOptions (HGEOptionsG rawDbUrl rawMetadataDbUrl rawCmd) =
|
||||
HCServe rso -> HCServe <$> mkServeOptions rso
|
||||
HCExport -> return HCExport
|
||||
HCClean -> return HCClean
|
||||
HCExecute -> return HCExecute
|
||||
HCVersion -> return HCVersion
|
||||
HCDowngrade tgt -> return (HCDowngrade tgt)
|
||||
|
||||
|
@ -230,7 +230,6 @@ data HGECommandG a
|
||||
= HCServe !a
|
||||
| HCExport
|
||||
| HCClean
|
||||
| HCExecute
|
||||
| HCVersion
|
||||
| HCDowngrade !DowngradeOptions
|
||||
deriving (Show, Eq)
|
||||
|
Loading…
Reference in New Issue
Block a user