Add morpheus instances for Permission
This commit is contained in:
parent
53f9d0d323
commit
97fbe99d06
|
@ -99,7 +99,18 @@ instance FromJSON Scope where parseJSON = scalarFromJSON <=< parseJSON
|
||||||
data Permission = None
|
data Permission = None
|
||||||
| ReadOnly
|
| ReadOnly
|
||||||
| ReadWrite
|
| ReadWrite
|
||||||
deriving (Show, Eq, Ord, Read)
|
deriving (Show, Eq, Ord, Read, Generic)
|
||||||
|
|
||||||
|
instance DecodeScalar Permission where
|
||||||
|
decodeScalar (String s) = maybe (Left $ "invalid Permission: \"" <> s <> "\"") Right $ readMaybe (toString s)
|
||||||
|
decodeScalar _ = Left "Invalid type for Permission, should be string"
|
||||||
|
|
||||||
|
instance EncodeScalar Permission where
|
||||||
|
encodeScalar = String . show
|
||||||
|
|
||||||
|
instance GQLType Permission where type KIND Permission = SCALAR
|
||||||
|
instance ToJSON Permission where toJSON = scalarToJSON
|
||||||
|
instance FromJSON Permission where parseJSON = scalarFromJSON <=< parseJSON
|
||||||
|
|
||||||
readPermission :: Text -> Maybe (Map Scope Permission)
|
readPermission :: Text -> Maybe (Map Scope Permission)
|
||||||
readPermission = rightToMaybe . readEither . toString
|
readPermission = rightToMaybe . readEither . toString
|
||||||
|
|
Loading…
Reference in New Issue