Safe Haskell | None |
---|---|
Language | Haskell2010 |
Data.Morpheus.Client
Synopsis
- raw :: QuasiQuoter
- class (RequestType a, ToJSON (Args a), FromJSON a) => Fetch a where
- type Args a
- fetch :: Monad m => (ByteString -> m ByteString) -> Args a -> m (Either (FetchError a) a)
- data FetchError a
- data ScalarValue
- class DecodeScalar a where
- decodeScalar :: ScalarValue -> Either Text a
- class EncodeScalar a where
- encodeScalar :: a -> ScalarValue
- newtype ID = ID {}
- declareGlobalTypes :: FilePath -> Q [Dec]
- declareGlobalTypesByName :: FilePath -> [TypeName] -> Q [Dec]
- declareLocalTypes :: FilePath -> FilePath -> Q [Dec]
- declareLocalTypesInline :: FilePath -> ExecutableSource -> Q [Dec]
- clientTypeDeclarations :: SchemaSource -> Maybe ExecutableSource -> Q [Dec]
- data GQLClient
- type GQLClientResult a = Either (FetchError a) a
- data ResponseStream a
- withHeaders :: GQLClient -> [Header] -> GQLClient
- request :: (ClientTypeConstraint a, MonadFail m) => GQLClient -> Args a -> m (ResponseStream a)
- forEach :: (MonadIO m, MonadUnliftIO m, MonadFail m) => (GQLClientResult a -> m ()) -> ResponseStream a -> m ()
- single :: MonadIO m => ResponseStream a -> m (GQLClientResult a)
- parseClientTypeDeclarations :: SchemaSource -> Maybe Text -> GQLResult ([ClientDeclaration], Flags)
- readSchemaSource :: FilePath -> IO SchemaSource
- data SchemaSource
- class RequestType a where
- type RequestArgs a
- __name :: f a -> FieldName
- __query :: f a -> String
- __type :: f a -> OperationType
Documentation
raw :: QuasiQuoter Source #
QuasiQuoter to insert multiple lines of text in Haskell
class (RequestType a, ToJSON (Args a), FromJSON a) => Fetch a where Source #
Methods
fetch :: Monad m => (ByteString -> m ByteString) -> Args a -> m (Either (FetchError a) a) Source #
Instances
(RequestType a, ToJSON (Args a), FromJSON a) => Fetch a Source # | |||||
Defined in Data.Morpheus.Client.Fetch Associated Types
Methods fetch :: Monad m => (ByteString -> m ByteString) -> Args a -> m (Either (FetchError a) a) Source # |
data FetchError a Source #
Constructors
FetchErrorParseFailure String | |
FetchErrorProducedErrors GQLErrors (Maybe a) | |
FetchErrorNoResult |
Instances
data ScalarValue #
Primitive Values for GQLScalar: Int
, Float
, String
, Boolean
.
for performance reason type Text
represents GraphQl String
value
Instances
FromJSON ScalarValue | |||||
Defined in Data.Morpheus.Types.Internal.AST.Value | |||||
ToJSON ScalarValue | |||||
Defined in Data.Morpheus.Types.Internal.AST.Value Methods toJSON :: ScalarValue -> Value # toEncoding :: ScalarValue -> Encoding # toJSONList :: [ScalarValue] -> Value # toEncodingList :: [ScalarValue] -> Encoding # omitField :: ScalarValue -> Bool # | |||||
IsString ScalarValue | |||||
Defined in Data.Morpheus.Types.Internal.AST.Value Methods fromString :: String -> ScalarValue # | |||||
Generic ScalarValue | |||||
Defined in Data.Morpheus.Types.Internal.AST.Value Associated Types
| |||||
Show ScalarValue | |||||
Defined in Data.Morpheus.Types.Internal.AST.Value Methods showsPrec :: Int -> ScalarValue -> ShowS # show :: ScalarValue -> String # showList :: [ScalarValue] -> ShowS # | |||||
Eq ScalarValue | |||||
Defined in Data.Morpheus.Types.Internal.AST.Value | |||||
RenderGQL ScalarValue | |||||
Defined in Data.Morpheus.Types.Internal.AST.Value Methods renderGQL :: ScalarValue -> Rendering # | |||||
Lift ScalarValue | |||||
Defined in Data.Morpheus.Types.Internal.AST.Value Methods lift :: Quote m => ScalarValue -> m Exp # liftTyped :: forall (m :: Type -> Type). Quote m => ScalarValue -> Code m ScalarValue # | |||||
type Rep ScalarValue | |||||
Defined in Data.Morpheus.Types.Internal.AST.Value type Rep ScalarValue = D1 ('MetaData "ScalarValue" "Data.Morpheus.Types.Internal.AST.Value" "morpheus-graphql-core-0.28.1-9hgXVNa7B3Z1gTIjVWAFjh" 'False) ((C1 ('MetaCons "Int" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int)) :+: C1 ('MetaCons "Float" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Double))) :+: (C1 ('MetaCons "String" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)) :+: (C1 ('MetaCons "Boolean" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool)) :+: C1 ('MetaCons "Value" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Value))))) |
class DecodeScalar a where #
GraphQL Scalar parser
Methods
decodeScalar :: ScalarValue -> Either Text a #
Instances
DecodeScalar ID | |
Defined in Data.Morpheus.Types.ID Methods decodeScalar :: ScalarValue -> Either Text ID # | |
DecodeScalar Text | |
Defined in Data.Morpheus.Types.GQLScalar Methods decodeScalar :: ScalarValue -> Either Text Text # | |
DecodeScalar Bool | |
Defined in Data.Morpheus.Types.GQLScalar Methods decodeScalar :: ScalarValue -> Either Text Bool # | |
DecodeScalar Double | |
Defined in Data.Morpheus.Types.GQLScalar Methods decodeScalar :: ScalarValue -> Either Text Double # | |
DecodeScalar Float | |
Defined in Data.Morpheus.Types.GQLScalar Methods decodeScalar :: ScalarValue -> Either Text Float # | |
DecodeScalar Int | |
Defined in Data.Morpheus.Types.GQLScalar Methods decodeScalar :: ScalarValue -> Either Text Int # |
class EncodeScalar a where #
GraphQL Scalar Serializer
Methods
encodeScalar :: a -> ScalarValue #
Instances
EncodeScalar ID | |
Defined in Data.Morpheus.Types.ID Methods encodeScalar :: ID -> ScalarValue # | |
EncodeScalar Text | |
Defined in Data.Morpheus.Types.GQLScalar Methods encodeScalar :: Text -> ScalarValue # | |
EncodeScalar Bool | |
Defined in Data.Morpheus.Types.GQLScalar Methods encodeScalar :: Bool -> ScalarValue # | |
EncodeScalar Double | |
Defined in Data.Morpheus.Types.GQLScalar Methods encodeScalar :: Double -> ScalarValue # | |
EncodeScalar Float | |
Defined in Data.Morpheus.Types.GQLScalar Methods encodeScalar :: Float -> ScalarValue # | |
EncodeScalar Int | |
Defined in Data.Morpheus.Types.GQLScalar Methods encodeScalar :: Int -> ScalarValue # |
Instances
FromJSON ID | |||||
Defined in Data.Morpheus.Types.ID | |||||
ToJSON ID | |||||
Semigroup ID | |||||
IsString ID | |||||
Defined in Data.Morpheus.Types.ID Methods fromString :: String -> ID # | |||||
Generic ID | |||||
Defined in Data.Morpheus.Types.ID Associated Types
| |||||
Show ID | |||||
Eq ID | |||||
Hashable ID | |||||
Defined in Data.Morpheus.Types.ID | |||||
DecodeScalar ID | |||||
Defined in Data.Morpheus.Types.ID Methods decodeScalar :: ScalarValue -> Either Text ID # | |||||
EncodeScalar ID | |||||
Defined in Data.Morpheus.Types.ID Methods encodeScalar :: ID -> ScalarValue # | |||||
type Rep ID | |||||
Defined in Data.Morpheus.Types.ID |
Arguments
:: FilePath | the schema path relative to the project location, both introspection (.json) and schema definition (.gql, .graphql) are accepted. |
-> Q [Dec] |
declares input, enum and scalar types for specified schema
Example where the schema is defined in SDL format
declareGlobalTypes
"schema.gql"
Example with schema as introspection in JSON format.
declareGlobalTypes
"schema.json"
declareGlobalTypesByName :: FilePath -> [TypeName] -> Q [Dec] Source #
declares global types like declareGlobalTypes
,
while enabling to select only the types that are needed.
Arguments
:: FilePath | the schema path relative to the project location. both introspection (`.json`) and schema definition (`.gql`, `.graphql`) are accepted. |
-> FilePath | query path relative to the project location |
-> Q [Dec] |
declares object, interface and union types for specified schema and query.
Example where the schema is defined in SDL format
declareLocalTypes
"schema.gql" "query.gql"
Example with schema as introspection in JSON format.
declareLocalTypes
"schema.json" "query.gql"
declareLocalTypesInline Source #
Arguments
:: FilePath | the schema path relative to the project location. both introspection (`.json`) and schema definition (`.gql`, `.graphql`) are accepted. |
-> ExecutableSource | inline graphql query in Text format |
-> Q [Dec] |
inline version of declareLocalTypes
, however
instead of specifying the file path, you can simply
pass the query as text using QuasiQuoter raw
declareLocalTypesInline
"schema.gql" [raw
| query GetUsers { users { name } } ]
clientTypeDeclarations :: SchemaSource -> Maybe ExecutableSource -> Q [Dec] Source #
declares global or local types, depending on whether the second argument is specified or not
Instances
IsString GQLClient Source # | |
Defined in Data.Morpheus.Client.Fetch.GQLClient Methods fromString :: String -> GQLClient # |
type GQLClientResult a = Either (FetchError a) a Source #
data ResponseStream a Source #
withHeaders :: GQLClient -> [Header] -> GQLClient Source #
request :: (ClientTypeConstraint a, MonadFail m) => GQLClient -> Args a -> m (ResponseStream a) Source #
forEach :: (MonadIO m, MonadUnliftIO m, MonadFail m) => (GQLClientResult a -> m ()) -> ResponseStream a -> m () Source #
returns loop listening subscription events forever. if you want to run it in background use forkIO
single :: MonadIO m => ResponseStream a -> m (GQLClientResult a) Source #
returns first response from the server
parseClientTypeDeclarations :: SchemaSource -> Maybe Text -> GQLResult ([ClientDeclaration], Flags) Source #
data SchemaSource Source #
Instances
Show SchemaSource Source # | |
Defined in Data.Morpheus.Client.Fetch.Types Methods showsPrec :: Int -> SchemaSource -> ShowS # show :: SchemaSource -> String # showList :: [SchemaSource] -> ShowS # | |
Eq SchemaSource Source # | |
Defined in Data.Morpheus.Client.Fetch.Types |