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