diff --git a/core/src/Datarekisteri/Core/Types.hs b/core/src/Datarekisteri/Core/Types.hs index 5d04874..885e4e8 100644 --- a/core/src/Datarekisteri/Core/Types.hs +++ b/core/src/Datarekisteri/Core/Types.hs @@ -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