Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- raw :: QuasiQuoter
- class (RequestType a, ToJSON (Args a), FromJSON a) => Fetch a where
- type Args a :: Type
- 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 :: Type) = 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)
- gql :: QuasiQuoter
- defineByDocument :: IO ByteString -> ExecutableSource -> Q [Dec]
- defineByDocumentFile :: FilePath -> ExecutableSource -> Q [Dec]
- defineByDocumentFile' :: Q FilePath -> ExecutableSource -> Q [Dec]
- defineByIntrospection :: IO ByteString -> ExecutableSource -> Q [Dec]
- defineByIntrospectionFile :: FilePath -> ExecutableSource -> Q [Dec]
- defineByIntrospectionFile' :: Q FilePath -> ExecutableSource -> Q [Dec]
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 #
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 fetch :: Monad m => (ByteString -> m ByteString) -> Args a -> m (Either (FetchError a) a) Source # |
data FetchError a Source #
Instances
data ScalarValue #
Primitive Values for GQLScalar: ScalarValue
, ScalarValue
, ScalarValue
, Boolean
.
for performance reason type Text
represents GraphQl ScalarValue
value
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 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 # |
default GraphQL type,
parses only ScalarValue
and ScalarValue
values,
serialized always as ScalarValue
Instances
FromJSON ID | |
ToJSON ID | |
Defined in Data.Morpheus.Types.ID | |
IsString ID | |
Defined in Data.Morpheus.Types.ID fromString :: String -> ID # | |
Semigroup ID | |
Generic ID | |
Show ID | |
Eq ID | |
Hashable ID | |
Defined in Data.Morpheus.Types.ID | |
DecodeScalar ID | |
Defined in Data.Morpheus.Types.ID decodeScalar :: ScalarValue -> Either Text ID # | |
EncodeScalar ID | |
Defined in Data.Morpheus.Types.ID encodeScalar :: ID -> ScalarValue # | |
type Rep ID | |
Defined in Data.Morpheus.Types.ID |
:: 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.
:: 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 #
:: 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 fromString :: String -> GQLClient # |
type GQLClientResult (a :: Type) = 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
gql :: QuasiQuoter Source #
Deprecated: use raw
defineByDocument :: IO ByteString -> ExecutableSource -> Q [Dec] Source #
Deprecated: use clientTypeDeclarations
defineByDocumentFile :: FilePath -> ExecutableSource -> Q [Dec] Source #
Deprecated: use declareLocalTypes
defineByDocumentFile' :: Q FilePath -> ExecutableSource -> Q [Dec] Source #
Deprecated: use declareLocalTypes
This variant exposes 'Q FilePath' enabling the use of TH to generate the FilePath
. For example, https://hackage.haskell.org/package/file-embed-0.0.13.0/docs/Data-FileEmbed.html#v:makeRelativeToProject can be used to handle multi package projects more reliably.
defineByIntrospection :: IO ByteString -> ExecutableSource -> Q [Dec] Source #
Deprecated: use clientTypeDeclarations
defineByIntrospectionFile :: FilePath -> ExecutableSource -> Q [Dec] Source #
Deprecated: use declareLocalTypes
defineByIntrospectionFile' :: Q FilePath -> ExecutableSource -> Q [Dec] Source #
Deprecated: use declareLocalTypes
This variant exposes 'Q FilePath' enabling the use of TH to generate the FilePath
. For example, https://hackage.haskell.org/package/file-embed-0.0.13.0/docs/Data-FileEmbed.html#v:makeRelativeToProject can be used to handle multi package projects more reliably.