diff options
| author | Eugen Wissner <belka@caraus.de> | 2019-07-08 10:15:47 +0200 |
|---|---|---|
| committer | Eugen Wissner <belka@caraus.de> | 2019-07-08 10:15:47 +0200 |
| commit | 61879fb12437302d6b14e0e0297e3a8742d91f8b (patch) | |
| tree | 32915a3da74f1b41b113f9a0fa12033e3cc6f656 /src/Language/GraphQL.hs | |
| parent | 22d4a4e583d8075fc71cddc22566f41fc5a698dc (diff) | |
| download | graphql-61879fb12437302d6b14e0e0297e3a8742d91f8b.tar.gz | |
Constrain the resolvers with MonadIO
This replaces the most usages of MonadPlus, which is not appropriate for
the resolvers, since a resolver is unambiguously chosen by the name (no
need for 'mplus'), and the resolvers are often doing IO.
Diffstat (limited to 'src/Language/GraphQL.hs')
| -rw-r--r-- | src/Language/GraphQL.hs | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/Language/GraphQL.hs b/src/Language/GraphQL.hs index 8ed29cf..74052d9 100644 --- a/src/Language/GraphQL.hs +++ b/src/Language/GraphQL.hs @@ -1,8 +1,7 @@ -- | This module provides the functions to parse and execute @GraphQL@ queries. module Language.GraphQL where -import Control.Monad (MonadPlus) - +import Control.Monad.IO.Class (MonadIO) import qualified Data.Text as T import qualified Data.Aeson as Aeson @@ -21,7 +20,7 @@ import Language.GraphQL.Error -- executed according to the given 'Schema'. -- -- Returns the response as an @Aeson.@'Aeson.Value'. -graphql :: MonadPlus m => Schema m -> T.Text -> m Aeson.Value +graphql :: MonadIO m => Schema m -> T.Text -> m Aeson.Value graphql = flip graphqlSubs $ const Nothing -- | Takes a 'Schema', a variable substitution function and text @@ -30,7 +29,7 @@ graphql = flip graphqlSubs $ const Nothing -- query and the query is then executed according to the given 'Schema'. -- -- Returns the response as an @Aeson.@'Aeson.Value'. -graphqlSubs :: MonadPlus m => Schema m -> Subs -> T.Text -> m Aeson.Value +graphqlSubs :: MonadIO m => Schema m -> Subs -> T.Text -> m Aeson.Value graphqlSubs schema f = either (parseError . errorBundlePretty) (execute schema f) . parse document "" |
