{-# LANGUAGE OverloadedStrings #-}
module Data.Morpheus.Error.Spread
( unknownFragment
, cannotBeSpreadOnType
) where
import Data.Morpheus.Error.Utils (errorMessage)
import Data.Morpheus.Types.Internal.Base (Position)
import Data.Morpheus.Types.Internal.Validation (GQLErrors)
import Data.Text (Text)
import qualified Data.Text as T
unknownFragment :: Text -> Position -> GQLErrors
unknownFragment key' position' = errorMessage position' text
where
text = T.concat ["Unknown Fragment \"", key', "\"."]
cannotBeSpreadOnType :: Maybe Text -> Text -> Position -> Text -> GQLErrors
cannotBeSpreadOnType key' type' position' selectionType' = errorMessage position' text
where
text =
T.concat
[ "Fragment"
, getName key'
, " cannot be spread here as objects of type \""
, selectionType'
, "\" can never be of type \""
, type'
, "\"."
]
getName (Just x') = T.concat [" \"", x', "\""]
getName Nothing = ""