Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
c95a5fcd61 | |||
8417be25d7 | |||
8aa2e521c4 |
@ -6,6 +6,10 @@ The format is based on
|
||||
and this project adheres to
|
||||
[Haskell Package Versioning Policy](https://pvp.haskell.org/).
|
||||
|
||||
## [1.0.5.0] - 2024-11-21
|
||||
### Added
|
||||
- Add `ToGraphQL` and `FromGraphQL` instances for `Value` and `HashMap`.
|
||||
|
||||
## [1.0.4.0] - 2024-10-24
|
||||
### Added
|
||||
- `gql` quasi quoter which generates a string literal with the first line
|
||||
@ -37,6 +41,7 @@ and this project adheres to
|
||||
- JSON serialization.
|
||||
- Test helpers.
|
||||
|
||||
[1.0.5.0]: https://git.caraus.tech/OSS/graphql-spice/compare/v1.0.4.0...v1.0.5.0
|
||||
[1.0.4.0]: https://git.caraus.tech/OSS/graphql-spice/compare/v1.0.3.0...v1.0.4.0
|
||||
[1.0.3.0]: https://git.caraus.tech/OSS/graphql-spice/compare/v1.0.2.0...v1.0.3.0
|
||||
[1.0.2.0]: https://git.caraus.tech/OSS/graphql-spice/compare/v1.0.1.0...v1.0.2.0
|
||||
|
@ -1,7 +1,7 @@
|
||||
cabal-version: 3.0
|
||||
|
||||
name: graphql-spice
|
||||
version: 1.0.4.0
|
||||
version: 1.0.5.0
|
||||
synopsis: GraphQL with batteries
|
||||
description: Various extensions and convenience functions for the core
|
||||
graphql package.
|
||||
@ -38,7 +38,7 @@ library
|
||||
containers >= 0.6 && < 0.8,
|
||||
exceptions ^>= 0.10.4,
|
||||
hspec-expectations >= 0.8.2 && < 0.9,
|
||||
graphql ^>= 1.3.0,
|
||||
graphql >= 1.3.0 && < 1.5.0,
|
||||
megaparsec >= 9.0 && < 10,
|
||||
scientific ^>= 0.3.7,
|
||||
template-haskell >= 2.16 && < 3,
|
||||
|
@ -5,6 +5,7 @@
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE TemplateHaskell #-}
|
||||
{-# LANGUAGE TupleSections #-}
|
||||
{-# LANGUAGE FlexibleInstances #-}
|
||||
|
||||
-- | ToGraphQL and FromGraphQL typeclasses used for user-defined type
|
||||
-- conversion.
|
||||
@ -101,6 +102,10 @@ class ToGraphQL a
|
||||
where
|
||||
toGraphQL :: a -> Type.Value
|
||||
|
||||
instance ToGraphQL Type.Value
|
||||
where
|
||||
toGraphQL a = a
|
||||
|
||||
instance ToGraphQL Text
|
||||
where
|
||||
toGraphQL = Type.String
|
||||
@ -198,12 +203,20 @@ instance ToGraphQL LocalTime
|
||||
where
|
||||
toGraphQL = iso8601ToGraphQL
|
||||
|
||||
instance ToGraphQL a => ToGraphQL (HashMap.HashMap Text a)
|
||||
where
|
||||
toGraphQL = Type.Object . fmap toGraphQL
|
||||
|
||||
-- | Instances of this typeclass can be used to convert GraphQL internal
|
||||
-- representation to user-defined type.
|
||||
class FromGraphQL a
|
||||
where
|
||||
fromGraphQL :: Type.Value -> Maybe a
|
||||
|
||||
instance FromGraphQL Type.Value
|
||||
where
|
||||
fromGraphQL = Just
|
||||
|
||||
instance FromGraphQL Text
|
||||
where
|
||||
fromGraphQL (Type.String value) = Just value
|
||||
@ -311,6 +324,11 @@ instance FromGraphQL LocalTime
|
||||
where
|
||||
fromGraphQL = fromGraphQLToISO8601
|
||||
|
||||
instance FromGraphQL a => FromGraphQL (HashMap.HashMap Text a)
|
||||
where
|
||||
fromGraphQL (Type.Object hm) = traverse fromGraphQL hm
|
||||
fromGraphQL _ = Nothing
|
||||
|
||||
stringLE :: Name -> Q Exp
|
||||
stringLE = litE . stringL . nameBase
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user