| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Data.Morpheus.Types.GQLScalar
Synopsis
- class GQLScalar a where
- parseValue :: ScalarValue -> Either Text a
- serialize :: a -> ScalarValue
- scalarValidator :: Proxy a -> ScalarDefinition
- toScalar :: ValidValue -> Either Text ScalarValue
- scalarToJSON :: GQLScalar a => a -> Value
- scalarFromJSON :: (Monad m, MonadFail m) => GQLScalar a => Value -> m a
Documentation
class GQLScalar a where Source #
GraphQL Scalar
parseValue and serialize should be provided for every instances manually
Minimal complete definition
Methods
parseValue :: ScalarValue -> Either Text a Source #
value parsing and validating
for exhaustive pattern matching should be handled all scalar types : ScalarValue, ScalarValue, String, Boolean
invalid values can be reported with Left constructor :
parseValue String _ = Left "" -- without error message -- or parseValue String _ = Left "Error Message"
serialize :: a -> ScalarValue Source #
serialization of haskell type into scalar value
scalarValidator :: Proxy a -> ScalarDefinition Source #
Instances
| GQLScalar Bool Source # | |
Defined in Data.Morpheus.Types.GQLScalar Methods parseValue :: ScalarValue -> Either Text Bool Source # serialize :: Bool -> ScalarValue Source # | |
| GQLScalar Float Source # | |
Defined in Data.Morpheus.Types.GQLScalar Methods parseValue :: ScalarValue -> Either Text Float Source # serialize :: Float -> ScalarValue Source # | |
| GQLScalar Int Source # | |
Defined in Data.Morpheus.Types.GQLScalar Methods parseValue :: ScalarValue -> Either Text Int Source # serialize :: Int -> ScalarValue Source # | |
| GQLScalar Text Source # | |
Defined in Data.Morpheus.Types.GQLScalar Methods parseValue :: ScalarValue -> Either Text Text Source # serialize :: Text -> ScalarValue Source # | |
| GQLScalar ID Source # | |
Defined in Data.Morpheus.Types.ID | |
toScalar :: ValidValue -> Either Text ScalarValue Source #
scalarToJSON :: GQLScalar a => a -> Value Source #