{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
module Data.Morpheus.Server.Types.DirectiveDefinitions
( Prefixes (..),
Deprecated (..),
Describe (..),
Rename (..),
DropNamespace (..),
DefaultValue (..),
)
where
import Data.Morpheus.Server.Types.Directives (GQLDirective (..))
import Data.Morpheus.Server.Types.GQLType (GQLType (__type))
import Data.Morpheus.Server.Types.Internal
( mkTypeData,
stripConstructorNamespace,
stripFieldNamespace,
)
import Data.Morpheus.Server.Types.Visitors
( VisitEnum (..),
VisitField (..),
VisitType (..),
)
import Data.Morpheus.Types.Internal.AST (CONST, DirectiveLocation (..), Value)
import Data.Text (drop, length, pack, unpack)
import Relude hiding (drop, length)
data Prefixes = Prefixes
{ Prefixes -> Text
addPrefix :: Text,
Prefixes -> Text
removePrefix :: Text
}
deriving (forall x. Rep Prefixes x -> Prefixes
forall x. Prefixes -> Rep Prefixes x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Prefixes x -> Prefixes
$cfrom :: forall x. Prefixes -> Rep Prefixes x
Generic, forall a.
(forall (f :: * -> *). f a -> DirectiveUsages)
-> (forall (cat :: TypeCategory). CatType cat a -> TypeData)
-> (forall (c :: TypeCategory).
CatType c a -> SchemaT c (TypeDefinition c CONST))
-> (forall (c :: TypeCategory).
CatType c a -> SchemaT c (Maybe (ArgumentsDefinition CONST)))
-> GQLType a
forall (c :: TypeCategory).
CatType c Prefixes -> SchemaT c (Maybe (ArgumentsDefinition CONST))
forall (c :: TypeCategory).
CatType c Prefixes -> SchemaT c (TypeDefinition c CONST)
forall (cat :: TypeCategory). CatType cat Prefixes -> TypeData
forall (f :: * -> *). f Prefixes -> DirectiveUsages
__deriveFieldArguments :: forall (c :: TypeCategory).
CatType c Prefixes -> SchemaT c (Maybe (ArgumentsDefinition CONST))
$c__deriveFieldArguments :: forall (c :: TypeCategory).
CatType c Prefixes -> SchemaT c (Maybe (ArgumentsDefinition CONST))
__deriveType :: forall (c :: TypeCategory).
CatType c Prefixes -> SchemaT c (TypeDefinition c CONST)
$c__deriveType :: forall (c :: TypeCategory).
CatType c Prefixes -> SchemaT c (TypeDefinition c CONST)
__type :: forall (cat :: TypeCategory). CatType cat Prefixes -> TypeData
$c__type :: forall (cat :: TypeCategory). CatType cat Prefixes -> TypeData
directives :: forall (f :: * -> *). f Prefixes -> DirectiveUsages
$cdirectives :: forall (f :: * -> *). f Prefixes -> DirectiveUsages
GQLType)
instance GQLDirective Prefixes where
type
DIRECTIVE_LOCATIONS Prefixes =
'[ 'LOCATION_OBJECT,
'LOCATION_ENUM,
'LOCATION_INPUT_OBJECT,
'LOCATION_UNION,
'LOCATION_SCALAR,
'LOCATION_INTERFACE
]
instance VisitType Prefixes where
visitTypeName :: Prefixes -> Bool -> Text -> Text
visitTypeName Prefixes {Text
addPrefix :: Text
addPrefix :: Prefixes -> Text
addPrefix, Text
removePrefix :: Text
removePrefix :: Prefixes -> Text
removePrefix} Bool
_ Text
name = Text
addPrefix forall a. Semigroup a => a -> a -> a
<> Int -> Text -> Text
drop (Text -> Int
length Text
removePrefix) Text
name
visitTypeDescription :: Prefixes -> Maybe Text -> Maybe Text
visitTypeDescription Prefixes
_ = forall a. a -> a
id
newtype Deprecated = Deprecated
{ Deprecated -> Maybe Text
reason :: Maybe Text
}
deriving
( forall x. Rep Deprecated x -> Deprecated
forall x. Deprecated -> Rep Deprecated x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Deprecated x -> Deprecated
$cfrom :: forall x. Deprecated -> Rep Deprecated x
Generic,
Deprecated -> Maybe Text -> Maybe Text
Deprecated -> Text -> Text
forall a.
(a -> Text -> Text)
-> (a -> Maybe Text -> Maybe Text) -> VisitEnum a
visitEnumDescription :: Deprecated -> Maybe Text -> Maybe Text
$cvisitEnumDescription :: Deprecated -> Maybe Text -> Maybe Text
visitEnumName :: Deprecated -> Text -> Text
$cvisitEnumName :: Deprecated -> Text -> Text
VisitEnum,
Deprecated -> Maybe Text -> Maybe Text
Deprecated -> Maybe (Value CONST) -> Maybe (Value CONST)
Deprecated -> Text -> Text
forall a.
(a -> Text -> Text)
-> (a -> Maybe Text -> Maybe Text)
-> (a -> Maybe (Value CONST) -> Maybe (Value CONST))
-> VisitField a
visitFieldDefaultValue :: Deprecated -> Maybe (Value CONST) -> Maybe (Value CONST)
$cvisitFieldDefaultValue :: Deprecated -> Maybe (Value CONST) -> Maybe (Value CONST)
visitFieldDescription :: Deprecated -> Maybe Text -> Maybe Text
$cvisitFieldDescription :: Deprecated -> Maybe Text -> Maybe Text
visitFieldName :: Deprecated -> Text -> Text
$cvisitFieldName :: Deprecated -> Text -> Text
VisitField
)
instance GQLType Deprecated where
__type :: forall (cat :: TypeCategory). CatType cat Deprecated -> TypeData
__type = forall a. TypeName -> a -> TypeData
mkTypeData TypeName
"deprecated"
instance GQLDirective Deprecated where
type
DIRECTIVE_LOCATIONS Deprecated =
'[ 'LOCATION_FIELD_DEFINITION,
'LOCATION_ENUM_VALUE
]
newtype Describe = Describe {Describe -> Text
text :: Text}
deriving
( forall a.
(forall (f :: * -> *). f a -> DirectiveUsages)
-> (forall (cat :: TypeCategory). CatType cat a -> TypeData)
-> (forall (c :: TypeCategory).
CatType c a -> SchemaT c (TypeDefinition c CONST))
-> (forall (c :: TypeCategory).
CatType c a -> SchemaT c (Maybe (ArgumentsDefinition CONST)))
-> GQLType a
forall (c :: TypeCategory).
CatType c Describe -> SchemaT c (Maybe (ArgumentsDefinition CONST))
forall (c :: TypeCategory).
CatType c Describe -> SchemaT c (TypeDefinition c CONST)
forall (cat :: TypeCategory). CatType cat Describe -> TypeData
forall (f :: * -> *). f Describe -> DirectiveUsages
__deriveFieldArguments :: forall (c :: TypeCategory).
CatType c Describe -> SchemaT c (Maybe (ArgumentsDefinition CONST))
$c__deriveFieldArguments :: forall (c :: TypeCategory).
CatType c Describe -> SchemaT c (Maybe (ArgumentsDefinition CONST))
__deriveType :: forall (c :: TypeCategory).
CatType c Describe -> SchemaT c (TypeDefinition c CONST)
$c__deriveType :: forall (c :: TypeCategory).
CatType c Describe -> SchemaT c (TypeDefinition c CONST)
__type :: forall (cat :: TypeCategory). CatType cat Describe -> TypeData
$c__type :: forall (cat :: TypeCategory). CatType cat Describe -> TypeData
directives :: forall (f :: * -> *). f Describe -> DirectiveUsages
$cdirectives :: forall (f :: * -> *). f Describe -> DirectiveUsages
GQLType,
forall x. Rep Describe x -> Describe
forall x. Describe -> Rep Describe x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Describe x -> Describe
$cfrom :: forall x. Describe -> Rep Describe x
Generic
)
instance GQLDirective Describe where
type
DIRECTIVE_LOCATIONS Describe =
'[ 'LOCATION_ENUM_VALUE,
'LOCATION_FIELD_DEFINITION,
'LOCATION_INPUT_FIELD_DEFINITION,
'LOCATION_OBJECT,
'LOCATION_ENUM,
'LOCATION_INPUT_OBJECT,
'LOCATION_UNION,
'LOCATION_SCALAR,
'LOCATION_INTERFACE,
'LOCATION_ARGUMENT_DEFINITION
]
instance VisitEnum Describe where
visitEnumDescription :: Describe -> Maybe Text -> Maybe Text
visitEnumDescription Describe {Text
text :: Text
text :: Describe -> Text
text} Maybe Text
_ = forall a. a -> Maybe a
Just Text
text
instance VisitField Describe where
visitFieldDescription :: Describe -> Maybe Text -> Maybe Text
visitFieldDescription Describe {Text
text :: Text
text :: Describe -> Text
text} Maybe Text
_ = forall a. a -> Maybe a
Just Text
text
instance VisitType Describe where
visitTypeDescription :: Describe -> Maybe Text -> Maybe Text
visitTypeDescription Describe {Text
text :: Text
text :: Describe -> Text
text} Maybe Text
_ = forall a. a -> Maybe a
Just Text
text
newtype Rename = Rename {Rename -> Text
newName :: Text}
deriving
( forall x. Rep Rename x -> Rename
forall x. Rename -> Rep Rename x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Rename x -> Rename
$cfrom :: forall x. Rename -> Rep Rename x
Generic,
forall a.
(forall (f :: * -> *). f a -> DirectiveUsages)
-> (forall (cat :: TypeCategory). CatType cat a -> TypeData)
-> (forall (c :: TypeCategory).
CatType c a -> SchemaT c (TypeDefinition c CONST))
-> (forall (c :: TypeCategory).
CatType c a -> SchemaT c (Maybe (ArgumentsDefinition CONST)))
-> GQLType a
forall (c :: TypeCategory).
CatType c Rename -> SchemaT c (Maybe (ArgumentsDefinition CONST))
forall (c :: TypeCategory).
CatType c Rename -> SchemaT c (TypeDefinition c CONST)
forall (cat :: TypeCategory). CatType cat Rename -> TypeData
forall (f :: * -> *). f Rename -> DirectiveUsages
__deriveFieldArguments :: forall (c :: TypeCategory).
CatType c Rename -> SchemaT c (Maybe (ArgumentsDefinition CONST))
$c__deriveFieldArguments :: forall (c :: TypeCategory).
CatType c Rename -> SchemaT c (Maybe (ArgumentsDefinition CONST))
__deriveType :: forall (c :: TypeCategory).
CatType c Rename -> SchemaT c (TypeDefinition c CONST)
$c__deriveType :: forall (c :: TypeCategory).
CatType c Rename -> SchemaT c (TypeDefinition c CONST)
__type :: forall (cat :: TypeCategory). CatType cat Rename -> TypeData
$c__type :: forall (cat :: TypeCategory). CatType cat Rename -> TypeData
directives :: forall (f :: * -> *). f Rename -> DirectiveUsages
$cdirectives :: forall (f :: * -> *). f Rename -> DirectiveUsages
GQLType
)
instance GQLDirective Rename where
excludeFromSchema :: forall (f :: * -> *). f Rename -> Bool
excludeFromSchema f Rename
_ = Bool
True
type
DIRECTIVE_LOCATIONS Rename =
'[ 'LOCATION_OBJECT,
'LOCATION_ENUM,
'LOCATION_INPUT_OBJECT,
'LOCATION_UNION,
'LOCATION_SCALAR,
'LOCATION_INTERFACE,
'LOCATION_ENUM_VALUE,
'LOCATION_FIELD_DEFINITION,
'LOCATION_INPUT_FIELD_DEFINITION
]
instance VisitType Rename where
visitTypeName :: Rename -> Bool -> Text -> Text
visitTypeName Rename {Text
newName :: Text
newName :: Rename -> Text
newName} Bool
_ Text
_ = Text
newName
visitTypeDescription :: Rename -> Maybe Text -> Maybe Text
visitTypeDescription Rename
_ = forall a. a -> a
id
instance VisitEnum Rename where
visitEnumName :: Rename -> Text -> Text
visitEnumName Rename {Text
newName :: Text
newName :: Rename -> Text
newName} Text
_ = Text
newName
instance VisitField Rename where
visitFieldName :: Rename -> Text -> Text
visitFieldName Rename {Text
newName :: Text
newName :: Rename -> Text
newName} Text
_ = Text
newName
newtype DropNamespace = DropNamespace
{ DropNamespace -> Text
dropNamespace :: Text
}
deriving
( forall x. Rep DropNamespace x -> DropNamespace
forall x. DropNamespace -> Rep DropNamespace x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DropNamespace x -> DropNamespace
$cfrom :: forall x. DropNamespace -> Rep DropNamespace x
Generic,
forall a.
(forall (f :: * -> *). f a -> DirectiveUsages)
-> (forall (cat :: TypeCategory). CatType cat a -> TypeData)
-> (forall (c :: TypeCategory).
CatType c a -> SchemaT c (TypeDefinition c CONST))
-> (forall (c :: TypeCategory).
CatType c a -> SchemaT c (Maybe (ArgumentsDefinition CONST)))
-> GQLType a
forall (c :: TypeCategory).
CatType c DropNamespace
-> SchemaT c (Maybe (ArgumentsDefinition CONST))
forall (c :: TypeCategory).
CatType c DropNamespace -> SchemaT c (TypeDefinition c CONST)
forall (cat :: TypeCategory). CatType cat DropNamespace -> TypeData
forall (f :: * -> *). f DropNamespace -> DirectiveUsages
__deriveFieldArguments :: forall (c :: TypeCategory).
CatType c DropNamespace
-> SchemaT c (Maybe (ArgumentsDefinition CONST))
$c__deriveFieldArguments :: forall (c :: TypeCategory).
CatType c DropNamespace
-> SchemaT c (Maybe (ArgumentsDefinition CONST))
__deriveType :: forall (c :: TypeCategory).
CatType c DropNamespace -> SchemaT c (TypeDefinition c CONST)
$c__deriveType :: forall (c :: TypeCategory).
CatType c DropNamespace -> SchemaT c (TypeDefinition c CONST)
__type :: forall (cat :: TypeCategory). CatType cat DropNamespace -> TypeData
$c__type :: forall (cat :: TypeCategory). CatType cat DropNamespace -> TypeData
directives :: forall (f :: * -> *). f DropNamespace -> DirectiveUsages
$cdirectives :: forall (f :: * -> *). f DropNamespace -> DirectiveUsages
GQLType
)
instance GQLDirective DropNamespace where
type
DIRECTIVE_LOCATIONS DropNamespace =
'[ 'LOCATION_OBJECT,
'LOCATION_ENUM,
'LOCATION_INPUT_OBJECT,
'LOCATION_UNION,
'LOCATION_SCALAR,
'LOCATION_INTERFACE
]
excludeFromSchema :: forall (f :: * -> *). f DropNamespace -> Bool
excludeFromSchema f DropNamespace
_ = Bool
True
instance VisitType DropNamespace where
visitFieldNames :: DropNamespace -> Text -> Text
visitFieldNames DropNamespace {Text
dropNamespace :: Text
dropNamespace :: DropNamespace -> Text
dropNamespace} = String -> Text
pack forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> String -> String
stripFieldNamespace Text
dropNamespace forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> String
unpack
visitEnumNames :: DropNamespace -> Text -> Text
visitEnumNames DropNamespace {Text
dropNamespace :: Text
dropNamespace :: DropNamespace -> Text
dropNamespace} = String -> Text
pack forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> String -> String
stripConstructorNamespace Text
dropNamespace forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> String
unpack
newtype DefaultValue = DefaultValue
{ DefaultValue -> Value CONST
defaultValue :: Value CONST
}
deriving
( forall x. Rep DefaultValue x -> DefaultValue
forall x. DefaultValue -> Rep DefaultValue x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DefaultValue x -> DefaultValue
$cfrom :: forall x. DefaultValue -> Rep DefaultValue x
Generic,
forall a.
(forall (f :: * -> *). f a -> DirectiveUsages)
-> (forall (cat :: TypeCategory). CatType cat a -> TypeData)
-> (forall (c :: TypeCategory).
CatType c a -> SchemaT c (TypeDefinition c CONST))
-> (forall (c :: TypeCategory).
CatType c a -> SchemaT c (Maybe (ArgumentsDefinition CONST)))
-> GQLType a
forall (c :: TypeCategory).
CatType c DefaultValue
-> SchemaT c (Maybe (ArgumentsDefinition CONST))
forall (c :: TypeCategory).
CatType c DefaultValue -> SchemaT c (TypeDefinition c CONST)
forall (cat :: TypeCategory). CatType cat DefaultValue -> TypeData
forall (f :: * -> *). f DefaultValue -> DirectiveUsages
__deriveFieldArguments :: forall (c :: TypeCategory).
CatType c DefaultValue
-> SchemaT c (Maybe (ArgumentsDefinition CONST))
$c__deriveFieldArguments :: forall (c :: TypeCategory).
CatType c DefaultValue
-> SchemaT c (Maybe (ArgumentsDefinition CONST))
__deriveType :: forall (c :: TypeCategory).
CatType c DefaultValue -> SchemaT c (TypeDefinition c CONST)
$c__deriveType :: forall (c :: TypeCategory).
CatType c DefaultValue -> SchemaT c (TypeDefinition c CONST)
__type :: forall (cat :: TypeCategory). CatType cat DefaultValue -> TypeData
$c__type :: forall (cat :: TypeCategory). CatType cat DefaultValue -> TypeData
directives :: forall (f :: * -> *). f DefaultValue -> DirectiveUsages
$cdirectives :: forall (f :: * -> *). f DefaultValue -> DirectiveUsages
GQLType
)
instance GQLDirective DefaultValue where
type DIRECTIVE_LOCATIONS DefaultValue = '[ 'LOCATION_INPUT_FIELD_DEFINITION]
excludeFromSchema :: forall (f :: * -> *). f DefaultValue -> Bool
excludeFromSchema f DefaultValue
_ = Bool
True
instance VisitField DefaultValue where
visitFieldDefaultValue :: DefaultValue -> Maybe (Value CONST) -> Maybe (Value CONST)
visitFieldDefaultValue DefaultValue {Value CONST
defaultValue :: Value CONST
defaultValue :: DefaultValue -> Value CONST
defaultValue} Maybe (Value CONST)
_ = forall a. a -> Maybe a
Just Value CONST
defaultValue