mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-18 13:02:11 +03:00
94331e23f5
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3924 GitOrigin-RevId: 75b276edcd2d1f88bbdbed1b96b08708f9c68450
50 lines
1.3 KiB
Haskell
50 lines
1.3 KiB
Haskell
{-# LANGUAGE DeriveAnyClass #-}
|
|
|
|
--
|
|
module Hasura.Backends.DataWrapper.API.V0.Column
|
|
( ColumnInfo (..),
|
|
ColumnName (..),
|
|
)
|
|
where
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
import Data.Aeson (FromJSON, ToJSON)
|
|
import Data.Aeson qualified as J
|
|
import Data.Aeson.Casing (snakeCase)
|
|
import Hasura.Backends.DataWrapper.API.V0.Scalar.Type qualified as API.V0.Scalar
|
|
import Hasura.Incremental (Cacheable)
|
|
import Hasura.Prelude
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
newtype ColumnName = ColumnName Text
|
|
deriving stock (Eq, Ord, Show, Generic, Data)
|
|
deriving newtype (FromJSON, ToJSON)
|
|
deriving anyclass (NFData, Cacheable, Hashable)
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
data ColumnInfo = ColumnInfo
|
|
{ dciName :: ColumnName,
|
|
dciType :: API.V0.Scalar.Type,
|
|
dciNullable :: Bool,
|
|
dciDescription :: Maybe Text
|
|
}
|
|
deriving stock (Eq, Ord, Show, Generic, Data)
|
|
deriving anyclass (NFData, Cacheable, Hashable)
|
|
|
|
instance ToJSON ColumnInfo where
|
|
toJSON =
|
|
J.genericToJSON $
|
|
J.defaultOptions
|
|
{ J.fieldLabelModifier = snakeCase . drop 3
|
|
}
|
|
|
|
instance FromJSON ColumnInfo where
|
|
parseJSON =
|
|
J.genericParseJSON $
|
|
J.defaultOptions
|
|
{ J.fieldLabelModifier = snakeCase . drop 3
|
|
}
|