mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-15 17:31:56 +03:00
4885a3fd9a
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8948 GitOrigin-RevId: d70c4a50b94ffe7d42a1fb1017051d351f236acc
27 lines
563 B
Haskell
27 lines
563 B
Haskell
module Hasura.SQL.Value
|
|
( TxtEncodedVal (..),
|
|
)
|
|
where
|
|
|
|
import Data.Aeson qualified as J
|
|
import Data.Aeson.Types qualified as AT
|
|
import Data.Text qualified as T
|
|
import Hasura.Prelude
|
|
|
|
data TxtEncodedVal
|
|
= TENull
|
|
| TELit !T.Text
|
|
deriving (Show, Eq, Generic)
|
|
|
|
instance Hashable TxtEncodedVal
|
|
|
|
instance J.ToJSON TxtEncodedVal where
|
|
toJSON = \case
|
|
TENull -> AT.Null
|
|
TELit t -> AT.String t
|
|
|
|
instance J.FromJSON TxtEncodedVal where
|
|
parseJSON J.Null = pure TENull
|
|
parseJSON (J.String t) = pure $ TELit t
|
|
parseJSON v = AT.typeMismatch "String" v
|