mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-14 17:02:49 +03:00
RemoveHasura.RQL.Types
dependency on Backends.Postgres.Execute.Types
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8869 Co-authored-by: Daniel Harvey <4729125+danieljharvey@users.noreply.github.com> GitOrigin-RevId: acabf17b5b9bde9f0f319eeae120ccc9527075a3
This commit is contained in:
parent
4c2ab2db4b
commit
982bf2cec6
@ -721,6 +721,7 @@ library
|
||||
, Hasura.LogicalModel.Schema
|
||||
, Hasura.LogicalModel.Types
|
||||
|
||||
, Hasura.ClientCredentials
|
||||
, Hasura.EncJSON
|
||||
|
||||
, Hasura.Function.API
|
||||
|
@ -90,6 +90,7 @@ import Hasura.App.State
|
||||
import Hasura.Backends.MSSQL.Connection
|
||||
import Hasura.Backends.Postgres.Connection
|
||||
import Hasura.Base.Error
|
||||
import Hasura.ClientCredentials (getEEClientCredentialsTx, setEEClientCredentialsTx)
|
||||
import Hasura.Eventing.Common
|
||||
import Hasura.Eventing.EventTrigger
|
||||
import Hasura.Eventing.ScheduledTrigger
|
||||
@ -125,7 +126,6 @@ import Hasura.RQL.DDL.Schema.Catalog
|
||||
import Hasura.RQL.Types.Allowlist
|
||||
import Hasura.RQL.Types.Backend
|
||||
import Hasura.RQL.Types.Common
|
||||
import Hasura.RQL.Types.EECredentials
|
||||
import Hasura.RQL.Types.Eventing.Backend
|
||||
import Hasura.RQL.Types.Metadata
|
||||
import Hasura.RQL.Types.ResizePool
|
||||
|
45
server/src-lib/Hasura/ClientCredentials.hs
Normal file
45
server/src-lib/Hasura/ClientCredentials.hs
Normal file
@ -0,0 +1,45 @@
|
||||
{-# LANGUAGE QuasiQuotes #-}
|
||||
|
||||
module Hasura.ClientCredentials
|
||||
( EEClientCredentials (..),
|
||||
EEClientId (..),
|
||||
getEEClientCredentialsTx,
|
||||
setEEClientCredentialsTx,
|
||||
)
|
||||
where
|
||||
|
||||
import Database.PG.Query qualified as PG
|
||||
import Hasura.Backends.Postgres.Execute.Types
|
||||
import Hasura.Base.Error
|
||||
import Hasura.Prelude
|
||||
import Hasura.RQL.Types.EECredentials (EEClientCredentials (..), EEClientId (..))
|
||||
|
||||
getEEClientCredentialsTx :: PG.TxE QErr (Maybe EEClientCredentials)
|
||||
getEEClientCredentialsTx =
|
||||
makeClientCredentials . PG.getRow
|
||||
<$> PG.withQE
|
||||
defaultTxErrorHandler
|
||||
[PG.sql|
|
||||
SELECT ee_client_id::text, ee_client_secret
|
||||
FROM hdb_catalog.hdb_version
|
||||
|]
|
||||
()
|
||||
False
|
||||
where
|
||||
makeClientCredentials :: (Maybe Text, Maybe Text) -> Maybe EEClientCredentials
|
||||
makeClientCredentials (clientIdMaybe, clientSecretMaybe) = do
|
||||
eccClientId <- EEClientId <$> clientIdMaybe
|
||||
eccClientSecret <- clientSecretMaybe
|
||||
pure EEClientCredentials {..}
|
||||
|
||||
setEEClientCredentialsTx :: EEClientCredentials -> PG.TxE QErr ()
|
||||
setEEClientCredentialsTx EEClientCredentials {..} =
|
||||
PG.unitQE
|
||||
defaultTxErrorHandler
|
||||
[PG.sql|
|
||||
UPDATE hdb_catalog.hdb_version
|
||||
SET ee_client_id = $1,
|
||||
ee_client_secret = $2
|
||||
|]
|
||||
(_getEEClientId eccClientId, eccClientSecret)
|
||||
True
|
@ -1,18 +1,11 @@
|
||||
{-# LANGUAGE QuasiQuotes #-}
|
||||
|
||||
module Hasura.RQL.Types.EECredentials
|
||||
( EEClientCredentials (..),
|
||||
EEClientId (..),
|
||||
getEEClientCredentialsTx,
|
||||
setEEClientCredentialsTx,
|
||||
)
|
||||
where
|
||||
|
||||
import Data.Aeson (FromJSON, (.:))
|
||||
import Data.Aeson qualified as Aeson
|
||||
import Database.PG.Query qualified as PG
|
||||
import Hasura.Backends.Postgres.Execute.Types
|
||||
import Hasura.Base.Error
|
||||
import Hasura.Prelude
|
||||
|
||||
data EEClientCredentials = EEClientCredentials
|
||||
@ -28,33 +21,3 @@ instance FromJSON EEClientCredentials where
|
||||
eccClientId <- o .: "client_id"
|
||||
eccClientSecret <- o .: "client_secret"
|
||||
pure EEClientCredentials {..}
|
||||
|
||||
getEEClientCredentialsTx :: PG.TxE QErr (Maybe EEClientCredentials)
|
||||
getEEClientCredentialsTx =
|
||||
makeClientCredentials . PG.getRow
|
||||
<$> PG.withQE
|
||||
defaultTxErrorHandler
|
||||
[PG.sql|
|
||||
SELECT ee_client_id::text, ee_client_secret
|
||||
FROM hdb_catalog.hdb_version
|
||||
|]
|
||||
()
|
||||
False
|
||||
where
|
||||
makeClientCredentials :: (Maybe Text, Maybe Text) -> Maybe EEClientCredentials
|
||||
makeClientCredentials (clientIdMaybe, clientSecretMaybe) = do
|
||||
eccClientId <- EEClientId <$> clientIdMaybe
|
||||
eccClientSecret <- clientSecretMaybe
|
||||
pure EEClientCredentials {..}
|
||||
|
||||
setEEClientCredentialsTx :: EEClientCredentials -> PG.TxE QErr ()
|
||||
setEEClientCredentialsTx EEClientCredentials {..} =
|
||||
PG.unitQE
|
||||
defaultTxErrorHandler
|
||||
[PG.sql|
|
||||
UPDATE hdb_catalog.hdb_version
|
||||
SET ee_client_id = $1,
|
||||
ee_client_secret = $2
|
||||
|]
|
||||
(_getEEClientId eccClientId, eccClientSecret)
|
||||
True
|
||||
|
Loading…
Reference in New Issue
Block a user