-- | A name for a native query as it is recognized by the graphql schema.
module Hasura.NativeQuery.Types
  ( NativeQueryName (..),
    NullableScalarType (..),
  )
where

import Autodocodec (HasCodec (codec), dimapCodec)
import Data.Aeson (FromJSON, FromJSONKey, ToJSON, ToJSONKey)
import Data.Text.Extended (ToTxt)
import Hasura.LogicalModel.NullableScalarType
import Hasura.Prelude hiding (first)
import Language.GraphQL.Draft.Syntax qualified as G
import Language.Haskell.TH.Syntax (Lift)

-- The name of a native query. This appears as a root field name in the graphql schema.
newtype NativeQueryName = NativeQueryName {NativeQueryName -> Name
getNativeQueryName :: G.Name}
  deriving newtype (NativeQueryName -> NativeQueryName -> Bool
(NativeQueryName -> NativeQueryName -> Bool)
-> (NativeQueryName -> NativeQueryName -> Bool)
-> Eq NativeQueryName
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: NativeQueryName -> NativeQueryName -> Bool
== :: NativeQueryName -> NativeQueryName -> Bool
$c/= :: NativeQueryName -> NativeQueryName -> Bool
/= :: NativeQueryName -> NativeQueryName -> Bool
Eq, Eq NativeQueryName
Eq NativeQueryName
-> (NativeQueryName -> NativeQueryName -> Ordering)
-> (NativeQueryName -> NativeQueryName -> Bool)
-> (NativeQueryName -> NativeQueryName -> Bool)
-> (NativeQueryName -> NativeQueryName -> Bool)
-> (NativeQueryName -> NativeQueryName -> Bool)
-> (NativeQueryName -> NativeQueryName -> NativeQueryName)
-> (NativeQueryName -> NativeQueryName -> NativeQueryName)
-> Ord NativeQueryName
NativeQueryName -> NativeQueryName -> Bool
NativeQueryName -> NativeQueryName -> Ordering
NativeQueryName -> NativeQueryName -> NativeQueryName
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: NativeQueryName -> NativeQueryName -> Ordering
compare :: NativeQueryName -> NativeQueryName -> Ordering
$c< :: NativeQueryName -> NativeQueryName -> Bool
< :: NativeQueryName -> NativeQueryName -> Bool
$c<= :: NativeQueryName -> NativeQueryName -> Bool
<= :: NativeQueryName -> NativeQueryName -> Bool
$c> :: NativeQueryName -> NativeQueryName -> Bool
> :: NativeQueryName -> NativeQueryName -> Bool
$c>= :: NativeQueryName -> NativeQueryName -> Bool
>= :: NativeQueryName -> NativeQueryName -> Bool
$cmax :: NativeQueryName -> NativeQueryName -> NativeQueryName
max :: NativeQueryName -> NativeQueryName -> NativeQueryName
$cmin :: NativeQueryName -> NativeQueryName -> NativeQueryName
min :: NativeQueryName -> NativeQueryName -> NativeQueryName
Ord, Int -> NativeQueryName -> ShowS
[NativeQueryName] -> ShowS
NativeQueryName -> String
(Int -> NativeQueryName -> ShowS)
-> (NativeQueryName -> String)
-> ([NativeQueryName] -> ShowS)
-> Show NativeQueryName
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> NativeQueryName -> ShowS
showsPrec :: Int -> NativeQueryName -> ShowS
$cshow :: NativeQueryName -> String
show :: NativeQueryName -> String
$cshowList :: [NativeQueryName] -> ShowS
showList :: [NativeQueryName] -> ShowS
Show, Eq NativeQueryName
Eq NativeQueryName
-> (Int -> NativeQueryName -> Int)
-> (NativeQueryName -> Int)
-> Hashable NativeQueryName
Int -> NativeQueryName -> Int
NativeQueryName -> Int
forall a. Eq a -> (Int -> a -> Int) -> (a -> Int) -> Hashable a
$chashWithSalt :: Int -> NativeQueryName -> Int
hashWithSalt :: Int -> NativeQueryName -> Int
$chash :: NativeQueryName -> Int
hash :: NativeQueryName -> Int
Hashable, NativeQueryName -> ()
(NativeQueryName -> ()) -> NFData NativeQueryName
forall a. (a -> ()) -> NFData a
$crnf :: NativeQueryName -> ()
rnf :: NativeQueryName -> ()
NFData, [NativeQueryName] -> Value
[NativeQueryName] -> Encoding
NativeQueryName -> Value
NativeQueryName -> Encoding
(NativeQueryName -> Value)
-> (NativeQueryName -> Encoding)
-> ([NativeQueryName] -> Value)
-> ([NativeQueryName] -> Encoding)
-> ToJSON NativeQueryName
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
$ctoJSON :: NativeQueryName -> Value
toJSON :: NativeQueryName -> Value
$ctoEncoding :: NativeQueryName -> Encoding
toEncoding :: NativeQueryName -> Encoding
$ctoJSONList :: [NativeQueryName] -> Value
toJSONList :: [NativeQueryName] -> Value
$ctoEncodingList :: [NativeQueryName] -> Encoding
toEncodingList :: [NativeQueryName] -> Encoding
ToJSON, Value -> Parser [NativeQueryName]
Value -> Parser NativeQueryName
(Value -> Parser NativeQueryName)
-> (Value -> Parser [NativeQueryName]) -> FromJSON NativeQueryName
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
$cparseJSON :: Value -> Parser NativeQueryName
parseJSON :: Value -> Parser NativeQueryName
$cparseJSONList :: Value -> Parser [NativeQueryName]
parseJSONList :: Value -> Parser [NativeQueryName]
FromJSON, NativeQueryName -> Text
(NativeQueryName -> Text) -> ToTxt NativeQueryName
forall a. (a -> Text) -> ToTxt a
$ctoTxt :: NativeQueryName -> Text
toTxt :: NativeQueryName -> Text
ToTxt)
  deriving stock (Typeable NativeQueryName
Typeable NativeQueryName
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> NativeQueryName -> c NativeQueryName)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c NativeQueryName)
-> (NativeQueryName -> Constr)
-> (NativeQueryName -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c NativeQueryName))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c NativeQueryName))
-> ((forall b. Data b => b -> b)
    -> NativeQueryName -> NativeQueryName)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> NativeQueryName -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> NativeQueryName -> r)
-> (forall u.
    (forall d. Data d => d -> u) -> NativeQueryName -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> NativeQueryName -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d)
    -> NativeQueryName -> m NativeQueryName)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> NativeQueryName -> m NativeQueryName)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> NativeQueryName -> m NativeQueryName)
-> Data NativeQueryName
NativeQueryName -> Constr
NativeQueryName -> DataType
(forall b. Data b => b -> b) -> NativeQueryName -> NativeQueryName
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u.
Int -> (forall d. Data d => d -> u) -> NativeQueryName -> u
forall u. (forall d. Data d => d -> u) -> NativeQueryName -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> NativeQueryName -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> NativeQueryName -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> NativeQueryName -> m NativeQueryName
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> NativeQueryName -> m NativeQueryName
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c NativeQueryName
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> NativeQueryName -> c NativeQueryName
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c NativeQueryName)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c NativeQueryName)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> NativeQueryName -> c NativeQueryName
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> NativeQueryName -> c NativeQueryName
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c NativeQueryName
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c NativeQueryName
$ctoConstr :: NativeQueryName -> Constr
toConstr :: NativeQueryName -> Constr
$cdataTypeOf :: NativeQueryName -> DataType
dataTypeOf :: NativeQueryName -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c NativeQueryName)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c NativeQueryName)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c NativeQueryName)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c NativeQueryName)
$cgmapT :: (forall b. Data b => b -> b) -> NativeQueryName -> NativeQueryName
gmapT :: (forall b. Data b => b -> b) -> NativeQueryName -> NativeQueryName
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> NativeQueryName -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> NativeQueryName -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> NativeQueryName -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> NativeQueryName -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> NativeQueryName -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> NativeQueryName -> [u]
$cgmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> NativeQueryName -> u
gmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> NativeQueryName -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> NativeQueryName -> m NativeQueryName
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> NativeQueryName -> m NativeQueryName
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> NativeQueryName -> m NativeQueryName
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> NativeQueryName -> m NativeQueryName
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> NativeQueryName -> m NativeQueryName
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> NativeQueryName -> m NativeQueryName
Data, (forall x. NativeQueryName -> Rep NativeQueryName x)
-> (forall x. Rep NativeQueryName x -> NativeQueryName)
-> Generic NativeQueryName
forall x. Rep NativeQueryName x -> NativeQueryName
forall x. NativeQueryName -> Rep NativeQueryName x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. NativeQueryName -> Rep NativeQueryName x
from :: forall x. NativeQueryName -> Rep NativeQueryName x
$cto :: forall x. Rep NativeQueryName x -> NativeQueryName
to :: forall x. Rep NativeQueryName x -> NativeQueryName
Generic, (forall (m :: * -> *). Quote m => NativeQueryName -> m Exp)
-> (forall (m :: * -> *).
    Quote m =>
    NativeQueryName -> Code m NativeQueryName)
-> Lift NativeQueryName
forall t.
(forall (m :: * -> *). Quote m => t -> m Exp)
-> (forall (m :: * -> *). Quote m => t -> Code m t) -> Lift t
forall (m :: * -> *). Quote m => NativeQueryName -> m Exp
forall (m :: * -> *).
Quote m =>
NativeQueryName -> Code m NativeQueryName
$clift :: forall (m :: * -> *). Quote m => NativeQueryName -> m Exp
lift :: forall (m :: * -> *). Quote m => NativeQueryName -> m Exp
$cliftTyped :: forall (m :: * -> *).
Quote m =>
NativeQueryName -> Code m NativeQueryName
liftTyped :: forall (m :: * -> *).
Quote m =>
NativeQueryName -> Code m NativeQueryName
Lift)

instance HasCodec NativeQueryName where
  codec :: JSONCodec NativeQueryName
codec = (Name -> NativeQueryName)
-> (NativeQueryName -> Name)
-> Codec Value Name Name
-> JSONCodec NativeQueryName
forall oldOutput newOutput newInput oldInput context.
(oldOutput -> newOutput)
-> (newInput -> oldInput)
-> Codec context oldInput oldOutput
-> Codec context newInput newOutput
dimapCodec Name -> NativeQueryName
NativeQueryName NativeQueryName -> Name
getNativeQueryName Codec Value Name Name
forall value. HasCodec value => JSONCodec value
codec

instance FromJSONKey NativeQueryName

instance ToJSONKey NativeQueryName