Add morpheus instances for Scope

This commit is contained in:
Saku Laesvuori 2024-01-19 13:25:30 +02:00
parent bb96e415e7
commit 53f9d0d323
Signed by: slaesvuo
GPG Key ID: 257D284A2A1D3A32
1 changed files with 12 additions and 1 deletions

View File

@ -83,7 +83,18 @@ data Scope = OwnProfile
| Tokens UserID
| Members
| Applications
deriving (Show, Eq, Ord, Read)
deriving (Show, Eq, Ord, Read, Generic)
instance DecodeScalar Scope where
decodeScalar (String s) = maybe (Left $ "invalid Scope: \"" <> s <> "\"") Right $ readMaybe (toString s)
decodeScalar _ = Left "Invalid type for Scope, should be string"
instance EncodeScalar Scope where
encodeScalar = String . show
instance GQLType Scope where type KIND Scope = SCALAR
instance ToJSON Scope where toJSON = scalarToJSON
instance FromJSON Scope where parseJSON = scalarFromJSON <=< parseJSON
data Permission = None
| ReadOnly