Skip to content

GraphQL.Resolver does NOT export DynamicUnionValue making refactoring impossible #165

Open
@cscalfani

Description

@cscalfani

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions