mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-18 13:02:11 +03:00
85cda65261
[NDAT-490]: https://hasurahq.atlassian.net/browse/NDAT-490?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [NDAT-491]: https://hasurahq.atlassian.net/browse/NDAT-491?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [NDAT-468]: https://hasurahq.atlassian.net/browse/NDAT-468?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ PR-URL: https://github.com/hasura/graphql-engine-mono/pull/7487 Co-authored-by: Solomon <24038+solomon-b@users.noreply.github.com> GitOrigin-RevId: ba679fc69df4b669fc7936cd359b8268e8e1a23a
68 lines
1.9 KiB
Haskell
68 lines
1.9 KiB
Haskell
{-# LANGUAGE DeriveAnyClass #-}
|
|
|
|
-- | Feature Flags are /temporary/ toggles.
|
|
module Hasura.Server.Init.FeatureFlag
|
|
( FeatureFlag (..),
|
|
defaultValueIO,
|
|
Identifier (..),
|
|
FeatureFlags (..),
|
|
featureFlags,
|
|
nativeQueryInterface,
|
|
)
|
|
where
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
import Data.Aeson (FromJSON, ToJSON)
|
|
import Data.HashMap.Strict qualified as HashMap
|
|
import Hasura.Prelude
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
newtype Identifier = Identifier {getIdentifier :: Text}
|
|
deriving stock (Generic)
|
|
deriving newtype (Eq, FromJSON, ToJSON)
|
|
deriving anyclass (Hashable)
|
|
|
|
data FeatureFlag = FeatureFlag
|
|
{ ffIdentifier :: Identifier,
|
|
ffDefaultValue :: Bool,
|
|
ffDescription :: Text
|
|
}
|
|
deriving stock (Eq, Generic)
|
|
deriving anyclass (Hashable, FromJSON, ToJSON)
|
|
|
|
-- | We hardcode all feature flags to their default value in OSS.
|
|
defaultValueIO :: FeatureFlag -> IO Bool
|
|
defaultValueIO = pure . ffDefaultValue
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
newtype FeatureFlags = FeatureFlags {getFeatureFlags :: HashMap Text FeatureFlag}
|
|
|
|
featureFlags :: FeatureFlags
|
|
featureFlags =
|
|
FeatureFlags $
|
|
HashMap.fromList
|
|
[ ("test-flag", testFlag),
|
|
("native-query-interface", nativeQueryInterface)
|
|
]
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
testFlag :: FeatureFlag
|
|
testFlag =
|
|
FeatureFlag
|
|
{ ffIdentifier = Identifier "test-flag",
|
|
ffDefaultValue = False,
|
|
ffDescription = "Testing feature flag integration"
|
|
}
|
|
|
|
nativeQueryInterface :: FeatureFlag
|
|
nativeQueryInterface =
|
|
FeatureFlag
|
|
{ ffIdentifier = Identifier "native-query-interface",
|
|
ffDefaultValue = False,
|
|
ffDescription = "Expose custom views, permissions and advanced SQL functionality via custom queries"
|
|
}
|