From 705e506c13b6c0f67ddf0195fa0d3256e7e4f9c3 Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Mon, 29 Jun 2020 13:14:23 +0200 Subject: Combine Resolver and ActionT in ResolverT --- docs/tutorial/tutorial.lhs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'docs/tutorial') diff --git a/docs/tutorial/tutorial.lhs b/docs/tutorial/tutorial.lhs index 13afb81..2c6e877 100644 --- a/docs/tutorial/tutorial.lhs +++ b/docs/tutorial/tutorial.lhs @@ -41,13 +41,12 @@ First we build a GraphQL schema. > > queryType :: ObjectType IO > queryType = ObjectType "Query" Nothing [] -> $ HashMap.singleton "hello" -> $ Out.Resolver helloField hello +> $ HashMap.singleton "hello" helloField > > helloField :: Field IO -> helloField = Field Nothing (Out.NamedScalarType string) mempty +> helloField = Field Nothing (Out.NamedScalarType string) mempty hello > -> hello :: ActionT IO Value +> hello :: ResolverT IO Value > hello = pure $ String "it's me" This defines a simple schema with one type and one field, that resolves to a fixed value. @@ -79,13 +78,12 @@ For this example, we're going to be using time. > > queryType2 :: ObjectType IO > queryType2 = ObjectType "Query" Nothing [] -> $ HashMap.singleton "time" -> $ Out.Resolver timeField time +> $ HashMap.singleton "time" timeField > > timeField :: Field IO -> timeField = Field Nothing (Out.NamedScalarType string) mempty +> timeField = Field Nothing (Out.NamedScalarType string) mempty time > -> time :: ActionT IO Value +> time :: ResolverT IO Value > time = do > t <- liftIO getCurrentTime > pure $ String $ Text.pack $ show t @@ -146,8 +144,8 @@ Now that we have two resolvers, we can define a schema which uses them both. > > queryType3 :: ObjectType IO > queryType3 = ObjectType "Query" Nothing [] $ HashMap.fromList -> [ ("hello", Out.Resolver helloField hello) -> , ("time", Out.Resolver timeField time) +> [ ("hello", helloField) +> , ("time", timeField) > ] > > query3 :: Text -- cgit v1.2.3