| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Data.Morpheus.Types
Description
GQL Types
Synopsis
- data Event e c = Event {}
- class ToValue (KIND a) => GQLType a where
- type KIND a :: GQL_KIND
- implements :: f a -> [SchemaT TypeName]
- description :: f a -> Maybe Text
- class GQLScalar a where
- parseValue :: ScalarValue -> Either Text a
- serialize :: a -> ScalarValue
- data GQLRequest = GQLRequest {}
- data GQLResponse
- = Data ValidValue
- | Errors [GQLError]
- newtype ID = ID {}
- data ScalarValue
- data RootResolver (m :: * -> *) event (query :: (* -> *) -> *) (mut :: (* -> *) -> *) (sub :: (* -> *) -> *) = RootResolver {
- queryResolver :: query (Resolver QUERY event m)
- mutationResolver :: mut (Resolver MUTATION event m)
- subscriptionResolver :: sub (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 :: * -> *) = Undefined
- 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), Failure Message (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 :: (Monad m, Event channel cont ~ e) => channel -> Resolver QUERY e m (e -> Resolver SUBSCRIPTION e m a) -> SubscriptionField (Resolver SUBSCRIPTION e m a)
- unsafeInternalContext :: (Monad m, LiftOperation o) => Resolver o e m ResolverContext
- data ResolverContext = ResolverContext {}
- data Input (api :: API)
- type WS = WS
- type HTTP = HTTP
- 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
- interface :: (GQLType a, DeriveType OUT a) => Proxy a -> SchemaT TypeName
- data SubscriptionField a
- data App event (m :: Type -> Type)
- class RenderGQL a where
- render :: a -> Rendering
- data GQLTypeOptions = GQLTypeOptions {
- fieldLabelModifier :: String -> String
- constructorTagModifier :: String -> String
Documentation
class ToValue (KIND a) => 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 ..."
Minimal complete definition
Nothing
Instances
GraphQL Scalar
parseValue and serialize should be provided for every instances manually
Methods
parseValue :: ScalarValue -> Either Text a #
value parsing and validating
for exhaustive pattern matching should be handled all scalar types : ScalarValue, ScalarValue, String, Boolean
invalid values can be reported with Left constructor :
parseValue String _ = Left "" -- without error message -- or parseValue String _ = Left "Error Message"
serialize :: a -> ScalarValue #
serialization of haskell type into scalar value
Instances
| GQLScalar Bool | |
Defined in Data.Morpheus.Types.GQLScalar Methods parseValue :: ScalarValue -> Either Text Bool # serialize :: Bool -> ScalarValue # scalarValidator :: f Bool -> ScalarDefinition # | |
| GQLScalar Float | |
Defined in Data.Morpheus.Types.GQLScalar Methods parseValue :: ScalarValue -> Either Text Float # serialize :: Float -> ScalarValue # scalarValidator :: f Float -> ScalarDefinition # | |
| GQLScalar Int | |
Defined in Data.Morpheus.Types.GQLScalar Methods parseValue :: ScalarValue -> Either Text Int # serialize :: Int -> ScalarValue # scalarValidator :: f Int -> ScalarDefinition # | |
| GQLScalar Text | |
Defined in Data.Morpheus.Types.GQLScalar Methods parseValue :: ScalarValue -> Either Text Text # serialize :: Text -> ScalarValue # scalarValidator :: f Text -> ScalarDefinition # | |
| GQLScalar ID | |
Defined in Data.Morpheus.Types.ID Methods parseValue :: ScalarValue -> Either Text ID # serialize :: ID -> ScalarValue # scalarValidator :: f ID -> ScalarDefinition # | |
data GQLRequest #
GraphQL HTTP Request Body
Constructors
| GQLRequest | |
Instances
data GQLResponse #
GraphQL Response
Constructors
| Data ValidValue | |
| Errors [GQLError] |
Instances
Instances
| Eq ID | |
| Show ID | |
| Generic ID | |
| ToJSON ID | |
Defined in Data.Morpheus.Types.ID | |
| FromJSON ID | |
| GQLScalar ID | |
Defined in Data.Morpheus.Types.ID Methods parseValue :: ScalarValue -> Either Text ID # serialize :: ID -> ScalarValue # scalarValidator :: f ID -> ScalarDefinition # | |
| GQLType ID Source # | |
Defined in Data.Morpheus.Server.Types.GQLType Methods implements :: f ID -> [SchemaT TypeName] Source # isObjectKind :: f ID -> Bool description :: f ID -> Maybe Text Source # getDescriptions :: f ID -> Map Text Description typeOptions :: f ID -> GQLTypeOptions getDirectives :: f ID -> Map Text (Directives CONST) getFieldContents :: f ID -> Map FieldName (Maybe (Value CONST), Maybe (ArgumentsDefinition CONST)) isEmptyType :: f ID -> Bool | |
| type Rep ID | |
Defined in Data.Morpheus.Types.ID | |
| type KIND ID Source # | |
Defined in Data.Morpheus.Server.Types.GQLType | |
data ScalarValue #
Primitive Values for GQLScalar: ScalarValue, ScalarValue, String, Boolean.
for performance reason type Text represents GraphQl String value
Instances
data RootResolver (m :: * -> *) event (query :: (* -> *) -> *) (mut :: (* -> *) -> *) (sub :: (* -> *) -> *) 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.
Constructors
| RootResolver | |
Fields
| |
constMutRes :: Monad m => [e] -> a -> args -> ResolverM e m a Source #
data Undefined (m :: * -> *) Source #
Constructors
| Undefined |
Instances
| Show (Undefined m) Source # | |
| Generic (Undefined m) Source # | |
| Typeable m => GQLType (Undefined m) Source # | |
Defined in Data.Morpheus.Server.Types.GQLType Methods implements :: f (Undefined m) -> [SchemaT TypeName] Source # isObjectKind :: f (Undefined m) -> Bool description :: f (Undefined m) -> Maybe Text Source # getDescriptions :: f (Undefined m) -> Map Text Description typeOptions :: f (Undefined m) -> GQLTypeOptions getDirectives :: f (Undefined m) -> Map Text (Directives CONST) getFieldContents :: f (Undefined m) -> Map FieldName (Maybe (Value CONST), Maybe (ArgumentsDefinition CONST)) isEmptyType :: f (Undefined m) -> Bool | |
| type Rep (Undefined m) Source # | |
| 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), Failure Message (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 :: (Monad m, Event channel cont ~ e) => channel -> Resolver QUERY e m (e -> Resolver SUBSCRIPTION e m a) -> SubscriptionField (Resolver SUBSCRIPTION e m a) #
unsafeInternalContext :: (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 expposes 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 #
Constructors
| ResolverContext | |
Instances
| Show ResolverContext | |
Defined in Data.Morpheus.Types.Internal.Resolving.ResolverState Methods showsPrec :: Int -> ResolverContext -> ShowS # show :: ResolverContext -> String # showList :: [ResolverContext] -> ShowS # | |
| Monad m => MonadReader ResolverContext (ResolverStateT event m) | |
Defined in Data.Morpheus.Types.Internal.Resolving.ResolverState Methods 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.Types.Internal.Resolving.Resolver Methods 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
| GQLType a => GQLType (SubscriptionField a) Source # | |
Defined in Data.Morpheus.Server.Types.GQLType Associated Types type KIND (SubscriptionField a) :: GQL_KIND Source # Methods implements :: f (SubscriptionField a) -> [SchemaT TypeName] Source # isObjectKind :: f (SubscriptionField a) -> Bool description :: f (SubscriptionField a) -> Maybe Text Source # getDescriptions :: f (SubscriptionField a) -> Map Text Description typeOptions :: f (SubscriptionField a) -> GQLTypeOptions getDirectives :: f (SubscriptionField a) -> Map Text (Directives CONST) getFieldContents :: f (SubscriptionField a) -> Map FieldName (Maybe (Value CONST), Maybe (ArgumentsDefinition CONST)) isEmptyType :: f (SubscriptionField a) -> Bool __type :: f (SubscriptionField a) -> TypeData | |
| type KIND (SubscriptionField a) Source # | |
Defined in Data.Morpheus.Server.Types.GQLType | |
Instances
data GQLTypeOptions Source #
Constructors
| GQLTypeOptions | |
Fields
| |