mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-17 12:31:52 +03:00
f7a202a363
This will implement BigQuery support. Co-authored-by: Antoine Leblanc <1618949+nicuveo@users.noreply.github.com> Co-authored-by: Sibi Prabakaran <737477+psibi@users.noreply.github.com> Co-authored-by: Aniket Deshpande <922486+aniketd@users.noreply.github.com> Co-authored-by: Vamshi Surabhi <6562944+0x777@users.noreply.github.com> GitOrigin-RevId: 1a6ffaf34233e13e8125a5c908eaa7e32d65007b
41 lines
1.2 KiB
Haskell
41 lines
1.2 KiB
Haskell
module Hasura.SQL.Backend
|
|
( BackendType(..)
|
|
, supportedBackends
|
|
) where
|
|
|
|
import Hasura.Prelude
|
|
|
|
import Data.Aeson
|
|
import Data.Text (unpack)
|
|
import Data.Text.Extended
|
|
|
|
|
|
-- | An enum that represents each backend we support.
|
|
-- This type MUST be an enumeration (an enumeration consists of one or
|
|
-- more nullary, non-GADT constructors).
|
|
data BackendType
|
|
= Postgres
|
|
| MSSQL
|
|
| BigQuery
|
|
deriving (Eq, Ord, Bounded, Enum)
|
|
|
|
-- | The name of the backend, as we expect it to appear in our metadata and API.
|
|
instance ToTxt BackendType where
|
|
toTxt Postgres = "postgres"
|
|
toTxt MSSQL = "mssql"
|
|
toTxt BigQuery = "bigquery"
|
|
|
|
-- | The FromJSON instance uses this lookup mechanism to avoid having
|
|
-- to duplicate and hardcode the backend string.
|
|
instance FromJSON BackendType where
|
|
parseJSON = withText "backend type" \name ->
|
|
lookup name [(toTxt b, b) | b <- supportedBackends]
|
|
`onNothing` fail ("got: " <> unpack name <> ", expected one of: " <> unpack (commaSeparated supportedBackends))
|
|
|
|
instance ToJSON BackendType where
|
|
toJSON = String . toTxt
|
|
|
|
|
|
supportedBackends :: [BackendType]
|
|
supportedBackends = [minBound @BackendType .. maxBound]
|