2016-02-05 12:32:35 +01:00
|
|
|
module Data.GraphQL where
|
|
|
|
|
|
|
|
import Control.Applicative (Alternative, empty)
|
|
|
|
|
|
|
|
import Data.Text (Text)
|
|
|
|
|
|
|
|
import qualified Data.Aeson as Aeson
|
|
|
|
import qualified Data.Attoparsec.Text as Attoparsec
|
|
|
|
|
|
|
|
import Data.GraphQL.Execute
|
|
|
|
import Data.GraphQL.Parser
|
|
|
|
import Data.GraphQL.Schema
|
|
|
|
|
|
|
|
graphql :: (Alternative m, Monad m) => Schema m -> Text -> m Aeson.Value
|
2016-02-15 14:25:15 +01:00
|
|
|
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)
|
|
|
|
. Attoparsec.parseOnly document
|