{-# LANGUAGE OverloadedStrings #-}
module Data.Morpheus.Error.Input
( typeViolation
)
where
import Data.Semigroup ( (<>) )
import Data.Aeson ( encode )
import Data.ByteString.Lazy.Char8 ( unpack )
import Data.Text ( pack )
import Data.Morpheus.Types.Internal.AST
( Message
, ResolvedValue
, TypeRef(..)
)
import Data.Morpheus.Rendering.RenderGQL
( RenderGQL(..) )
typeViolation :: TypeRef -> ResolvedValue -> Message
typeViolation expected found = "Expected type \""
<> render expected
<> "\" found "
<> pack (unpack $ encode found)
<> "."