diff options
| author | Matthías Páll Gissurarson <mpg@mpg.is> | 2016-03-12 00:59:51 +0100 |
|---|---|---|
| committer | Matthías Páll Gissurarson <mpg@mpg.is> | 2016-03-14 01:01:24 +0100 |
| commit | d1953891029a71115ee572b7b3798072cbaf2ea8 (patch) | |
| tree | c964aade8d6aeaff61f2bb8e6057079e7e5d5913 /Data/GraphQL.hs | |
| parent | b74278cd19d900d1397e35b85f7b80d70cd574f2 (diff) | |
| download | graphql-d1953891029a71115ee572b7b3798072cbaf2ea8.tar.gz | |
Added exception handling with Alternative constraint according to spec.
Diffstat (limited to 'Data/GraphQL.hs')
| -rw-r--r-- | Data/GraphQL.hs | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/Data/GraphQL.hs b/Data/GraphQL.hs index 2da8a46..a2796ae 100644 --- a/Data/GraphQL.hs +++ b/Data/GraphQL.hs @@ -1,6 +1,6 @@ module Data.GraphQL where -import Control.Applicative (Alternative, empty) +import Control.Applicative (Alternative) import Data.Text (Text) @@ -11,10 +11,13 @@ import Data.GraphQL.Execute import Data.GraphQL.Parser import Data.GraphQL.Schema +import Data.GraphQL.Error + graphql :: (Alternative m, Monad m) => Schema m -> Text -> m Aeson.Value graphql = flip graphqlSubs $ const Nothing + graphqlSubs :: (Alternative m, Monad m) => Schema m -> Subs -> Text -> m Aeson.Value graphqlSubs schema f = - either (const empty) (execute schema f) + either parseError (execute schema f) . Attoparsec.parseOnly document |
