Skip to content

Use newtypes in schema #151

Open
Open
@jml

Description

@jml

I want to do something like this:

newtype Thingy = Thingy Text deriving (Eq, Ord, Show)

instance ToValue Thingy where
  toValue (Thingy x) = toValue x

type QueryRoot = Object "QueryRoot" '[]
  '[ Field "thingy" Thingy
   ]

rootHandler :: Handler IO QueryRoot
rootHandler = thingyHandler

thingyHandler :: Handler IO Thingy
thingyHandler = pure $ Thingy "content"

But this gives me the following warning:

[-Wdeferred-type-errors]
    • Couldn't match expected type ‘Handler IO Thingy’
                  with actual type ‘f0 Thingy’
      The type variable ‘f0’ is ambiguous
    • In the expression: pure $ Thingy "content"
      In an equation for ‘thingyHandler’:
          thingyHandler = pure $ Thingy "content"

I think this is because we don't have a HasResolver instance. It seems a bit odd that I, the user, would have to provide one.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions