{-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveAnyClass #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE DeriveLift #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE NoImplicitPrelude #-} module Data.Morpheus.Types.Internal.AST.OperationType ( OperationType (..), QUERY, MUTATION, SUBSCRIPTION, toOperationType, ) where import Data.Char (toLower) 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, decodeUtf8, intercalate, ) type QUERY = 'Query type MUTATION = 'Mutation type SUBSCRIPTION = 'Subscription data OperationType = Query | Subscription | Mutation deriving ( Int -> OperationType -> ShowS [OperationType] -> ShowS OperationType -> String (Int -> OperationType -> ShowS) -> (OperationType -> String) -> ([OperationType] -> ShowS) -> Show OperationType 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, OperationType -> OperationType -> Bool (OperationType -> OperationType -> Bool) -> (OperationType -> OperationType -> Bool) -> Eq OperationType 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, OperationType -> Q Exp OperationType -> Q (TExp OperationType) (OperationType -> Q Exp) -> (OperationType -> Q (TExp OperationType)) -> Lift OperationType forall t. (t -> Q Exp) -> (t -> Q (TExp t)) -> Lift t liftTyped :: OperationType -> Q (TExp OperationType) $cliftTyped :: OperationType -> Q (TExp OperationType) lift :: OperationType -> Q Exp $clift :: OperationType -> Q Exp Lift, (forall x. OperationType -> Rep OperationType x) -> (forall x. Rep OperationType x -> OperationType) -> Generic OperationType 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, Int -> OperationType -> Int OperationType -> Int (Int -> OperationType -> Int) -> (OperationType -> Int) -> Hashable OperationType forall a. (Int -> a -> Int) -> (a -> Int) -> Hashable a hash :: OperationType -> Int $chash :: OperationType -> Int hashWithSalt :: Int -> OperationType -> Int $chashWithSalt :: Int -> OperationType -> Int Hashable ) instance RenderGQL OperationType where renderGQL :: OperationType -> Rendering renderGQL = String -> Rendering forall a. IsString a => String -> a fromString (String -> Rendering) -> (OperationType -> String) -> OperationType -> Rendering forall b c a. (b -> c) -> (a -> b) -> a -> c . (Char -> Char) -> ShowS forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b fmap Char -> Char toLower ShowS -> (OperationType -> String) -> OperationType -> String forall b c a. (b -> c) -> (a -> b) -> a -> c . OperationType -> String forall b a. (Show a, IsString b) => a -> b show toOperationType :: TypeName -> Maybe OperationType toOperationType :: TypeName -> Maybe OperationType toOperationType TypeName "Subscription" = OperationType -> Maybe OperationType forall a. a -> Maybe a Just OperationType Subscription toOperationType TypeName "Mutation" = OperationType -> Maybe OperationType forall a. a -> Maybe a Just OperationType Mutation toOperationType TypeName "Query" = OperationType -> Maybe OperationType forall a. a -> Maybe a Just OperationType Query toOperationType TypeName _ = Maybe OperationType forall a. Maybe a Nothing {-# INLINE toOperationType #-} instance Msg OperationType where msg :: OperationType -> GQLError msg OperationType Query = TypeName -> GQLError forall a. Msg a => a -> GQLError msg (TypeName "query" :: TypeName) msg OperationType Mutation = TypeName -> GQLError forall a. Msg a => a -> GQLError msg (TypeName "mutation" :: TypeName) msg OperationType Subscription = TypeName -> GQLError forall a. Msg a => a -> GQLError msg (TypeName "subscription" :: TypeName)