mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-17 20:41:49 +03:00
c209b60239
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5329 GitOrigin-RevId: 5cf492bc2b09fef6250f4dd50f74f750f55ebe6a
34 lines
859 B
Haskell
34 lines
859 B
Haskell
module Hasura.Backends.DataConnector.IR.Function
|
|
( Name (..),
|
|
)
|
|
where
|
|
|
|
import Data.Aeson (FromJSON, ToJSON, ToJSONKey (..))
|
|
import Data.Aeson.Types (toJSONKeyText)
|
|
import Data.List.NonEmpty qualified as NonEmpty
|
|
import Data.Text qualified as Text
|
|
import Data.Text.Extended (ToTxt (..))
|
|
import Hasura.Base.ErrorValue qualified as ErrorValue
|
|
import Hasura.Base.ToErrorValue
|
|
import Hasura.Incremental (Cacheable)
|
|
import Hasura.Prelude
|
|
|
|
newtype Name = Name {unName :: NonEmpty Text}
|
|
deriving stock (Data, Eq, Generic, Ord, Show)
|
|
deriving newtype
|
|
( Cacheable,
|
|
FromJSON,
|
|
Hashable,
|
|
NFData,
|
|
ToJSON
|
|
)
|
|
|
|
instance ToJSONKey Name where
|
|
toJSONKey = toJSONKeyText toTxt
|
|
|
|
instance ToTxt Name where
|
|
toTxt = Text.intercalate "." . NonEmpty.toList . unName
|
|
|
|
instance ToErrorValue Name where
|
|
toErrorValue = ErrorValue.squote . toTxt
|