mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-15 01:12:56 +03:00
server: drop HasVersion implicit parameter (closes #2236)
The only real use was for the dubious multitenant option --consoleAssetsVersion, which actually overrode not just the assets version. I.e., as far as I can tell, if you pass --consoleAssetsVersion to multitenant, that version will also make it into e.g. HTTP client user agent headers as the proper graphql-engine version. I'm dropping that option, since it seems unused in production and I don't want to go to the effort of fixing it, but am happy to look into that if folks feels strongly that it should be kept. (Reason for attacking this is that I was looking into http client things around blacklisting, and the versioning thing is a bit painful around http client headers.) PR-URL: https://github.com/hasura/graphql-engine-mono/pull/2458 GitOrigin-RevId: a02b05557124bdba9f65e96b3aa2746aeee03f4a
This commit is contained in:
parent
94a3be3e6e
commit
71af68e9e5
@ -438,7 +438,6 @@ library
|
||||
, Hasura.Server.API.V2Query
|
||||
, Hasura.Server.Utils
|
||||
, Hasura.Server.Version
|
||||
, Hasura.Server.Version.TH
|
||||
, Hasura.Server.Limits
|
||||
, Hasura.Server.Logging
|
||||
, Hasura.Server.Migrate
|
||||
|
@ -25,7 +25,6 @@ import Hasura.Server.Init
|
||||
import Hasura.Server.Metrics (ServerMetricsSpec, createServerMetrics)
|
||||
import Hasura.Server.Migrate (downgradeCatalog)
|
||||
import Hasura.Server.Version
|
||||
import Hasura.Server.Version.TH
|
||||
import System.Exit qualified as Sys
|
||||
import System.Metrics qualified as EKG
|
||||
import System.Posix.Signals qualified as Signals
|
||||
@ -48,7 +47,7 @@ runApp env (HGEOptionsG rci metadataDbUrl hgeCmd) = do
|
||||
globalCtx@GlobalCtx {..} <- initGlobalCtx env metadataDbUrl rci
|
||||
let (maybeDefaultPgConnInfo, maybeRetries) = _gcDefaultPostgresConnInfo
|
||||
|
||||
withVersion $$(getVersionFromEnvironment) $ case hgeCmd of
|
||||
case hgeCmd of
|
||||
HCServe serveOptions -> do
|
||||
(ekgStore, serverMetrics) <- liftIO $ do
|
||||
store <- EKG.newStore @AppMetricsSpec
|
||||
|
@ -305,7 +305,7 @@ resolvePostgresConnInfo env dbUrlConf maybeRetries = do
|
||||
|
||||
-- | Initializes or migrates the catalog and returns the context required to start the server.
|
||||
initialiseServeCtx ::
|
||||
(HasVersion, C.ForkableMonadIO m, MonadCatch m) =>
|
||||
(C.ForkableMonadIO m, MonadCatch m) =>
|
||||
Env.Environment ->
|
||||
GlobalCtx ->
|
||||
ServeOptions Hasura ->
|
||||
@ -394,7 +394,7 @@ mkLoggers enabledLogs logLevel = do
|
||||
|
||||
-- | helper function to initialize or migrate the @hdb_catalog@ schema (used by pro as well)
|
||||
migrateCatalogSchema ::
|
||||
(HasVersion, MonadIO m, MonadBaseControl IO m) =>
|
||||
(MonadIO m, MonadBaseControl IO m) =>
|
||||
Env.Environment ->
|
||||
Logger Hasura ->
|
||||
Q.PGPool ->
|
||||
@ -511,8 +511,7 @@ flushLogger = liftIO . FL.flushLogStr . _lcLoggerSet
|
||||
{- HLINT ignore runHGEServer "Avoid lambda" -}
|
||||
runHGEServer ::
|
||||
forall m impl.
|
||||
( HasVersion,
|
||||
MonadIO m,
|
||||
( MonadIO m,
|
||||
MonadMask m,
|
||||
MonadStateless IO m,
|
||||
LA.Forall (LA.Pure m),
|
||||
@ -1083,7 +1082,7 @@ instance MonadMetadataStorageQueryAPI (MetadataStorageT (PGMetadataStorageAppT C
|
||||
|
||||
--- helper functions ---
|
||||
|
||||
mkConsoleHTML :: HasVersion => Text -> AuthMode -> Bool -> Maybe Text -> Either String Text
|
||||
mkConsoleHTML :: Text -> AuthMode -> Bool -> Maybe Text -> Either String Text
|
||||
mkConsoleHTML path authMode enableTelemetry consoleAssetsDir =
|
||||
renderHtmlTemplate consoleTmplt $
|
||||
-- variables required to render the template
|
||||
|
@ -27,14 +27,12 @@ import Hasura.QueryTags
|
||||
import Hasura.RQL.IR.Insert qualified as IR
|
||||
import Hasura.RQL.IR.Returning qualified as IR
|
||||
import Hasura.RQL.Types
|
||||
import Hasura.Server.Version (HasVersion)
|
||||
import Hasura.Session
|
||||
import Hasura.Tracing qualified as Tracing
|
||||
|
||||
convertToSQLTransaction ::
|
||||
forall pgKind m.
|
||||
( HasVersion,
|
||||
MonadTx m,
|
||||
( MonadTx m,
|
||||
MonadIO m,
|
||||
Tracing.MonadTrace m,
|
||||
Backend ('Postgres pgKind),
|
||||
@ -58,8 +56,7 @@ convertToSQLTransaction (IR.AnnInsert fieldName isSingle annIns mutationOutput)
|
||||
|
||||
insertMultipleObjects ::
|
||||
forall pgKind m.
|
||||
( HasVersion,
|
||||
MonadTx m,
|
||||
( MonadTx m,
|
||||
MonadIO m,
|
||||
Tracing.MonadTrace m,
|
||||
Backend ('Postgres pgKind),
|
||||
@ -118,8 +115,7 @@ insertMultipleObjects multiObjIns additionalColumns userInfo mutationOutput plan
|
||||
|
||||
insertObject ::
|
||||
forall pgKind m.
|
||||
( HasVersion,
|
||||
MonadTx m,
|
||||
( MonadTx m,
|
||||
MonadIO m,
|
||||
Tracing.MonadTrace m,
|
||||
Backend ('Postgres pgKind),
|
||||
@ -212,8 +208,7 @@ insertObject singleObjIns additionalColumns userInfo planVars stringifyNum = Tra
|
||||
|
||||
insertObjRel ::
|
||||
forall pgKind m.
|
||||
( HasVersion,
|
||||
MonadTx m,
|
||||
( MonadTx m,
|
||||
MonadIO m,
|
||||
Tracing.MonadTrace m,
|
||||
Backend ('Postgres pgKind),
|
||||
@ -248,8 +243,7 @@ insertObjRel planVars userInfo stringifyNum objRelIns =
|
||||
<> table <<> " affects zero rows"
|
||||
|
||||
insertArrRel ::
|
||||
( HasVersion,
|
||||
MonadTx m,
|
||||
( MonadTx m,
|
||||
MonadIO m,
|
||||
Tracing.MonadTrace m,
|
||||
Backend ('Postgres pgKind),
|
||||
|
@ -70,7 +70,6 @@ import Hasura.RQL.Types
|
||||
)
|
||||
import Hasura.RQL.Types.Column (ColumnType (..), ColumnValue (..))
|
||||
import Hasura.SQL.AnyBackend qualified as AB
|
||||
import Hasura.Server.Version (HasVersion)
|
||||
import Hasura.Session (UserInfo (..))
|
||||
import Hasura.Tracing qualified as Tracing
|
||||
import Language.GraphQL.Draft.Syntax qualified as G
|
||||
@ -208,7 +207,6 @@ convertUpdate userInfo updateOperation stringifyNum queryTags = do
|
||||
convertInsert ::
|
||||
forall pgKind m.
|
||||
( MonadError QErr m,
|
||||
HasVersion,
|
||||
Backend ('Postgres pgKind),
|
||||
PostgresAnnotatedFieldJSON pgKind
|
||||
) =>
|
||||
@ -253,7 +251,6 @@ convertFunction userInfo jsonAggSelect unpreparedQuery queryTags = do
|
||||
pgDBMutationPlan ::
|
||||
forall pgKind m.
|
||||
( MonadError QErr m,
|
||||
HasVersion,
|
||||
Backend ('Postgres pgKind),
|
||||
PostgresAnnotatedFieldJSON pgKind,
|
||||
MonadReader QueryTagsComment m
|
||||
|
@ -76,7 +76,6 @@ import Hasura.RQL.Types.Eventing.Backend
|
||||
import Hasura.SQL.AnyBackend qualified as AB
|
||||
import Hasura.Server.Metrics (ServerMetrics (..))
|
||||
import Hasura.Server.Types
|
||||
import Hasura.Server.Version (HasVersion)
|
||||
import Hasura.Tracing qualified as Tracing
|
||||
import Network.HTTP.Client qualified as HTTP
|
||||
import System.Metrics.Distribution qualified as EKG.Distribution
|
||||
@ -217,8 +216,7 @@ pattern Resp a = Right (Right a)
|
||||
-- - limit webhook HTTP concurrency per HASURA_GRAPHQL_EVENTS_HTTP_POOL_SIZE
|
||||
processEventQueue ::
|
||||
forall m.
|
||||
( HasVersion,
|
||||
MonadIO m,
|
||||
( MonadIO m,
|
||||
Tracing.HasReporter m,
|
||||
MonadBaseControl IO m,
|
||||
LA.Forall (LA.Pure m),
|
||||
@ -346,8 +344,7 @@ processEventQueue logger logBehavior httpMgr getSchemaCache EventEngineCtx {..}
|
||||
|
||||
processEvent ::
|
||||
forall io r b.
|
||||
( HasVersion,
|
||||
MonadIO io,
|
||||
( MonadIO io,
|
||||
MonadReader r io,
|
||||
Has HTTP.Manager r,
|
||||
Has (L.Logger L.Hasura) r,
|
||||
|
@ -65,7 +65,6 @@ import Hasura.RQL.DDL.RequestTransform (RequestTransform, TransformErrorBundle (
|
||||
import Hasura.RQL.Types.Common (ResolvedWebhook (..))
|
||||
import Hasura.RQL.Types.EventTrigger
|
||||
import Hasura.RQL.Types.Eventing
|
||||
import Hasura.Server.Version (HasVersion)
|
||||
import Hasura.Session (SessionVariables)
|
||||
import Hasura.Tracing
|
||||
import Network.HTTP.Client.Transformable qualified as HTTP
|
||||
@ -377,7 +376,6 @@ decodeHeader logBehavior headerInfos (hdrName, hdrVal) =
|
||||
-- | Encodes given request headers along with our 'defaultHeaders' and returns
|
||||
-- them along with the re-decoded set of headers (for logging purposes).
|
||||
prepareHeaders ::
|
||||
HasVersion =>
|
||||
LogBehavior ->
|
||||
[EventHeaderInfo] ->
|
||||
([HTTP.Header], [HeaderConf])
|
||||
|
@ -139,7 +139,6 @@ import Hasura.RQL.DDL.EventTrigger (getHeaderInfosFromConf)
|
||||
import Hasura.RQL.DDL.Headers
|
||||
import Hasura.RQL.Types
|
||||
import Hasura.SQL.Types
|
||||
import Hasura.Server.Version (HasVersion)
|
||||
import Hasura.Tracing qualified as Tracing
|
||||
import Network.HTTP.Client.Transformable qualified as HTTP
|
||||
import System.Cron
|
||||
@ -217,8 +216,7 @@ generateScheduleTimes from n cron = take n $ go from
|
||||
go = unfoldr (fmap dup . nextMatch cron)
|
||||
|
||||
processCronEvents ::
|
||||
( HasVersion,
|
||||
MonadIO m,
|
||||
( MonadIO m,
|
||||
Tracing.HasReporter m,
|
||||
MonadMetadataStorage (MetadataStorageT m)
|
||||
) =>
|
||||
@ -268,8 +266,7 @@ processCronEvents logger logBehavior httpMgr cronEvents getSC lockedCronEvents =
|
||||
logInternalError err = liftIO . L.unLogger logger $ ScheduledTriggerInternalErr err
|
||||
|
||||
processOneOffScheduledEvents ::
|
||||
( HasVersion,
|
||||
MonadIO m,
|
||||
( MonadIO m,
|
||||
Tracing.HasReporter m,
|
||||
MonadMetadataStorage (MetadataStorageT m)
|
||||
) =>
|
||||
@ -312,8 +309,7 @@ processOneOffScheduledEvents
|
||||
logInternalError err = liftIO . L.unLogger logger $ ScheduledTriggerInternalErr err
|
||||
|
||||
processScheduledTriggers ::
|
||||
( HasVersion,
|
||||
MonadIO m,
|
||||
( MonadIO m,
|
||||
Tracing.HasReporter m,
|
||||
MonadMetadataStorage (MetadataStorageT m)
|
||||
) =>
|
||||
@ -357,7 +353,6 @@ processScheduledEvent ::
|
||||
( MonadReader r m,
|
||||
Has HTTP.Manager r,
|
||||
Has (L.Logger L.Hasura) r,
|
||||
HasVersion,
|
||||
MonadIO m,
|
||||
Tracing.HasReporter m,
|
||||
MonadMetadataStorage m
|
||||
|
@ -46,7 +46,6 @@ import Hasura.RQL.IR qualified as IR
|
||||
import Hasura.RQL.Types
|
||||
import Hasura.SQL.AnyBackend qualified as AB
|
||||
import Hasura.Server.Types (RequestId (..))
|
||||
import Hasura.Server.Version (HasVersion)
|
||||
import Hasura.Session
|
||||
import Hasura.Tracing qualified as Tracing
|
||||
import Language.GraphQL.Draft.Syntax qualified as G
|
||||
@ -189,7 +188,7 @@ buildSubscriptionPlan userInfo rootFields parameterizedQueryHash = do
|
||||
let subscriptionQueryTagsAttributes = encodeQueryTags $ QTLiveQuery $ LivequeryMetadata rootFieldName parameterizedQueryHash
|
||||
let queryTagsComment = Tagged.untag $ EB.createQueryTags @m subscriptionQueryTagsAttributes queryTagsConfig
|
||||
LQP . AB.mkAnyBackend . MultiplexedLiveQueryPlan
|
||||
<$> flip runReaderT queryTagsComment (EB.mkDBSubscriptionPlan userInfo sourceName sourceConfig qdbs)
|
||||
<$> runReaderT (EB.mkDBSubscriptionPlan userInfo sourceName sourceConfig qdbs) queryTagsComment
|
||||
pure (sourceName, lqp)
|
||||
|
||||
checkField ::
|
||||
@ -228,8 +227,7 @@ checkQueryInAllowlist enableAL userInfo req sc =
|
||||
|
||||
getResolvedExecPlan ::
|
||||
forall m.
|
||||
( HasVersion,
|
||||
MonadError QErr m,
|
||||
( MonadError QErr m,
|
||||
MonadMetadataStorage (MetadataStorageT m),
|
||||
MonadIO m,
|
||||
Tracing.MonadTrace m,
|
||||
|
@ -31,7 +31,6 @@ import Hasura.RQL.Types.Run (RunT (..))
|
||||
import Hasura.RQL.Types.SchemaCache.Build (MetadataT (..))
|
||||
import Hasura.SQL.AnyBackend qualified as AB
|
||||
import Hasura.SQL.Backend
|
||||
import Hasura.Server.Version (HasVersion)
|
||||
import Hasura.Session
|
||||
import Hasura.Tracing (TraceT)
|
||||
import Language.GraphQL.Draft.Syntax qualified as G
|
||||
@ -67,7 +66,6 @@ class
|
||||
mkDBMutationPlan ::
|
||||
forall m.
|
||||
( MonadError QErr m,
|
||||
HasVersion,
|
||||
MonadQueryTags m,
|
||||
MonadReader QueryTagsComment m
|
||||
) =>
|
||||
|
@ -28,7 +28,6 @@ import Hasura.RQL.IR
|
||||
import Hasura.RQL.Types
|
||||
import Hasura.SQL.AnyBackend qualified as AB
|
||||
import Hasura.Server.Types (RequestId (..))
|
||||
import Hasura.Server.Version (HasVersion)
|
||||
import Hasura.Session
|
||||
import Hasura.Tracing qualified as Tracing
|
||||
import Language.GraphQL.Draft.Syntax qualified as G
|
||||
@ -59,8 +58,7 @@ convertMutationAction env logger userInfo manager reqHeaders gqlQueryText = \cas
|
||||
|
||||
convertMutationSelectionSet ::
|
||||
forall m.
|
||||
( HasVersion,
|
||||
Tracing.MonadTrace m,
|
||||
( Tracing.MonadTrace m,
|
||||
MonadIO m,
|
||||
MonadError QErr m,
|
||||
MonadMetadataStorage (MetadataStorageT m),
|
||||
|
@ -31,7 +31,6 @@ import Hasura.Prelude
|
||||
import Hasura.RQL.Types
|
||||
import Hasura.SQL.AnyBackend qualified as AB
|
||||
import Hasura.Server.Types (RequestId)
|
||||
import Hasura.Server.Version (HasVersion)
|
||||
import Hasura.Session
|
||||
import Hasura.Tracing qualified as Tracing
|
||||
import Language.GraphQL.Draft.Syntax qualified as G
|
||||
@ -48,8 +47,7 @@ forRemoteJoins remoteJoins onNoJoins f =
|
||||
maybe (pure onNoJoins) f remoteJoins
|
||||
|
||||
processRemoteJoins ::
|
||||
( HasVersion,
|
||||
MonadError QErr m,
|
||||
( MonadError QErr m,
|
||||
MonadIO m,
|
||||
EB.MonadQueryTags m,
|
||||
MonadQueryLog m,
|
||||
@ -81,8 +79,7 @@ processRemoteJoins requestId logger env manager reqHdrs userInfo lhs joinTree gq
|
||||
gqlreq
|
||||
|
||||
processRemoteJoins_ ::
|
||||
( HasVersion,
|
||||
MonadError QErr m,
|
||||
( MonadError QErr m,
|
||||
MonadIO m,
|
||||
EB.MonadQueryTags m,
|
||||
MonadQueryLog m,
|
||||
|
@ -28,7 +28,6 @@ import Hasura.GraphQL.RemoteServer (execRemoteGQ)
|
||||
import Hasura.GraphQL.Transport.HTTP.Protocol (GQLReq (..), GQLReqOutgoing)
|
||||
import Hasura.Prelude
|
||||
import Hasura.RQL.Types
|
||||
import Hasura.Server.Version (HasVersion)
|
||||
import Hasura.Session
|
||||
import Hasura.Tracing qualified as Tracing
|
||||
import Language.GraphQL.Draft.Syntax qualified as G
|
||||
@ -124,8 +123,7 @@ buildJoinIndex response responsePaths =
|
||||
for responsePaths $ \path -> extractAtPath (AO.Object response) path
|
||||
|
||||
getRemoteSchemaResponse ::
|
||||
( HasVersion,
|
||||
MonadError QErr m,
|
||||
( MonadError QErr m,
|
||||
MonadIO m,
|
||||
Tracing.MonadTrace m
|
||||
) =>
|
||||
|
@ -36,7 +36,6 @@ import Hasura.Prelude
|
||||
import Hasura.RQL.DDL.Headers (makeHeadersFromConf)
|
||||
import Hasura.RQL.Types
|
||||
import Hasura.Server.Utils
|
||||
import Hasura.Server.Version (HasVersion)
|
||||
import Hasura.Session
|
||||
import Hasura.Tracing qualified as Tracing
|
||||
import Language.GraphQL.Draft.Parser qualified as G
|
||||
@ -145,7 +144,7 @@ validateSchemaCustomizationsDistinct remoteSchemaCustomizer (RemoteSchemaIntrosp
|
||||
-- and also is called by schema cache rebuilding code in "Hasura.RQL.DDL.Schema.Cache".
|
||||
fetchRemoteSchema ::
|
||||
forall m.
|
||||
(HasVersion, MonadIO m, MonadUnique m, MonadError QErr m, Tracing.MonadTrace m) =>
|
||||
(MonadIO m, MonadUnique m, MonadError QErr m, Tracing.MonadTrace m) =>
|
||||
Env.Environment ->
|
||||
HTTP.Manager ->
|
||||
RemoteSchemaName ->
|
||||
@ -413,8 +412,7 @@ toObjectTypeDefinition :: G.Name -> G.ObjectTypeDefinition G.InputValueDefinitio
|
||||
toObjectTypeDefinition name = G.ObjectTypeDefinition Nothing name [] [] []
|
||||
|
||||
execRemoteGQ ::
|
||||
( HasVersion,
|
||||
MonadIO m,
|
||||
( MonadIO m,
|
||||
MonadError QErr m,
|
||||
Tracing.MonadTrace m
|
||||
) =>
|
||||
|
@ -66,7 +66,6 @@ import Hasura.Server.Logging
|
||||
import Hasura.Server.Logging qualified as L
|
||||
import Hasura.Server.Telemetry.Counters qualified as Telem
|
||||
import Hasura.Server.Types (RequestId)
|
||||
import Hasura.Server.Version (HasVersion)
|
||||
import Hasura.Session
|
||||
import Hasura.Tracing (MonadTrace, TraceT, trace)
|
||||
import Hasura.Tracing qualified as Tracing
|
||||
@ -223,8 +222,7 @@ filterVariablesFromQuery query = fold $ rootToSessVarPreds =<< query
|
||||
-- | Run (execute) a single GraphQL query
|
||||
runGQ ::
|
||||
forall m.
|
||||
( HasVersion,
|
||||
MonadIO m,
|
||||
( MonadIO m,
|
||||
MonadBaseControl IO m,
|
||||
MonadError QErr m,
|
||||
MonadReader E.ExecutionCtx m,
|
||||
@ -560,8 +558,7 @@ buildRaw json = do
|
||||
-- | Run (execute) a batched GraphQL query (see 'GQLBatchedReqs').
|
||||
runGQBatched ::
|
||||
forall m.
|
||||
( HasVersion,
|
||||
MonadIO m,
|
||||
( MonadIO m,
|
||||
MonadBaseControl IO m,
|
||||
MonadError QErr m,
|
||||
MonadReader E.ExecutionCtx m,
|
||||
|
@ -35,15 +35,13 @@ import Hasura.Server.Init.Config
|
||||
)
|
||||
import Hasura.Server.Limits
|
||||
import Hasura.Server.Metrics (ServerMetrics (..))
|
||||
import Hasura.Server.Version (HasVersion)
|
||||
import Hasura.Tracing qualified as Tracing
|
||||
import Network.HTTP.Client qualified as H
|
||||
import Network.WebSockets qualified as WS
|
||||
import System.Metrics.Gauge qualified as EKG.Gauge
|
||||
|
||||
createWSServerApp ::
|
||||
( HasVersion,
|
||||
MonadIO m,
|
||||
( MonadIO m,
|
||||
MC.MonadBaseControl IO m,
|
||||
LA.Forall (LA.Pure m),
|
||||
UserAuthentication (Tracing.TraceT m),
|
||||
|
@ -86,7 +86,6 @@ import Hasura.Server.Limits
|
||||
import Hasura.Server.Metrics (ServerMetrics (..))
|
||||
import Hasura.Server.Telemetry.Counters qualified as Telem
|
||||
import Hasura.Server.Types (RequestId, getRequestId)
|
||||
import Hasura.Server.Version (HasVersion)
|
||||
import Hasura.Session
|
||||
import Hasura.Tracing qualified as Tracing
|
||||
import Language.GraphQL.Draft.Syntax qualified as G
|
||||
@ -376,8 +375,7 @@ onConn wsId requestHead ipAddress onConnHActions = do
|
||||
|
||||
onStart ::
|
||||
forall m.
|
||||
( HasVersion,
|
||||
MonadIO m,
|
||||
( MonadIO m,
|
||||
E.MonadGQLExecutionCheck m,
|
||||
MonadQueryLog m,
|
||||
Tracing.MonadTrace m,
|
||||
@ -837,8 +835,7 @@ onStart env enabledLogTypes serverEnv wsConn (StartMsg opId q) onMessageActions
|
||||
catchAndIgnore m = void $ runExceptT m
|
||||
|
||||
onMessage ::
|
||||
( HasVersion,
|
||||
MonadIO m,
|
||||
( MonadIO m,
|
||||
UserAuthentication (Tracing.TraceT m),
|
||||
E.MonadGQLExecutionCheck m,
|
||||
MonadQueryLog m,
|
||||
@ -932,7 +929,7 @@ stopOperation serverEnv wsConn opId logWhenOpNotExist = do
|
||||
opDet n = OperationDetails opId Nothing n ODStopped Nothing Nothing
|
||||
|
||||
onConnInit ::
|
||||
(HasVersion, MonadIO m, UserAuthentication (Tracing.TraceT m)) =>
|
||||
(MonadIO m, UserAuthentication (Tracing.TraceT m)) =>
|
||||
L.Logger L.Hasura ->
|
||||
H.Manager ->
|
||||
WSConn ->
|
||||
|
@ -19,7 +19,7 @@ import Data.Text.Conversions (UTF8 (..), convertText)
|
||||
import Data.Text.Encoding qualified as TE
|
||||
import Hasura.Prelude
|
||||
import Hasura.Server.Utils (redactSensitiveHeader)
|
||||
import Hasura.Server.Version (HasVersion, currentVersion)
|
||||
import Hasura.Server.Version (currentVersion)
|
||||
import Network.HTTP.Client qualified as HTTP
|
||||
import Network.HTTP.Types qualified as HTTP
|
||||
import Network.Wreq qualified as Wreq
|
||||
@ -30,7 +30,7 @@ hdrsToText hdrs =
|
||||
| (hdrName, hdrVal) <- hdrs
|
||||
]
|
||||
|
||||
wreqOptions :: HasVersion => HTTP.Manager -> [HTTP.Header] -> Wreq.Options
|
||||
wreqOptions :: HTTP.Manager -> [HTTP.Header] -> Wreq.Options
|
||||
wreqOptions manager hdrs =
|
||||
Wreq.defaults
|
||||
& Wreq.headers .~ addDefaultHeaders hdrs
|
||||
@ -38,15 +38,15 @@ wreqOptions manager hdrs =
|
||||
& Wreq.manager .~ Right manager
|
||||
|
||||
-- Adds defaults headers overwriting any existing ones
|
||||
addDefaultHeaders :: HasVersion => [HTTP.Header] -> [HTTP.Header]
|
||||
addDefaultHeaders :: [HTTP.Header] -> [HTTP.Header]
|
||||
addDefaultHeaders hdrs = defaultHeaders <> rmDefaultHeaders hdrs
|
||||
where
|
||||
rmDefaultHeaders = filter (not . isDefaultHeader)
|
||||
|
||||
isDefaultHeader :: HasVersion => HTTP.Header -> Bool
|
||||
isDefaultHeader :: HTTP.Header -> Bool
|
||||
isDefaultHeader (hdrName, _) = hdrName `elem` map fst defaultHeaders
|
||||
|
||||
defaultHeaders :: HasVersion => [HTTP.Header]
|
||||
defaultHeaders :: [HTTP.Header]
|
||||
defaultHeaders = [contentType, userAgent]
|
||||
where
|
||||
contentType = ("Content-Type", "application/json")
|
||||
|
@ -27,14 +27,12 @@ import Hasura.Prelude
|
||||
import Hasura.RQL.DDL.Deps
|
||||
import Hasura.RQL.DDL.RemoteSchema.Permission
|
||||
import Hasura.RQL.Types
|
||||
import Hasura.Server.Version (HasVersion)
|
||||
import Hasura.Session
|
||||
import Hasura.Tracing qualified as Tracing
|
||||
import Network.HTTP.Client.Manager (HasHttpManagerM (..))
|
||||
|
||||
runAddRemoteSchema ::
|
||||
( HasVersion,
|
||||
QErrM m,
|
||||
( QErrM m,
|
||||
CacheRWM m,
|
||||
MonadIO m,
|
||||
MonadUnique m,
|
||||
@ -128,7 +126,7 @@ addRemoteSchemaP1 name = do
|
||||
<> name <<> " already exists"
|
||||
|
||||
addRemoteSchemaP2Setup ::
|
||||
(HasVersion, QErrM m, MonadIO m, MonadUnique m, HasHttpManagerM m, Tracing.MonadTrace m) =>
|
||||
(QErrM m, MonadIO m, MonadUnique m, HasHttpManagerM m, Tracing.MonadTrace m) =>
|
||||
Env.Environment ->
|
||||
AddRemoteSchemaQuery ->
|
||||
m RemoteSchemaCtx
|
||||
@ -213,8 +211,7 @@ runIntrospectRemoteSchema (RemoteSchemaNameQuery rsName) = do
|
||||
pure $ encJFromLBS _rscRawIntrospectionResult
|
||||
|
||||
runUpdateRemoteSchema ::
|
||||
( HasVersion,
|
||||
QErrM m,
|
||||
( QErrM m,
|
||||
CacheRWM m,
|
||||
MonadIO m,
|
||||
MonadUnique m,
|
||||
|
@ -71,7 +71,6 @@ import Hasura.SQL.Tag qualified as Tag
|
||||
import Hasura.Server.Types
|
||||
( MaintenanceMode (..),
|
||||
)
|
||||
import Hasura.Server.Version (HasVersion)
|
||||
import Hasura.Session
|
||||
import Hasura.Tracing qualified as Tracing
|
||||
import Language.GraphQL.Draft.Syntax qualified as G
|
||||
@ -116,7 +115,6 @@ action/function.
|
||||
-}
|
||||
|
||||
buildRebuildableSchemaCache ::
|
||||
HasVersion =>
|
||||
Env.Environment ->
|
||||
Metadata ->
|
||||
CacheBuild RebuildableSchemaCache
|
||||
@ -124,7 +122,6 @@ buildRebuildableSchemaCache =
|
||||
buildRebuildableSchemaCacheWithReason CatalogSync
|
||||
|
||||
buildRebuildableSchemaCacheWithReason ::
|
||||
HasVersion =>
|
||||
BuildReason ->
|
||||
Env.Environment ->
|
||||
Metadata ->
|
||||
@ -222,8 +219,7 @@ instance
|
||||
buildSchemaCacheRule ::
|
||||
-- Note: by supplying BuildReason via MonadReader, it does not participate in caching, which is
|
||||
-- what we want!
|
||||
( HasVersion,
|
||||
ArrowChoice arr,
|
||||
( ArrowChoice arr,
|
||||
Inc.ArrowDistribute arr,
|
||||
Inc.ArrowCache m arr,
|
||||
MonadIO m,
|
||||
|
@ -17,7 +17,7 @@ import Hasura.RQL.Types
|
||||
import Hasura.Server.Auth
|
||||
import Hasura.Server.Auth.JWT
|
||||
import Hasura.Server.Types (ExperimentalFeature)
|
||||
import Hasura.Server.Version (HasVersion, Version, currentVersion)
|
||||
import Hasura.Server.Version (Version, currentVersion)
|
||||
|
||||
data JWTInfo = JWTInfo
|
||||
{ jwtiClaimsNamespace :: !JWTNamespace,
|
||||
@ -46,7 +46,6 @@ data ServerConfig = ServerConfig
|
||||
$(deriveToJSON hasuraJSON ''ServerConfig)
|
||||
|
||||
runGetConfig ::
|
||||
HasVersion =>
|
||||
FunctionPermissionsCtx ->
|
||||
RemoteSchemaPermsCtx ->
|
||||
AuthMode ->
|
||||
|
@ -46,7 +46,6 @@ import Hasura.Server.API.Backend
|
||||
import Hasura.Server.API.Instances ()
|
||||
import Hasura.Server.Types (InstanceId (..), MaintenanceMode (..))
|
||||
import Hasura.Server.Utils (APIVersion (..))
|
||||
import Hasura.Server.Version (HasVersion)
|
||||
import Hasura.Session
|
||||
import Hasura.Tracing qualified as Tracing
|
||||
import Network.HTTP.Client.Manager qualified as HTTP
|
||||
@ -276,8 +275,7 @@ instance FromJSON RQLMetadata where
|
||||
pure RQLMetadata {..}
|
||||
|
||||
runMetadataQuery ::
|
||||
( HasVersion,
|
||||
MonadIO m,
|
||||
( MonadIO m,
|
||||
MonadBaseControl IO m,
|
||||
Tracing.MonadTrace m,
|
||||
MonadMetadataStorage m,
|
||||
@ -347,8 +345,7 @@ queryModifiesMetadata = \case
|
||||
_ -> True
|
||||
|
||||
runMetadataQueryM ::
|
||||
( HasVersion,
|
||||
MonadIO m,
|
||||
( MonadIO m,
|
||||
MonadBaseControl IO m,
|
||||
CacheRWM m,
|
||||
Tracing.MonadTrace m,
|
||||
@ -372,8 +369,7 @@ runMetadataQueryM env currentResourceVersion =
|
||||
|
||||
runMetadataQueryV1M ::
|
||||
forall m r.
|
||||
( HasVersion,
|
||||
MonadIO m,
|
||||
( MonadIO m,
|
||||
MonadBaseControl IO m,
|
||||
CacheRWM m,
|
||||
Tracing.MonadTrace m,
|
||||
|
@ -40,7 +40,6 @@ import Hasura.RQL.Types
|
||||
import Hasura.RQL.Types.Run
|
||||
import Hasura.Server.Types
|
||||
import Hasura.Server.Utils
|
||||
import Hasura.Server.Version (HasVersion)
|
||||
import Hasura.Session
|
||||
import Hasura.Tracing qualified as Tracing
|
||||
import Network.HTTP.Client qualified as HTTP
|
||||
@ -155,8 +154,7 @@ $( deriveFromJSON
|
||||
)
|
||||
|
||||
runQuery ::
|
||||
( HasVersion,
|
||||
MonadIO m,
|
||||
( MonadIO m,
|
||||
Tracing.MonadTrace m,
|
||||
MonadBaseControl IO m,
|
||||
MonadMetadataStorage m,
|
||||
@ -316,8 +314,7 @@ reconcileAccessModes (Just mode1) (Just mode2)
|
||||
| otherwise = Left mode2
|
||||
|
||||
runQueryM ::
|
||||
( HasVersion,
|
||||
CacheRWM m,
|
||||
( CacheRWM m,
|
||||
UserInfoM m,
|
||||
MonadBaseControl IO m,
|
||||
MonadIO m,
|
||||
|
@ -25,7 +25,6 @@ import Hasura.RQL.DML.Update
|
||||
import Hasura.RQL.Types
|
||||
import Hasura.RQL.Types.Run
|
||||
import Hasura.Server.Types
|
||||
import Hasura.Server.Version (HasVersion)
|
||||
import Hasura.Session
|
||||
import Hasura.Tracing qualified as Tracing
|
||||
import Network.HTTP.Client qualified as HTTP
|
||||
@ -53,8 +52,7 @@ $( deriveFromJSON
|
||||
)
|
||||
|
||||
runQuery ::
|
||||
( HasVersion,
|
||||
MonadIO m,
|
||||
( MonadIO m,
|
||||
MonadBaseControl IO m,
|
||||
Tracing.MonadTrace m,
|
||||
MonadMetadataStorage m,
|
||||
@ -112,8 +110,7 @@ queryModifiesSchema = \case
|
||||
RQBulk l -> any queryModifiesSchema l
|
||||
|
||||
runQueryM ::
|
||||
( HasVersion,
|
||||
MonadError QErr m,
|
||||
( MonadError QErr m,
|
||||
MonadIO m,
|
||||
MonadBaseControl IO m,
|
||||
UserInfoM m,
|
||||
|
@ -249,13 +249,13 @@ setHeader (headerName, headerValue) =
|
||||
-- | Typeclass representing the metadata API authorization effect
|
||||
class (Monad m) => MonadMetadataApiAuthorization m where
|
||||
authorizeV1QueryApi ::
|
||||
HasVersion => RQLQuery -> HandlerCtx -> m (Either QErr ())
|
||||
RQLQuery -> HandlerCtx -> m (Either QErr ())
|
||||
|
||||
authorizeV1MetadataApi ::
|
||||
HasVersion => RQLMetadata -> HandlerCtx -> m (Either QErr ())
|
||||
RQLMetadata -> HandlerCtx -> m (Either QErr ())
|
||||
|
||||
authorizeV2QueryApi ::
|
||||
HasVersion => V2Q.RQLQuery -> HandlerCtx -> m (Either QErr ())
|
||||
V2Q.RQLQuery -> HandlerCtx -> m (Either QErr ())
|
||||
|
||||
instance MonadMetadataApiAuthorization m => MonadMetadataApiAuthorization (ReaderT r m) where
|
||||
authorizeV1QueryApi q hc = lift $ authorizeV1QueryApi q hc
|
||||
@ -275,7 +275,6 @@ instance MonadMetadataApiAuthorization m => MonadMetadataApiAuthorization (Traci
|
||||
-- | The config API (/v1alpha1/config) handler
|
||||
class Monad m => MonadConfigApiHandler m where
|
||||
runConfigApiHandler ::
|
||||
HasVersion =>
|
||||
ServerCtx ->
|
||||
-- | console assets directory
|
||||
Maybe Text ->
|
||||
@ -292,7 +291,7 @@ mapActionT ::
|
||||
mapActionT f tma = MTC.restoreT . pure =<< MTC.liftWith (\run -> f (run tma))
|
||||
|
||||
mkSpockAction ::
|
||||
(HasVersion, MonadIO m, MonadBaseControl IO m, FromJSON a, UserAuthentication (Tracing.TraceT m), HttpLog m, Tracing.HasReporter m, HasResourceLimits m) =>
|
||||
(MonadIO m, MonadBaseControl IO m, FromJSON a, UserAuthentication (Tracing.TraceT m), HttpLog m, Tracing.HasReporter m, HasResourceLimits m) =>
|
||||
ServerCtx ->
|
||||
-- | `QErr` JSON encoder function
|
||||
(Bool -> QErr -> Value) ->
|
||||
@ -407,8 +406,7 @@ mkSpockAction serverCtx@ServerCtx {..} qErrEncoder qErrModifier apiHandler = do
|
||||
Spock.lazyBytes compressedResp
|
||||
|
||||
v1QueryHandler ::
|
||||
( HasVersion,
|
||||
MonadIO m,
|
||||
( MonadIO m,
|
||||
MonadBaseControl IO m,
|
||||
MonadMetadataApiAuthorization m,
|
||||
Tracing.MonadTrace m,
|
||||
@ -450,8 +448,7 @@ v1QueryHandler query = do
|
||||
query
|
||||
|
||||
v1MetadataHandler ::
|
||||
( HasVersion,
|
||||
MonadIO m,
|
||||
( MonadIO m,
|
||||
MonadBaseControl IO m,
|
||||
MonadReader HandlerCtx m,
|
||||
Tracing.MonadTrace m,
|
||||
@ -493,8 +490,7 @@ v1MetadataHandler query = do
|
||||
pure $ HttpResponse r []
|
||||
|
||||
v2QueryHandler ::
|
||||
( HasVersion,
|
||||
MonadIO m,
|
||||
( MonadIO m,
|
||||
MonadBaseControl IO m,
|
||||
MonadMetadataApiAuthorization m,
|
||||
Tracing.MonadTrace m,
|
||||
@ -531,8 +527,7 @@ v2QueryHandler query = do
|
||||
V2Q.runQuery env instanceId userInfo schemaCache httpMgr serverConfigCtx query
|
||||
|
||||
v1Alpha1GQHandler ::
|
||||
( HasVersion,
|
||||
MonadIO m,
|
||||
( MonadIO m,
|
||||
MonadBaseControl IO m,
|
||||
E.MonadGQLExecutionCheck m,
|
||||
MonadQueryLog m,
|
||||
@ -589,8 +584,7 @@ mkExecutionContext = do
|
||||
pure $ E.ExecutionCtx logger sqlGenCtx (lastBuiltSchemaCache sc) scVer manager enableAL
|
||||
|
||||
v1GQHandler ::
|
||||
( HasVersion,
|
||||
MonadIO m,
|
||||
( MonadIO m,
|
||||
MonadBaseControl IO m,
|
||||
E.MonadGQLExecutionCheck m,
|
||||
MonadQueryLog m,
|
||||
@ -608,8 +602,7 @@ v1GQHandler ::
|
||||
v1GQHandler = v1Alpha1GQHandler E.QueryHasura
|
||||
|
||||
v1GQRelayHandler ::
|
||||
( HasVersion,
|
||||
MonadIO m,
|
||||
( MonadIO m,
|
||||
MonadBaseControl IO m,
|
||||
E.MonadGQLExecutionCheck m,
|
||||
MonadQueryLog m,
|
||||
@ -691,7 +684,7 @@ consoleAssetsHandler logger enabledLogTypes dir path = do
|
||||
headers = ("Content-Type", mimeType) : encHeader
|
||||
|
||||
class (Monad m) => ConsoleRenderer m where
|
||||
renderConsole :: HasVersion => Text -> AuthMode -> Bool -> Maybe Text -> m (Either String Text)
|
||||
renderConsole :: Text -> AuthMode -> Bool -> Maybe Text -> m (Either String Text)
|
||||
|
||||
instance ConsoleRenderer m => ConsoleRenderer (Tracing.TraceT m) where
|
||||
renderConsole a b c d = lift $ renderConsole a b c d
|
||||
@ -706,7 +699,7 @@ renderHtmlTemplate template jVal =
|
||||
-- | Default implementation of the 'MonadConfigApiHandler'
|
||||
configApiGetHandler ::
|
||||
forall m.
|
||||
(HasVersion, MonadIO m, MonadBaseControl IO m, UserAuthentication (Tracing.TraceT m), HttpLog m, Tracing.HasReporter m, HasResourceLimits m) =>
|
||||
(MonadIO m, MonadBaseControl IO m, UserAuthentication (Tracing.TraceT m), HttpLog m, Tracing.HasReporter m, HasResourceLimits m) =>
|
||||
ServerCtx ->
|
||||
Maybe Text ->
|
||||
Spock.SpockCtxT () m ()
|
||||
@ -737,8 +730,7 @@ data HasuraApp = HasuraApp
|
||||
|
||||
mkWaiApp ::
|
||||
forall m.
|
||||
( HasVersion,
|
||||
MonadIO m,
|
||||
( MonadIO m,
|
||||
-- , MonadUnique m
|
||||
MonadStateless IO m,
|
||||
LA.Forall (LA.Pure m),
|
||||
@ -886,8 +878,7 @@ initialiseCache schemaCache = do
|
||||
|
||||
httpApp ::
|
||||
forall m.
|
||||
( HasVersion,
|
||||
MonadIO m,
|
||||
( MonadIO m,
|
||||
-- , MonadUnique m
|
||||
MonadBaseControl IO m,
|
||||
ConsoleRenderer m,
|
||||
@ -955,8 +946,7 @@ httpApp setupHook corsCfg serverCtx enableConsole consoleAssetsDir enableTelemet
|
||||
|
||||
let customEndpointHandler ::
|
||||
forall n.
|
||||
( HasVersion,
|
||||
MonadIO n,
|
||||
( MonadIO n,
|
||||
MonadBaseControl IO n,
|
||||
E.MonadGQLExecutionCheck n,
|
||||
MonadQueryLog n,
|
||||
|
@ -41,7 +41,6 @@ import Hasura.Prelude
|
||||
import Hasura.Server.Auth.JWT hiding (processJwt_)
|
||||
import Hasura.Server.Auth.WebHook
|
||||
import Hasura.Server.Utils
|
||||
import Hasura.Server.Version (HasVersion)
|
||||
import Hasura.Session
|
||||
import Hasura.Tracing qualified as Tracing
|
||||
import Network.HTTP.Client qualified as H
|
||||
@ -50,7 +49,6 @@ import Network.HTTP.Types qualified as N
|
||||
-- | Typeclass representing the @UserInfo@ authorization and resolving effect
|
||||
class (Monad m) => UserAuthentication m where
|
||||
resolveUserInfo ::
|
||||
HasVersion =>
|
||||
Logger Hasura ->
|
||||
H.Manager ->
|
||||
-- | request headers
|
||||
@ -99,8 +97,7 @@ data AuthMode
|
||||
--
|
||||
-- This must only be run once, on launch.
|
||||
setupAuthMode ::
|
||||
( HasVersion,
|
||||
ForkableMonadIO m,
|
||||
( ForkableMonadIO m,
|
||||
Tracing.HasReporter m
|
||||
) =>
|
||||
Maybe AdminSecretHash ->
|
||||
@ -144,8 +141,7 @@ setupAuthMode mAdminSecretHash mWebHook mJwtSecret mUnAuthRole httpManager logge
|
||||
<> " --access-key (HASURA_GRAPHQL_ACCESS_KEY) to be set"
|
||||
|
||||
mkJwtCtx ::
|
||||
( HasVersion,
|
||||
ForkableMonadIO m,
|
||||
( ForkableMonadIO m,
|
||||
Tracing.HasReporter m
|
||||
) =>
|
||||
JWTConfig ->
|
||||
@ -182,7 +178,7 @@ setupAuthMode mAdminSecretHash mWebHook mJwtSecret mUnAuthRole httpManager logge
|
||||
-- | Authenticate the request using the headers and the configured 'AuthMode'.
|
||||
getUserInfoWithExpTime ::
|
||||
forall m.
|
||||
(HasVersion, MonadIO m, MonadBaseControl IO m, MonadError QErr m, Tracing.MonadTrace m) =>
|
||||
(MonadIO m, MonadBaseControl IO m, MonadError QErr m, Tracing.MonadTrace m) =>
|
||||
Logger Hasura ->
|
||||
H.Manager ->
|
||||
[N.Header] ->
|
||||
|
@ -66,7 +66,6 @@ import Hasura.Server.Utils
|
||||
isSessionVariable,
|
||||
userRoleHeader,
|
||||
)
|
||||
import Hasura.Server.Version (HasVersion)
|
||||
import Hasura.Session
|
||||
import Hasura.Tracing qualified as Tracing
|
||||
import Network.HTTP.Client.Transformable qualified as HTTP
|
||||
@ -256,7 +255,7 @@ $(J.deriveJSON hasuraJSON ''HasuraClaims)
|
||||
|
||||
-- | An action that refreshes the JWK at intervals in an infinite loop.
|
||||
jwkRefreshCtrl ::
|
||||
(HasVersion, MonadIO m, MonadBaseControl IO m, Tracing.HasReporter m) =>
|
||||
(MonadIO m, MonadBaseControl IO m, Tracing.HasReporter m) =>
|
||||
Logger Hasura ->
|
||||
HTTP.Manager ->
|
||||
URI ->
|
||||
@ -279,8 +278,7 @@ jwkRefreshCtrl logger manager url ref time = do
|
||||
|
||||
-- | Given a JWK url, fetch JWK from it and update the IORef
|
||||
updateJwkRef ::
|
||||
( HasVersion,
|
||||
MonadIO m,
|
||||
( MonadIO m,
|
||||
MonadBaseControl IO m,
|
||||
MonadError JwkFetchError m,
|
||||
Tracing.MonadTrace m
|
||||
|
@ -24,7 +24,6 @@ import Hasura.Logging
|
||||
import Hasura.Prelude
|
||||
import Hasura.Server.Logging
|
||||
import Hasura.Server.Utils
|
||||
import Hasura.Server.Version (HasVersion)
|
||||
import Hasura.Session
|
||||
import Hasura.Tracing qualified as Tracing
|
||||
import Network.HTTP.Client.Transformable qualified as H
|
||||
@ -59,7 +58,7 @@ hookMethod authHook = case ahType authHook of
|
||||
-- for finer-grained auth. (#2666)
|
||||
userInfoFromAuthHook ::
|
||||
forall m.
|
||||
(HasVersion, MonadIO m, MonadBaseControl IO m, MonadError QErr m, Tracing.MonadTrace m) =>
|
||||
(MonadIO m, MonadBaseControl IO m, MonadError QErr m, Tracing.MonadTrace m) =>
|
||||
Logger Hasura ->
|
||||
H.Manager ->
|
||||
AuthHook ->
|
||||
|
@ -16,7 +16,7 @@ import Data.Text.Conversions (toText)
|
||||
import Hasura.HTTP
|
||||
import Hasura.Logging (LoggerCtx (..))
|
||||
import Hasura.Prelude
|
||||
import Hasura.Server.Version (HasVersion, Version, currentVersion)
|
||||
import Hasura.Server.Version (Version, currentVersion)
|
||||
import Network.HTTP.Client qualified as H
|
||||
import Network.URI.Encode qualified as URI
|
||||
import Network.Wreq qualified as Wreq
|
||||
@ -31,7 +31,7 @@ newtype UpdateInfo = UpdateInfo
|
||||
-- aesonPrefix, but needs to remain like this for backwards compatibility
|
||||
$(A.deriveJSON (A.aesonDrop 2 A.snakeCase) ''UpdateInfo)
|
||||
|
||||
checkForUpdates :: HasVersion => LoggerCtx a -> H.Manager -> IO void
|
||||
checkForUpdates :: LoggerCtx a -> H.Manager -> IO void
|
||||
checkForUpdates (LoggerCtx loggerSet _ _ _) manager = do
|
||||
let options = wreqOptions manager []
|
||||
url <- getUrl
|
||||
|
@ -29,7 +29,6 @@ import Hasura.RQL.Types
|
||||
import Hasura.Server.Limits
|
||||
import Hasura.Server.Logging
|
||||
import Hasura.Server.Types
|
||||
import Hasura.Server.Version
|
||||
import Hasura.Session
|
||||
import Hasura.Tracing qualified as Tracing
|
||||
import Language.GraphQL.Draft.Syntax qualified as G
|
||||
@ -109,8 +108,7 @@ data RestRequest method = RestRequest
|
||||
-- handler.
|
||||
runCustomEndpoint ::
|
||||
forall m.
|
||||
( HasVersion,
|
||||
MonadIO m,
|
||||
( MonadIO m,
|
||||
MonadError QErr m,
|
||||
Tracing.MonadTrace m,
|
||||
MonadBaseControl IO m,
|
||||
|
@ -111,7 +111,6 @@ mkPayload dbId instanceId version metrics = do
|
||||
-- hours. The send time depends on when the server was started and will
|
||||
-- naturally drift.
|
||||
runTelemetry ::
|
||||
HasVersion =>
|
||||
Logger Hasura ->
|
||||
HTTP.Manager ->
|
||||
-- | an action that always returns the latest schema cache
|
||||
|
@ -11,6 +11,7 @@ import Data.ByteString.Base16 qualified as Base16
|
||||
import Data.ByteString.Lazy qualified as BL
|
||||
import Data.CaseInsensitive qualified as CI
|
||||
import Data.Char
|
||||
import Data.FileEmbed (makeRelativeToProject)
|
||||
import Data.HashSet qualified as Set
|
||||
import Data.List.NonEmpty qualified as NE
|
||||
import Data.Text qualified as T
|
||||
@ -87,16 +88,17 @@ parseStringAsBool t
|
||||
++ ". All values are case insensitive"
|
||||
|
||||
-- Get an env var during compile time
|
||||
getValFromEnvOrScript :: String -> String -> Q (TExp String)
|
||||
getValFromEnvOrScript n s = do
|
||||
maybeVal <- TH.runIO $ lookupEnv n
|
||||
getValFromEnvOrScript :: String -> FilePath -> Q (TExp String)
|
||||
getValFromEnvOrScript var file = do
|
||||
maybeVal <- TH.runIO $ lookupEnv var
|
||||
case maybeVal of
|
||||
Just val -> [||val||]
|
||||
Nothing -> runScript s
|
||||
Nothing -> runScript file
|
||||
|
||||
-- Run a shell script during compile time
|
||||
runScript :: FilePath -> Q (TExp String)
|
||||
runScript fp = do
|
||||
runScript file = do
|
||||
fp <- makeRelativeToProject file
|
||||
TH.addDependentFile fp
|
||||
fileContent <- TH.runIO $ TI.readFile fp
|
||||
(exitCode, stdOut, stdErr) <-
|
||||
|
@ -1,11 +1,7 @@
|
||||
{-# LANGUAGE ImplicitParams #-}
|
||||
|
||||
module Hasura.Server.Version
|
||||
( Version (..),
|
||||
HasVersion,
|
||||
currentVersion,
|
||||
consoleAssetsVersion,
|
||||
withVersion,
|
||||
)
|
||||
where
|
||||
|
||||
@ -15,6 +11,7 @@ import Data.SemVer qualified as V
|
||||
import Data.Text qualified as T
|
||||
import Data.Text.Conversions (FromText (..), ToText (..))
|
||||
import Hasura.Prelude
|
||||
import Hasura.Server.Utils (getValFromEnvOrScript)
|
||||
import Text.Regex.TDFA ((=~~))
|
||||
|
||||
data Version
|
||||
@ -38,28 +35,15 @@ instance ToJSON Version where
|
||||
instance FromJSON Version where
|
||||
parseJSON = fmap fromText . parseJSON
|
||||
|
||||
-- | Lots of random things need access to the current version. It would be very convenient to define
|
||||
-- @version :: 'Version'@ in this module and export it, and indeed, that’s what we used to do! But
|
||||
-- that turns out to cause problems: the version is compiled into the executable via Template
|
||||
-- Haskell, so the Pro codebase runs into awkward problems. Since the Pro codebase depends on this
|
||||
-- code as a library, it has to do gymnastics to ensure that this library always gets recompiled in
|
||||
-- order to use the updated version, and that’s really hacky.
|
||||
--
|
||||
-- A better solution is to explicitly plumb the version through to everything that needs it, but
|
||||
-- that would be noisy, so as a compromise we use an implicit parameter. Since implicit parameters
|
||||
-- are a little cumbersome, we hide the parameter itself behind this 'HasVersion' constraint,
|
||||
-- 'currentVersion' can be used to access it, and 'withVersion' can be used to bring a version into
|
||||
-- scope.
|
||||
type HasVersion = ?version :: Version
|
||||
|
||||
currentVersion :: HasVersion => Version
|
||||
currentVersion = ?version
|
||||
|
||||
withVersion :: Version -> (HasVersion => r) -> r
|
||||
withVersion version x = let ?version = version in x
|
||||
currentVersion :: Version
|
||||
currentVersion =
|
||||
fromText $
|
||||
T.dropWhileEnd (== '\n') $
|
||||
T.pack $
|
||||
$$(getValFromEnvOrScript "VERSION" "../scripts/get-version.sh")
|
||||
|
||||
-- | A version-based string used to form the CDN URL for fetching console assets.
|
||||
consoleAssetsVersion :: HasVersion => Text
|
||||
consoleAssetsVersion :: Text
|
||||
consoleAssetsVersion = case currentVersion of
|
||||
VersionDev txt -> "versioned/" <> txt
|
||||
VersionRelease v -> case getReleaseChannel v of
|
||||
|
@ -1,14 +0,0 @@
|
||||
module Hasura.Server.Version.TH (getVersionFromEnvironment) where
|
||||
|
||||
import Data.FileEmbed (makeRelativeToProject)
|
||||
import Data.Text qualified as T
|
||||
import Data.Text.Conversions (FromText (..))
|
||||
import Hasura.Prelude
|
||||
import Hasura.Server.Utils (getValFromEnvOrScript)
|
||||
import Hasura.Server.Version
|
||||
import Language.Haskell.TH.Syntax qualified as TH
|
||||
|
||||
getVersionFromEnvironment :: TH.Q (TH.TExp Version)
|
||||
getVersionFromEnvironment = do
|
||||
txt <- getValFromEnvOrScript "VERSION" <$> makeRelativeToProject "../scripts/get-version.sh"
|
||||
[||fromText $ T.dropWhileEnd (== '\n') $ T.pack $$(txt)||]
|
@ -18,7 +18,6 @@ import Hasura.Prelude
|
||||
import Hasura.Server.Auth hiding (getUserInfoWithExpTime, processJwt)
|
||||
import Hasura.Server.Auth.JWT hiding (processJwt)
|
||||
import Hasura.Server.Utils
|
||||
import Hasura.Server.Version
|
||||
import Hasura.Session
|
||||
import Hasura.Tracing qualified as Tracing
|
||||
import Network.HTTP.Types qualified as N
|
||||
@ -632,20 +631,19 @@ setupAuthMode' ::
|
||||
Maybe RoleName ->
|
||||
IO (Either () AuthMode)
|
||||
setupAuthMode' mAdminSecretHash mWebHook mJwtSecret mUnAuthRole =
|
||||
withVersion (VersionDev "fake") $
|
||||
-- just throw away the error message for ease of testing:
|
||||
fmap (either (const $ Left ()) Right) $
|
||||
runNoReporter $
|
||||
lowerManagedT $
|
||||
runExceptT $
|
||||
setupAuthMode
|
||||
mAdminSecretHash
|
||||
mWebHook
|
||||
mJwtSecret
|
||||
mUnAuthRole
|
||||
-- NOTE: this won't do any http or launch threads if we don't specify JWT URL:
|
||||
(error "H.Manager")
|
||||
(Logger $ void . return)
|
||||
-- just throw away the error message for ease of testing:
|
||||
fmap (either (const $ Left ()) Right) $
|
||||
runNoReporter $
|
||||
lowerManagedT $
|
||||
runExceptT $
|
||||
setupAuthMode
|
||||
mAdminSecretHash
|
||||
mWebHook
|
||||
mJwtSecret
|
||||
mUnAuthRole
|
||||
-- NOTE: this won't do any http or launch threads if we don't specify JWT URL:
|
||||
(error "H.Manager")
|
||||
(Logger $ void . return)
|
||||
|
||||
mkClaimsSetWithUnregisteredClaims :: HashMap Text J.Value -> JWT.ClaimsSet
|
||||
mkClaimsSetWithUnregisteredClaims unregisteredClaims =
|
||||
|
@ -26,7 +26,6 @@ import Hasura.Server.API.PGDump
|
||||
import Hasura.Server.Init (DowngradeOptions (..))
|
||||
import Hasura.Server.Migrate
|
||||
import Hasura.Server.Types (MaintenanceMode (..))
|
||||
import Hasura.Server.Version (HasVersion)
|
||||
import Hasura.Session
|
||||
import Network.HTTP.Client.Manager qualified as HTTP
|
||||
import Test.Hspec.Core.Spec
|
||||
@ -94,8 +93,7 @@ singleTransaction = id
|
||||
|
||||
spec ::
|
||||
forall m.
|
||||
( HasVersion,
|
||||
MonadIO m,
|
||||
( MonadIO m,
|
||||
MonadBaseControl IO m,
|
||||
HTTP.HasHttpManagerM m,
|
||||
HasServerConfigCtx m,
|
||||
|
@ -40,8 +40,6 @@ import Hasura.Server.Migrate
|
||||
import Hasura.Server.MigrateSpec qualified as MigrateSpec
|
||||
import Hasura.Server.TelemetrySpec qualified as TelemetrySpec
|
||||
import Hasura.Server.Types
|
||||
import Hasura.Server.Version
|
||||
import Hasura.Server.Version.TH
|
||||
import Network.HTTP.Client qualified as HTTP
|
||||
import Network.HTTP.Client.TLS qualified as HTTP
|
||||
import Network.HTTP.Client.TransformableSpec qualified as TransformableSpec
|
||||
@ -65,17 +63,16 @@ data TestSuite
|
||||
|
||||
main :: IO ()
|
||||
main =
|
||||
withVersion $$(getVersionFromEnvironment) $
|
||||
parseArgs >>= \case
|
||||
AllSuites pgConnOptions mssqlConnOptions -> do
|
||||
postgresSpecs <- buildPostgresSpecs pgConnOptions
|
||||
mssqlSpecs <- buildMSSQLSpecs mssqlConnOptions
|
||||
runHspec [] (unitSpecs *> postgresSpecs *> mssqlSpecs)
|
||||
SingleSuite hspecArgs suite ->
|
||||
runHspec hspecArgs =<< case suite of
|
||||
UnitSuite -> pure unitSpecs
|
||||
PostgresSuite pgConnOptions -> buildPostgresSpecs pgConnOptions
|
||||
MSSQLSuite mssqlConnOptions -> buildMSSQLSpecs mssqlConnOptions
|
||||
parseArgs >>= \case
|
||||
AllSuites pgConnOptions mssqlConnOptions -> do
|
||||
postgresSpecs <- buildPostgresSpecs pgConnOptions
|
||||
mssqlSpecs <- buildMSSQLSpecs mssqlConnOptions
|
||||
runHspec [] (unitSpecs *> postgresSpecs *> mssqlSpecs)
|
||||
SingleSuite hspecArgs suite ->
|
||||
runHspec hspecArgs =<< case suite of
|
||||
UnitSuite -> pure unitSpecs
|
||||
PostgresSuite pgConnOptions -> buildPostgresSpecs pgConnOptions
|
||||
MSSQLSuite mssqlConnOptions -> buildMSSQLSpecs mssqlConnOptions
|
||||
|
||||
unitSpecs :: Spec
|
||||
unitSpecs = do
|
||||
@ -118,7 +115,7 @@ mssqlConnectionString =
|
||||
"SQL Server database connection string. Example DRIVER={ODBC Driver 17 for SQL Server};SERVER=$IP_ADDRESS,$PORT;Uid=$USER;Pwd=$PASSWORD;"
|
||||
)
|
||||
|
||||
buildPostgresSpecs :: HasVersion => Maybe URLTemplate -> IO Spec
|
||||
buildPostgresSpecs :: Maybe URLTemplate -> IO Spec
|
||||
buildPostgresSpecs maybeUrlTemplate = do
|
||||
env <- getEnvironment
|
||||
let envMap = Env.mkEnvironment env
|
||||
|
Loading…
Reference in New Issue
Block a user