graphql-api
graphql-api copied to clipboard
GraphQL.Resolver does NOT export DynamicUnionValue making refactoring impossible
I'm trying to refactor out the commented section below into its own function.
type Man = Object "Man" '[] '[Field "name" Text, Field "canVote" Bool]
type Dog = Object "Dog" '[] '[Field "name" Text, Field "hatesCats" Bool]
type ManOrDog = Object "Animal" '[]
'[Argument "num" Int32 :> Field "animal" (Union "ManOrDog" '[Man, Dog])]
manOrDog :: Int32 -> _
manOrDog num =
if num `mod` 2 == 0
then unionValue @Man $ pure (pure "Joe" :<> pure False)
else unionValue @Dog $ pure (pure "Rover" :<> pure True)
pickAnimal :: Handler IO ManOrDog
pickAnimal = pure manOrDog
-- where manOrDog num =
-- if num `mod` 2 == 0
-- then unionValue @Man $ pure (pure "Joe" :<> pure False)
-- else unionValue @Dog $ pure (pure "Rover" :<> pure True)
According to the compiler, the _ is:
IO (GraphQL.Resolver.DynamicUnionValue (Union "ManOrDog" '[Man, Dog]) IO)
But DynamicUnionValue is NOT exported so this cannot be specified making the refactor impossible.
Good catch. I'm doing some related work on this for #99. Will make sure I address it there.