{-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveAnyClass #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE DeriveLift #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE NoImplicitPrelude #-} module Data.Morpheus.Types.Internal.AST.OperationType ( OperationType (..), QUERY, MUTATION, SUBSCRIPTION, toOperationType, isOperationType, ) where import Data.Morpheus.Rendering.RenderGQL ( RenderGQL (..), ) import Data.Morpheus.Types.Internal.AST.Error (Msg (..)) import Data.Morpheus.Types.Internal.AST.Name (TypeName) import Language.Haskell.TH.Syntax ( Lift, ) import Relude hiding ( ByteString, Show, decodeUtf8, intercalate, show, ) import Prelude (Show (..)) type QUERY = 'OPERATION_QUERY type MUTATION = 'OPERATION_MUTATION type SUBSCRIPTION = 'OPERATION_SUBSCRIPTION data OperationType = OPERATION_QUERY | OPERATION_SUBSCRIPTION | OPERATION_MUTATION deriving ( OperationType -> OperationType -> Bool forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a /= :: OperationType -> OperationType -> Bool $c/= :: OperationType -> OperationType -> Bool == :: OperationType -> OperationType -> Bool $c== :: OperationType -> OperationType -> Bool Eq, forall t. (forall (m :: * -> *). Quote m => t -> m Exp) -> (forall (m :: * -> *). Quote m => t -> Code m t) -> Lift t forall (m :: * -> *). Quote m => OperationType -> m Exp forall (m :: * -> *). Quote m => OperationType -> Code m OperationType liftTyped :: forall (m :: * -> *). Quote m => OperationType -> Code m OperationType $cliftTyped :: forall (m :: * -> *). Quote m => OperationType -> Code m OperationType lift :: forall (m :: * -> *). Quote m => OperationType -> m Exp $clift :: forall (m :: * -> *). Quote m => OperationType -> m Exp Lift, forall x. Rep OperationType x -> OperationType forall x. OperationType -> Rep OperationType x forall a. (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a $cto :: forall x. Rep OperationType x -> OperationType $cfrom :: forall x. OperationType -> Rep OperationType x Generic, Eq OperationType Int -> OperationType -> Int OperationType -> Int forall a. Eq a -> (Int -> a -> Int) -> (a -> Int) -> Hashable a hash :: OperationType -> Int $chash :: OperationType -> Int hashWithSalt :: Int -> OperationType -> Int $chashWithSalt :: Int -> OperationType -> Int Hashable, Int -> OperationType -> ShowS [OperationType] -> ShowS OperationType -> String forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a showList :: [OperationType] -> ShowS $cshowList :: [OperationType] -> ShowS show :: OperationType -> String $cshow :: OperationType -> String showsPrec :: Int -> OperationType -> ShowS $cshowsPrec :: Int -> OperationType -> ShowS Show ) instance RenderGQL OperationType where renderGQL :: OperationType -> Rendering renderGQL OperationType OPERATION_QUERY = Rendering "query" renderGQL OperationType OPERATION_MUTATION = Rendering "mutation" renderGQL OperationType OPERATION_SUBSCRIPTION = Rendering "subscription" isOperationType :: OperationType -> TypeName -> Bool isOperationType :: OperationType -> TypeName -> Bool isOperationType OperationType OPERATION_QUERY TypeName "Query" = Bool True isOperationType OperationType OPERATION_MUTATION TypeName "Mutation" = Bool True isOperationType OperationType OPERATION_SUBSCRIPTION TypeName "Subscription" = Bool True isOperationType OperationType _ TypeName _ = Bool False {-# INLINE isOperationType #-} toOperationType :: TypeName -> Maybe OperationType toOperationType :: TypeName -> Maybe OperationType toOperationType TypeName "Subscription" = forall a. a -> Maybe a Just OperationType OPERATION_SUBSCRIPTION toOperationType TypeName "Mutation" = forall a. a -> Maybe a Just OperationType OPERATION_MUTATION toOperationType TypeName "Query" = forall a. a -> Maybe a Just OperationType OPERATION_QUERY toOperationType TypeName _ = forall a. Maybe a Nothing {-# INLINE toOperationType #-} instance Msg OperationType where msg :: OperationType -> GQLError msg OperationType OPERATION_QUERY = forall a. Msg a => a -> GQLError msg (TypeName "query" :: TypeName) msg OperationType OPERATION_MUTATION = forall a. Msg a => a -> GQLError msg (TypeName "mutation" :: TypeName) msg OperationType OPERATION_SUBSCRIPTION = forall a. Msg a => a -> GQLError msg (TypeName "subscription" :: TypeName)