From d82d5a36b32934bfeb99bf8c99637977dfe725b4 Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Tue, 31 Dec 2019 08:29:03 +0100 Subject: Retrieve resolver arguments from the reader --- docs/tutorial/tutorial.lhs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'docs/tutorial/tutorial.lhs') diff --git a/docs/tutorial/tutorial.lhs b/docs/tutorial/tutorial.lhs index d017ddd..fcbc3eb 100644 --- a/docs/tutorial/tutorial.lhs +++ b/docs/tutorial/tutorial.lhs @@ -16,7 +16,6 @@ Since this file is a literate haskell file, we start by importing some dependenc > module Main where > > import Control.Monad.IO.Class (liftIO) -> import Control.Monad.Trans.Except (throwE) > import Data.Aeson (encode) > import Data.ByteString.Lazy.Char8 (putStrLn) > import Data.List.NonEmpty (NonEmpty(..)) @@ -25,7 +24,6 @@ Since this file is a literate haskell file, we start by importing some dependenc > > import Language.GraphQL > import qualified Language.GraphQL.Schema as Schema -> import Language.GraphQL.Trans (ActionT(..)) > > import Prelude hiding (putStrLn) @@ -70,10 +68,9 @@ For this example, we're going to be using time. > schema2 = time :| [] > > time :: Schema.Resolver IO -> time = Schema.scalarA "time" $ \case -> [] -> do t <- liftIO getCurrentTime -> return $ show t -> _ -> ActionT $ throwE "Invalid arguments." +> time = Schema.scalar "time" $ do +> t <- liftIO getCurrentTime +> return $ show t This defines a simple schema with one type and one field, which resolves to the current time. -- cgit v1.2.3