diff options
Diffstat (limited to 'src/Language/GraphQL/Class.hs')
| -rw-r--r-- | src/Language/GraphQL/Class.hs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/Language/GraphQL/Class.hs b/src/Language/GraphQL/Class.hs index b363fd0..89b4337 100644 --- a/src/Language/GraphQL/Class.hs +++ b/src/Language/GraphQL/Class.hs @@ -79,6 +79,12 @@ instance ToGraphQL a => ToGraphQL (Maybe a) where instance ToGraphQL Bool where toGraphQL = Type.Boolean +instance ToGraphQL Float where + toGraphQL = Type.Float . realToFrac + +instance ToGraphQL Double where + toGraphQL = Type.Float + -- | Instances of this typeclass can be used to convert GraphQL internal -- representation to user-defined type. class FromGraphQL a where @@ -134,3 +140,11 @@ instance FromGraphQL a => FromGraphQL (Maybe a) where instance FromGraphQL Bool where fromGraphQL (Type.Boolean value) = Just value fromGraphQL _ = Nothing + +instance FromGraphQL Float where + fromGraphQL (Type.Float value) = Just $ realToFrac value + fromGraphQL _ = Nothing + +instance FromGraphQL Double where + fromGraphQL (Type.Float value) = Just value + fromGraphQL _ = Nothing |
