Maintainer | Brandon Chinn <brandonchinn178@gmail.com> |
---|---|
Stability | experimental |
Portability | portable |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Defines the MonadGraphQLQuery
type class to query GraphQL APIs.
Also provides the GraphQLQueryT
monad transformer that can be
added to a transformer stack to implement the type class, and the
runQuerySafeIO
function to manually implement it yourself.
Synopsis
- class Monad m => MonadGraphQLQuery m where
- runQuerySafe :: (GraphQLQuery query, schema ~ ResultSchema query) => query -> m (GraphQLResult (Object schema))
- runQuery :: (MonadIO m, MonadGraphQLQuery m, GraphQLQuery query, schema ~ ResultSchema query) => query -> m (Object schema)
- runQuerySafeIO :: (GraphQLQuery query, schema ~ ResultSchema query) => GraphQLManager -> query -> IO (GraphQLResult (Object schema))
- data GraphQLSettings = GraphQLSettings {
- managerSettings :: ManagerSettings
- url :: String
- modifyReq :: Request -> Request
- defaultGraphQLSettings :: GraphQLSettings
- data GraphQLManager
- initGraphQLManager :: GraphQLSettings -> IO GraphQLManager
- data GraphQLQueryT m a
- runGraphQLQueryT :: MonadIO m => GraphQLSettings -> GraphQLQueryT m a -> m a
MonadGraphQLQuery API
class Monad m => MonadGraphQLQuery m where Source #
A type class for monads that can run GraphQL queries.
runQuerySafe :: (GraphQLQuery query, schema ~ ResultSchema query) => query -> m (GraphQLResult (Object schema)) Source #
Run the given query and return the GraphQLResult
.
Instances
runQuery :: (MonadIO m, MonadGraphQLQuery m, GraphQLQuery query, schema ~ ResultSchema query) => query -> m (Object schema) Source #
Run the given query and returns the result, erroring if the query returned errors.
runQuerySafeIO :: (GraphQLQuery query, schema ~ ResultSchema query) => GraphQLManager -> query -> IO (GraphQLResult (Object schema)) Source #
Execute a GraphQL query with the given GraphQLManager
.
GraphQLSettings
data GraphQLSettings Source #
The settings for initializing a GraphQLManager
.
GraphQLSettings | |
|
defaultGraphQLSettings :: GraphQLSettings Source #
Default settings for GraphQLSettings
. Requires url
field to be overridden.
Example usage:
>>>
defaultGraphQLSettings
... { url = "https://api.github.com/graphql" ... , modifyReq = \\req -> req ... { requestHeaders = ... (hAuthorization, "bearer my_github_token") : requestHeaders req ... } ... }
GraphQLManager
data GraphQLManager Source #
The manager for running GraphQL queries.
GraphQLQueryT
data GraphQLQueryT m a Source #
The monad transformer type that can be used to run GraphQL queries.
newtype MyMonad a = MyMonad { unMyMonad :: GraphQLQueryT IO a } runMyMonad :: MyMonad a -> IO a runMyMonad = runGraphQLQueryT graphQLSettings . unMyMonad where graphQLSettings = defaultGraphQLSettings{url = "https://api.github.com/graphql"}
Instances
runGraphQLQueryT :: MonadIO m => GraphQLSettings -> GraphQLQueryT m a -> m a Source #
Run the GraphQLQueryT monad transformer.