Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
GQL Types
Synopsis
- class GQLType a where
- type KIND a :: DerivingKind
- description :: f a -> Maybe Text
- getDescriptions :: f a -> Map Text Description
- typeOptions :: f a -> GQLTypeOptions -> GQLTypeOptions
- getDirectives :: f a -> Map Text (Directives CONST)
- defaultValues :: f a -> Map Text (Value CONST)
- class EncodeScalar a where
- encodeScalar :: a -> ScalarValue
- class EncodeWrapper (wrapper :: Type -> Type) where
- encodeWrapper :: Monad m => (a -> m (ResolverValue m)) -> wrapper a -> m (ResolverValue m)
- class DecodeScalar a where
- decodeScalar :: ScalarValue -> Either Text a
- class DecodeWrapper (f :: Type -> Type) where
- decodeWrapper :: (Monad m, DecodeWrapperConstraint f a) => (ValidValue -> m a) -> ValidValue -> ExceptT GQLError m (f a)
- data GQLRequest = GQLRequest {}
- data GQLResponse
- = Data ValidValue
- | Errors [GQLError]
- newtype ID = ID {}
- data ScalarValue
- data RootResolver (m :: Type -> Type) event (query :: (Type -> Type) -> Type) (mutation :: (Type -> Type) -> Type) (subscription :: (Type -> Type) -> Type) = RootResolver {
- queryResolver :: query (Resolver QUERY event m)
- mutationResolver :: mutation (Resolver MUTATION event m)
- subscriptionResolver :: subscription (Resolver SUBSCRIPTION event m)
- constRes :: (WithOperation o, Monad m) => b -> a -> Resolver o e m b
- constMutRes :: Monad m => [e] -> a -> args -> ResolverM e m a
- data Undefined (m :: Type -> Type)
- data Resolver (o :: OperationType) event (m :: Type -> Type) value
- type QUERY = 'Query
- type MUTATION = 'Mutation
- type SUBSCRIPTION = 'Subscription
- lift :: (MonadTrans t, Monad m) => m a -> t m a
- liftEither :: (MonadTrans t, Monad (t m), MonadError GQLError (t m)) => Monad m => m (Either String a) -> t m a
- failRes :: (Monad m, WithOperation o) => String -> Resolver o e m a
- type WithOperation (o :: OperationType) = LiftOperation o
- publish :: Monad m => [e] -> Resolver MUTATION e m ()
- subscribe :: forall (m :: Type -> Type) e a. Monad m => Channel e -> Resolver QUERY e m (e -> Resolver SUBSCRIPTION e m a) -> SubscriptionField (Resolver SUBSCRIPTION e m a)
- unsafeInternalContext :: forall (m :: Type -> Type) (o :: OperationType) e. (Monad m, LiftOperation o) => Resolver o e m ResolverContext
- data ResolverContext = ResolverContext {}
- type ResolverO o e m a = WithOperation o => Flexible (Resolver o e m) a
- type ComposedResolver o e m f a = WithOperation o => Composed (Resolver o e m) f a
- type ResolverQ e m a = Flexible (Resolver QUERY e m) a
- type ResolverM e m a = Flexible (Resolver MUTATION e m) a
- type ResolverS e m a = Flexible (Resolver SUBSCRIPTION e m) a
- type ResolveQ e m a = ResolverQ e m a
- type ResolveM e m a = ResolverM e m a
- type ResolveS e m a = ResolverS e m a
- type Res = Resolver QUERY
- type MutRes = Resolver MUTATION
- type SubRes = Resolver SUBSCRIPTION
- type IORes e = Res e IO
- type IOMutRes e = MutRes e IO
- type IOSubRes e = SubRes e IO
- data SubscriptionField a
- data App event (m :: Type -> Type)
- class RenderGQL a
- render :: RenderGQL a => a -> ByteString
- data TypeGuard interface union
- = ResolveInterface interface
- | ResolveType union
- newtype Arg (name :: Symbol) a = Arg {
- argValue :: a
- data NamedResolvers (m :: Type -> Type) event (qu :: (Type -> Type) -> Type) (mu :: (Type -> Type) -> Type) (su :: (Type -> Type) -> Type) = ResolveNamed (Resolver QUERY event m) (qu (NamedResolverT (Resolver QUERY event m))) => NamedResolvers
- data GQLTypeOptions
- defaultTypeOptions :: GQLTypeOptions
- fieldLabelModifier :: GQLTypeOptions -> String -> String
- constructorTagModifier :: GQLTypeOptions -> String -> String
- typeNameModifier :: GQLTypeOptions -> Bool -> String -> String
- defaultRootResolver :: RootResolver m event Undefined Undefined Undefined
Documentation
class GQLType a where Source #
GraphQL type, every graphQL type should have an instance of Generic
and GQLType
.
... deriving (Generic, GQLType)
if you want to add description
... deriving (Generic) instance GQLType ... where description = const "your description ..."
Nothing
description :: f a -> Maybe Text Source #
A description of the type.
Used for documentation in the GraphQL schema.
getDescriptions :: f a -> Map Text Description Source #
A dictionary of descriptions for fields, keyed on field name.
Used for documentation in the GraphQL schema.
typeOptions :: f a -> GQLTypeOptions -> GQLTypeOptions Source #
getDirectives :: f a -> Map Text (Directives CONST) Source #
Instances
class EncodeScalar a where #
GraphQL Scalar Serializer
encodeScalar :: a -> ScalarValue #
Instances
EncodeScalar ID | |
Defined in Data.Morpheus.Types.ID encodeScalar :: ID -> ScalarValue # | |
EncodeScalar Text | |
Defined in Data.Morpheus.Types.GQLScalar encodeScalar :: Text -> ScalarValue # | |
EncodeScalar Bool | |
Defined in Data.Morpheus.Types.GQLScalar encodeScalar :: Bool -> ScalarValue # | |
EncodeScalar Double | |
Defined in Data.Morpheus.Types.GQLScalar encodeScalar :: Double -> ScalarValue # | |
EncodeScalar Float | |
Defined in Data.Morpheus.Types.GQLScalar encodeScalar :: Float -> ScalarValue # | |
EncodeScalar Int | |
Defined in Data.Morpheus.Types.GQLScalar encodeScalar :: Int -> ScalarValue # |
class EncodeWrapper (wrapper :: Type -> Type) where #
GraphQL Wrapper Serializer
encodeWrapper :: Monad m => (a -> m (ResolverValue m)) -> wrapper a -> m (ResolverValue m) #
Instances
class DecodeScalar a where #
GraphQL Scalar parser
decodeScalar :: ScalarValue -> Either Text a #
Instances
DecodeScalar ID | |
Defined in Data.Morpheus.Types.ID decodeScalar :: ScalarValue -> Either Text ID # | |
DecodeScalar Text | |
Defined in Data.Morpheus.Types.GQLScalar decodeScalar :: ScalarValue -> Either Text Text # | |
DecodeScalar Bool | |
Defined in Data.Morpheus.Types.GQLScalar decodeScalar :: ScalarValue -> Either Text Bool # | |
DecodeScalar Double | |
Defined in Data.Morpheus.Types.GQLScalar decodeScalar :: ScalarValue -> Either Text Double # | |
DecodeScalar Float | |
Defined in Data.Morpheus.Types.GQLScalar decodeScalar :: ScalarValue -> Either Text Float # | |
DecodeScalar Int | |
Defined in Data.Morpheus.Types.GQLScalar decodeScalar :: ScalarValue -> Either Text Int # |
class DecodeWrapper (f :: Type -> Type) where #
GraphQL Wrapper Deserializer
decodeWrapper :: (Monad m, DecodeWrapperConstraint f a) => (ValidValue -> m a) -> ValidValue -> ExceptT GQLError m (f a) #
Instances
data GQLRequest #
GraphQL HTTP Request Body
Instances
data GQLResponse #
GraphQL Response
Instances
default GraphQL type,
parses only ScalarValue
and ScalarValue
values,
serialized always as ScalarValue
Instances
data ScalarValue #
Primitive Values for GQLScalar: ScalarValue
, ScalarValue
, ScalarValue
, Boolean
.
for performance reason type Text
represents GraphQl ScalarValue
value
Instances
data RootResolver (m :: Type -> Type) event (query :: (Type -> Type) -> Type) (mutation :: (Type -> Type) -> Type) (subscription :: (Type -> Type) -> Type) Source #
GraphQL Root resolver, also the interpreter generates a GQL schema from it.
queryResolver
is required, mutationResolver
and subscriptionResolver
are optional,
if your schema does not supports mutation or subscription , you can use () for it.
RootResolver | |
|
constMutRes :: Monad m => [e] -> a -> args -> ResolverM e m a Source #
data Undefined (m :: Type -> Type) Source #
Instances
Generic (Undefined m) Source # | |
Show (Undefined m) Source # | |
Typeable m => GQLType (Undefined m) Source # | |
Defined in Data.Morpheus.Server.Types.GQLType type KIND (Undefined m) :: DerivingKind Source # description :: f (Undefined m) -> Maybe Text Source # getDescriptions :: f (Undefined m) -> Map Text Description Source # typeOptions :: f (Undefined m) -> GQLTypeOptions -> GQLTypeOptions Source # getDirectives :: f (Undefined m) -> Map Text (Directives CONST) Source # defaultValues :: f (Undefined m) -> Map Text (Value CONST) Source # __isEmptyType :: f (Undefined m) -> Bool __type :: f (Undefined m) -> TypeCategory -> TypeData | |
type Rep (Undefined m) Source # | |
Defined in Data.Morpheus.Server.Types.Types | |
type KIND (Undefined m) Source # | |
Defined in Data.Morpheus.Server.Types.GQLType |
data Resolver (o :: OperationType) event (m :: Type -> Type) value #
Instances
type SUBSCRIPTION = 'Subscription #
lift :: (MonadTrans t, Monad m) => m a -> t m a #
Lift a computation from the argument monad to the constructed monad.
liftEither :: (MonadTrans t, Monad (t m), MonadError GQLError (t m)) => Monad m => m (Either String a) -> t m a Source #
failRes :: (Monad m, WithOperation o) => String -> Resolver o e m a Source #
Deprecated: use "fail" from MonadFail
type WithOperation (o :: OperationType) = LiftOperation o #
subscribe :: forall (m :: Type -> Type) e a. Monad m => Channel e -> Resolver QUERY e m (e -> Resolver SUBSCRIPTION e m a) -> SubscriptionField (Resolver SUBSCRIPTION e m a) #
unsafeInternalContext :: forall (m :: Type -> Type) (o :: OperationType) e. (Monad m, LiftOperation o) => Resolver o e m ResolverContext #
A function to return the internal ResolverContext
within a resolver's monad.
Using the ResolverContext
itself is unsafe because it exposes internal structures
of the AST, but you can use the Data.Morpheus.Types.SelectionTree typeClass to manipulate
the internal AST with a safe interface.
data ResolverContext #
ResolverContext | |
|
Instances
Show ResolverContext | |
Defined in Data.Morpheus.App.Internal.Resolving.ResolverState showsPrec :: Int -> ResolverContext -> ShowS # show :: ResolverContext -> String # showList :: [ResolverContext] -> ShowS # | |
Monad m => MonadReader ResolverContext (ResolverStateT event m) | |
Defined in Data.Morpheus.App.Internal.Resolving.ResolverState ask :: ResolverStateT event m ResolverContext # local :: (ResolverContext -> ResolverContext) -> ResolverStateT event m a -> ResolverStateT event m a # reader :: (ResolverContext -> a) -> ResolverStateT event m a # | |
(LiftOperation o, Monad m) => MonadReader ResolverContext (Resolver o e m) | |
Defined in Data.Morpheus.App.Internal.Resolving.Resolver ask :: Resolver o e m ResolverContext # local :: (ResolverContext -> ResolverContext) -> Resolver o e m a -> Resolver o e m a # reader :: (ResolverContext -> a) -> Resolver o e m a # |
type ResolverO o e m a = WithOperation o => Flexible (Resolver o e m) a Source #
type ComposedResolver o e m f a = WithOperation o => Composed (Resolver o e m) f a Source #
type ResolverS e m a = Flexible (Resolver SUBSCRIPTION e m) a Source #
type SubRes = Resolver SUBSCRIPTION Source #
Deprecated: use ResolverS
data SubscriptionField a #
Instances
EncodeWrapper SubscriptionField | |
Defined in Data.Morpheus.Types.GQLWrapper encodeWrapper :: Monad m => (a -> m (ResolverValue m)) -> SubscriptionField a -> m (ResolverValue m) # | |
GQLType a => GQLType (SubscriptionField a) Source # | |
Defined in Data.Morpheus.Server.Types.GQLType type KIND (SubscriptionField a) :: DerivingKind Source # description :: f (SubscriptionField a) -> Maybe Text Source # getDescriptions :: f (SubscriptionField a) -> Map Text Description Source # typeOptions :: f (SubscriptionField a) -> GQLTypeOptions -> GQLTypeOptions Source # getDirectives :: f (SubscriptionField a) -> Map Text (Directives CONST) Source # defaultValues :: f (SubscriptionField a) -> Map Text (Value CONST) Source # __isEmptyType :: f (SubscriptionField a) -> Bool __type :: f (SubscriptionField a) -> TypeCategory -> TypeData | |
type KIND (SubscriptionField a) Source # | |
Defined in Data.Morpheus.Server.Types.GQLType |
Instances
render :: RenderGQL a => a -> ByteString #
data TypeGuard interface union Source #
ResolveInterface interface | |
ResolveType union |
Instances
GQLType interface => GQLType (TypeGuard interface possibleTypes) Source # | |
Defined in Data.Morpheus.Server.Types.GQLType type KIND (TypeGuard interface possibleTypes) :: DerivingKind Source # description :: f (TypeGuard interface possibleTypes) -> Maybe Text Source # getDescriptions :: f (TypeGuard interface possibleTypes) -> Map Text Description Source # typeOptions :: f (TypeGuard interface possibleTypes) -> GQLTypeOptions -> GQLTypeOptions Source # getDirectives :: f (TypeGuard interface possibleTypes) -> Map Text (Directives CONST) Source # defaultValues :: f (TypeGuard interface possibleTypes) -> Map Text (Value CONST) Source # __isEmptyType :: f (TypeGuard interface possibleTypes) -> Bool __type :: f (TypeGuard interface possibleTypes) -> TypeCategory -> TypeData | |
type KIND (TypeGuard interface possibleTypes) Source # | |
Defined in Data.Morpheus.Server.Types.GQLType |
newtype Arg (name :: Symbol) a Source #
Instances
Generic (Arg name a) Source # | |
Show a => Show (Arg name a) Source # | |
GQLType value => GQLType (Arg name value) Source # | |
Defined in Data.Morpheus.Server.Types.GQLType type KIND (Arg name value) :: DerivingKind Source # description :: f (Arg name value) -> Maybe Text Source # getDescriptions :: f (Arg name value) -> Map Text Description Source # typeOptions :: f (Arg name value) -> GQLTypeOptions -> GQLTypeOptions Source # getDirectives :: f (Arg name value) -> Map Text (Directives CONST) Source # defaultValues :: f (Arg name value) -> Map Text (Value CONST) Source # __isEmptyType :: f (Arg name value) -> Bool __type :: f (Arg name value) -> TypeCategory -> TypeData | |
type Rep (Arg name a) Source # | |
Defined in Data.Morpheus.Server.Types.Types | |
type KIND (Arg name value) Source # | |
Defined in Data.Morpheus.Server.Types.GQLType |
data NamedResolvers (m :: Type -> Type) event (qu :: (Type -> Type) -> Type) (mu :: (Type -> Type) -> Type) (su :: (Type -> Type) -> Type) Source #
ResolveNamed (Resolver QUERY event m) (qu (NamedResolverT (Resolver QUERY event m))) => NamedResolvers |
GQLType naming configuration
data GQLTypeOptions Source #
Options that specify how to map GraphQL field, type, and constructor names to and from their Haskell equivalent.
Options can be set using record syntax on defaultOptions
with the fields
below.
defaultTypeOptions :: GQLTypeOptions Source #
Default encoding GQLTypeOptions
:
GQLTypeOptions
{fieldLabelModifier
= id ,constructorTagModifier
= id ,typeNameModifier
= const id }
fieldLabelModifier :: GQLTypeOptions -> String -> String Source #
Function applied to field labels. Handy for removing common record prefixes for example.
constructorTagModifier :: GQLTypeOptions -> String -> String Source #
Function applied to constructor tags.
typeNameModifier :: GQLTypeOptions -> Bool -> String -> String Source #
Construct a new type name depending on whether it is an input, and being given the original type name.
defaultRootResolver :: RootResolver m event Undefined Undefined Undefined Source #