Skip to content

Commit af72e73

Browse files
author
Auke Booij
committed
Throw more errors when collecting query root names
1 parent 2eed647 commit af72e73

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

server/src-lib/Hasura/GraphQL/Schema.hs

+6-9
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,12 @@ buildGQLContext =
9898
-- build the admin context so that we can check against name clashes with remotes
9999
adminHasuraContext <- bindA -< buildFullestDBSchema
100100

101-
let queryFieldNames :: [G.Name]
102-
queryFieldNames =
103-
case P.discardNullability $ P.parserType $ fst adminHasuraContext of
104-
P.TList _ -> []
105-
P.TNamed def ->
106-
case P.dInfo def of
107-
-- It really ought to be this case; anything else is a programming error.
108-
P.TIObject (P.ObjectInfo rootFields _interfaces) -> fmap P.dName rootFields
109-
_ -> []
101+
queryFieldNames :: [G.Name] <- bindA -<
102+
case P.discardNullability $ P.parserType $ fst adminHasuraContext of
103+
-- It really ought to be this case; anything else is a programming error.
104+
P.TNamed (P.Definition _ _ _ (P.TIObject (P.ObjectInfo rootFields _interfaces))) ->
105+
pure $ fmap P.dName rootFields
106+
_ -> throw500 "We encountered an root query of unexpected GraphQL type. It should be an object type."
110107
let mutationFieldNames :: [G.Name]
111108
mutationFieldNames =
112109
case P.discardNullability . P.parserType <$> snd adminHasuraContext of

0 commit comments

Comments
 (0)