mirror of
https://github.com/higherkindness/mu-haskell.git
synced 2024-08-16 18:00:33 +03:00
Missing instances for UUID (fixes #345)
This commit is contained in:
parent
4e2412efa8
commit
d1fbfeebdf
@ -26,9 +26,9 @@ import Data.Proxy
|
|||||||
import Data.SOP.NS
|
import Data.SOP.NS
|
||||||
import Data.Scientific (Scientific, floatingOrInteger, fromFloatDigits)
|
import Data.Scientific (Scientific, floatingOrInteger, fromFloatDigits)
|
||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
|
import qualified Data.UUID as UUID
|
||||||
import GHC.TypeLits
|
import GHC.TypeLits
|
||||||
import qualified Language.GraphQL.AST as GQL
|
import qualified Language.GraphQL.AST as GQL
|
||||||
|
|
||||||
import Mu.GraphQL.Annotations
|
import Mu.GraphQL.Annotations
|
||||||
import Mu.GraphQL.Query.Definition
|
import Mu.GraphQL.Query.Definition
|
||||||
import Mu.Rpc
|
import Mu.Rpc
|
||||||
@ -597,6 +597,13 @@ instance ParseArg p ('PrimitiveRef String) where
|
|||||||
= pure $ ArgPrimitive $ T.unpack b
|
= pure $ ArgPrimitive $ T.unpack b
|
||||||
parseArg _ aname _
|
parseArg _ aname _
|
||||||
= throwError $ "argument '" <> aname <> "' was not of right type"
|
= throwError $ "argument '" <> aname <> "' was not of right type"
|
||||||
|
instance ParseArg p ('PrimitiveRef UUID.UUID) where
|
||||||
|
parseArg _ _ (GQL.String b)
|
||||||
|
= case UUID.fromText b of
|
||||||
|
Nothing -> throwError "string not in UUID format"
|
||||||
|
Just u -> pure $ ArgPrimitive u
|
||||||
|
parseArg _ aname _
|
||||||
|
= throwError $ "argument '" <> aname <> "' was not of right type"
|
||||||
instance ParseArg p ('PrimitiveRef ()) where
|
instance ParseArg p ('PrimitiveRef ()) where
|
||||||
parseArg _ _ GQL.Null = pure $ ArgPrimitive ()
|
parseArg _ _ GQL.Null = pure $ ArgPrimitive ()
|
||||||
parseArg _ aname _
|
parseArg _ aname _
|
||||||
@ -716,6 +723,12 @@ instance ValueParser sch ('TPrimitive T.Text) where
|
|||||||
instance ValueParser sch ('TPrimitive String) where
|
instance ValueParser sch ('TPrimitive String) where
|
||||||
valueParser _ _ (GQL.String b) = pure $ FPrimitive $ T.unpack b
|
valueParser _ _ (GQL.String b) = pure $ FPrimitive $ T.unpack b
|
||||||
valueParser _ fname _ = throwError $ "field '" <> fname <> "' was not of right type"
|
valueParser _ fname _ = throwError $ "field '" <> fname <> "' was not of right type"
|
||||||
|
instance ValueParser sch ('TPrimitive UUID.UUID) where
|
||||||
|
valueParser _ _ (GQL.String b) =
|
||||||
|
case UUID.fromText b of
|
||||||
|
Nothing -> throwError "string not in UUID format"
|
||||||
|
Just u -> pure $ FPrimitive u
|
||||||
|
valueParser _ fname _ = throwError $ "field '" <> fname <> "' was not of right type"
|
||||||
instance (ValueParser sch r) => ValueParser sch ('TList r) where
|
instance (ValueParser sch r) => ValueParser sch ('TList r) where
|
||||||
valueParser vmap fname (GQL.List xs) = FList <$> traverse (valueParser' vmap fname . GQL.node) xs
|
valueParser vmap fname (GQL.List xs) = FList <$> traverse (valueParser' vmap fname . GQL.node) xs
|
||||||
valueParser _ fname _ = throwError $ "field '" <> fname <> "' was not of right type"
|
valueParser _ fname _ = throwError $ "field '" <> fname <> "' was not of right type"
|
||||||
|
Loading…
Reference in New Issue
Block a user