@@ -39,6 +39,9 @@ Which means we have base type, an _object_ called `Hello`, which has a single
3939_field_ `greeting`, which takes a non-nullable `String` called `who` and
4040returns a `String`.
4141
42+ Note that all the types here are GraphQL types, not Haskell types. `String`
43+ here is a GraphQL `String`, not a Haskell one.
44+
4245And we want to be able to send queries that look like:
4346
4447`` `graphql
@@ -72,11 +75,14 @@ object (also named `"Hello"`) that implements no interfaces (hence `'[]`). It
7275has one field, called `" greeting" ` which returns some `Text` and takes a
7376single named argument `"who"` , which is also `Text`.
7477
78+ Note that the GraphQL `String` from above got translated into a Haskell
79+ `Text`.
80+
7581There are some noteworthy differences between this schema and the GraphQL
7682schema:
7783
7884* The GraphQL schema requires a special annotation to say that a value cannot
79- be null, `!`. In Haskell, we instead assume that everything can't be null.
85+ be null, `!`. In Haskell, we instead assume that nothing can be null.
8086* In the GraphQL schema, the argument appears *after* the field name. In
8187 Haskell, it appears *before*.
8288* In Haskell, we name the top-level type twice, once on left hand side of the
@@ -111,8 +117,8 @@ The second layer of the handler, the implementation of `greeting`, produces
111117the value of the `greeting` field. It is monadic so that it will only be
112118executed when the field was requested.
113119
114- Each handler is a separate monadic action so we only perform the side effects
115- for fields present in the query.
120+ Each field handler is a separate monadic action so we only perform the side
121+ effects for fields present in the query.
116122
117123This handler is in `Identity` because it doesn't do anything particularly
118124monadic. It could be in `IO` or `STM` or `ExceptT Text IO` or whatever you
@@ -127,8 +133,8 @@ queryHello :: IO Response
127133queryHello = interpretAnonymousQuery @Hello hello " { greeting(who: \" mort\" ) }"
128134`` `
129135
130- The actual `Response` type is fairly big , so we're most likely to turn it into
131- JSON:
136+ The actual `Response` type is fairly verbose , so we're most likely to turn it
137+ into JSON:
132138
133139`` `
134140λ Aeson.encode <$ > queryHello
@@ -255,13 +261,13 @@ union UserOrCalculator = User | Calculator
255261And now in Haskell:
256262
257263```haskell
258- type UserOrCalcualtor = Union "UserOrCalcualtor " '[User, Calculator]
264+ type UserOrCalculator = Union "UserOrCalculator " '[User, Calculator]
259265```
260266
261- And let's define a very simple top-level object that uses `UserOrCalcualtor `:
267+ And let's define a very simple top-level object that uses `UserOrCalculator `:
262268
263269```haskell
264- type UnionQuery = Object "UnionQuery" '[] '[Field "union" UserOrCalcualtor ]
270+ type UnionQuery = Object "UnionQuery" '[] '[Field "union" UserOrCalculator ]
265271```
266272
267273and a handler that randomly returns either a user or a calculator:
0 commit comments