graphql-client-1.2.4: test/Data/GraphQL/Test/Generation/src/Example/Scalars.hs
module Example.Scalars where
import Control.Monad (guard)
import Data.Aeson (FromJSON (..), ToJSON (..))
newtype Age = Age Int
deriving (Show)
instance FromJSON Age where
parseJSON v = do
n <- parseJSON v
guard $ n >= 0
pure $ Age n
instance ToJSON Age where
toJSON (Age n) = toJSON n