diff options
| author | Eugen Wissner <belka@caraus.de> | 2020-06-29 13:14:23 +0200 |
|---|---|---|
| committer | Eugen Wissner <belka@caraus.de> | 2020-06-29 13:14:23 +0200 |
| commit | 705e506c13b6c0f67ddf0195fa0d3256e7e4f9c3 (patch) | |
| tree | 58e41bdbd246fc5b947a848283d6688c7ddf636b /docs/tutorial | |
| parent | 9798b08b4c25685e92a7f537f68f35994a5a4899 (diff) | |
| download | graphql-705e506c13b6c0f67ddf0195fa0d3256e7e4f9c3.tar.gz | |
Combine Resolver and ActionT in ResolverT
Diffstat (limited to 'docs/tutorial')
| -rw-r--r-- | docs/tutorial/tutorial.lhs | 18 |
1 files changed, 8 insertions, 10 deletions
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 |
