summaryrefslogtreecommitdiff
path: root/docs/tutorial
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2020-06-03 07:20:38 +0200
committerEugen Wissner <belka@caraus.de>2020-06-03 07:20:38 +0200
commit93a04032886976b540f5fdb1417bd085a642f772 (patch)
tree712dda8a81286e0e39719a25f798ce23bb574e69 /docs/tutorial
parentd12577ae717512979c7654191ca65f25fc877907 (diff)
downloadgraphql-93a04032886976b540f5fdb1417bd085a642f772.tar.gz
Resolve abstract types
Objects that can be a part of an union or interface should return __typename as string.
Diffstat (limited to 'docs/tutorial')
-rw-r--r--docs/tutorial/tutorial.lhs14
1 files changed, 10 insertions, 4 deletions
diff --git a/docs/tutorial/tutorial.lhs b/docs/tutorial/tutorial.lhs
index 9ca2db0..9a2242e 100644
--- a/docs/tutorial/tutorial.lhs
+++ b/docs/tutorial/tutorial.lhs
@@ -42,7 +42,10 @@ First we build a GraphQL schema.
> queryType :: ObjectType IO
> queryType = ObjectType "Query" Nothing []
> $ HashMap.singleton "hello"
-> $ Field Nothing (Out.NamedScalarType string) mempty hello
+> $ Out.Resolver helloField hello
+>
+> helloField :: Field IO
+> helloField = Field Nothing (Out.NamedScalarType string) mempty
>
> hello :: ActionT IO Value
> hello = pure $ String "it's me"
@@ -77,7 +80,10 @@ For this example, we're going to be using time.
> queryType2 :: ObjectType IO
> queryType2 = ObjectType "Query" Nothing []
> $ HashMap.singleton "time"
-> $ Field Nothing (Out.NamedScalarType string) mempty time
+> $ Out.Resolver timeField time
+>
+> timeField :: Field IO
+> timeField = Field Nothing (Out.NamedScalarType string) mempty
>
> time :: ActionT IO Value
> time = do
@@ -140,8 +146,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", Field Nothing (Out.NamedScalarType string) mempty hello)
-> , ("time", Field Nothing (Out.NamedScalarType string) mempty time)
+> [ ("hello", Out.Resolver helloField hello)
+> , ("time", Out.Resolver timeField time)
> ]
>
> query3 :: Text