@@ -198,29 +198,31 @@ instance forall m. (Applicative m) => HasResolver m Bool where
198
198
resolve handler Nothing = map (ok . toValue) handler
199
199
resolve _ (Just ss) = throwE (SubSelectionOnLeaf ss)
200
200
201
- -- XXX: jml really doesn't understand this. What happens to the selection set? What if it's a nullable object?
202
- instance forall m hg . (HasResolver m hg , Functor m , ToValue (Maybe hg )) => HasResolver m (Maybe hg ) where
203
- type Handler m (Maybe hg ) = m (Maybe hg )
204
- resolve handler _ = map (ok . toValue) handler
205
-
206
201
instance forall m hg . (Monad m , Applicative m , HasResolver m hg ) => HasResolver m (API. List hg ) where
207
202
type Handler m (API. List hg ) = m [Handler m hg ]
208
203
resolve handler selectionSet = do
209
204
h <- handler
210
205
let a = traverse (flip (resolve @ m @ hg ) selectionSet) h
211
206
map aggregateResults a
212
207
213
-
214
208
instance forall m ksN enum . (Applicative m , API. GraphQLEnum enum ) => HasResolver m (API. Enum ksN enum ) where
215
209
type Handler m (API. Enum ksN enum ) = enum
216
210
resolve handler Nothing = (pure . ok . GValue. ValueEnum . API. enumToValue) handler
217
211
resolve _ (Just ss) = throwE (SubSelectionOnLeaf ss)
218
212
213
+ -- TODO: This is our handler for `Maybe a`, which is currently used to
214
+ -- implement nullable types. It's *probably* broken, in that it's discarding
215
+ -- the selection set. <https://github.com/jml/graphql-api/issues/102>
216
+ instance forall m hg . (HasResolver m hg , Functor m , ToValue (Maybe hg )) => HasResolver m (Maybe hg ) where
217
+ type Handler m (Maybe hg ) = m (Maybe hg )
218
+ resolve handler _ = map (ok . toValue) handler
219
+
219
220
-- TODO: A parametrized `Result` is really not a good way to handle the
220
221
-- "result" for resolveField, but not sure what to use either. Tom liked the
221
222
-- tuple we had before more because it didn't imply any other structure or
222
223
-- meaning. Maybe we can just create a new datatype. jml thinks we should
223
224
-- extract some helpful generic monad, ala `Validator`.
225
+ -- <https://github.com/jml/graphql-api/issues/98>
224
226
type ResolveFieldResult = Result (Maybe GValue. Value )
225
227
226
228
-- Extract field name from an argument type. TODO: ideally we'd run
0 commit comments