Skip to content

Commit 445c157

Browse files
authored
Merge pull request #101 from jml/todo-tweaks
Revise TODOs
2 parents 6dcb87d + 711e0ca commit 445c157

File tree

5 files changed

+13
-11
lines changed

5 files changed

+13
-11
lines changed

Diff for: src/GraphQL/Internal/Validation.hs

+2-4
Original file line numberDiff line numberDiff line change
@@ -494,10 +494,8 @@ validateSelection schema selection =
494494
AST.SelectionFragmentSpread (AST.FragmentSpread name directives) ->
495495
SelectionFragmentSpread <$> (UnresolvedFragmentSpread name <$> validateDirectives directives)
496496
AST.SelectionInlineFragment (AST.InlineFragment typeCond directives ss) ->
497-
SelectionInlineFragment <$> (InlineFragment -- TODO: fix the case statement
498-
<$> (case typeCond of
499-
Nothing -> pure Nothing
500-
Just tC -> Just <$> validateTypeCondition schema tC)
497+
SelectionInlineFragment <$> (InlineFragment
498+
<$> traverse (validateTypeCondition schema) typeCond
501499
<*> validateDirectives directives
502500
<*> childSegments ss)
503501
where

Diff for: src/GraphQL/Resolver.hs

+8-6
Original file line numberDiff line numberDiff line change
@@ -198,29 +198,31 @@ instance forall m. (Applicative m) => HasResolver m Bool where
198198
resolve handler Nothing = map (ok . toValue) handler
199199
resolve _ (Just ss) = throwE (SubSelectionOnLeaf ss)
200200

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-
206201
instance forall m hg. (Monad m, Applicative m, HasResolver m hg) => HasResolver m (API.List hg) where
207202
type Handler m (API.List hg) = m [Handler m hg]
208203
resolve handler selectionSet = do
209204
h <- handler
210205
let a = traverse (flip (resolve @m @hg) selectionSet) h
211206
map aggregateResults a
212207

213-
214208
instance forall m ksN enum. (Applicative m, API.GraphQLEnum enum) => HasResolver m (API.Enum ksN enum) where
215209
type Handler m (API.Enum ksN enum) = enum
216210
resolve handler Nothing = (pure . ok . GValue.ValueEnum . API.enumToValue) handler
217211
resolve _ (Just ss) = throwE (SubSelectionOnLeaf ss)
218212

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+
219220
-- TODO: A parametrized `Result` is really not a good way to handle the
220221
-- "result" for resolveField, but not sure what to use either. Tom liked the
221222
-- tuple we had before more because it didn't imply any other structure or
222223
-- meaning. Maybe we can just create a new datatype. jml thinks we should
223224
-- extract some helpful generic monad, ala `Validator`.
225+
-- <https://github.com/jml/graphql-api/issues/98>
224226
type ResolveFieldResult = Result (Maybe GValue.Value)
225227

226228
-- Extract field name from an argument type. TODO: ideally we'd run

Diff for: src/GraphQL/Value.hs

+1
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ type Value = Value' ConstScalar
110110

111111
-- TODO: These next two definitions are quite internal. We should move this
112112
-- module to Internal and then re-export the bits that end-users will use.
113+
-- <https://github.com/jml/graphql-api/issues/99>
113114

114115
-- | A GraphQL value which might contain some variables. These variables are
115116
-- not yet associated with

Diff for: src/GraphQL/Value/ToValue.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ instance ToValue a => ToValue [a] where
2222
toValue = toValue . List' . map toValue
2323

2424
-- TODO - tom still thinks that using Maybe for nullable is maybe not
25-
-- the best idea.
25+
-- the best idea. <https://github.com/jml/graphql-api/issues/100>
2626
instance ToValue a => ToValue (Maybe a) where
2727
toValue Nothing = ValueNull
2828
toValue (Just v) = toValue v

Diff for: tests/EndToEndTests.hs

+1
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@ tests = testSpec "End-to-end tests" $ do
312312
-- very simple function to turn a JSON value / object into the
313313
-- variable map that we desire. Alternatively, we should have APIs
314314
-- like Aeson does.
315+
-- <https://github.com/jml/graphql-api/issues/96>
315316
let Right varName = makeName "whichCommand"
316317
let vars = Map.singleton (Variable varName) (toValue Sit)
317318
response <- executeQuery @QueryRoot root query Nothing vars

0 commit comments

Comments
 (0)