Compare commits

...

3 Commits

Author SHA1 Message Date
c95a5fcd61
Allow graphql 1.4.0.0
All checks were successful
Build / audit (push) Successful in 6s
Build / test (push) Successful in 7m37s
Build / doc (push) Successful in 7m22s
Release / release (push) Successful in 5s
2024-11-21 17:14:03 +01:00
8417be25d7
Release 1.0.5.0
All checks were successful
Build / audit (push) Successful in 8s
Build / test (push) Successful in 7m59s
Build / doc (push) Successful in 8m5s
Release / release (push) Successful in 4s
2024-11-21 15:59:44 +01:00
8aa2e521c4
Add a few missing instances
All checks were successful
Build / audit (pull_request) Successful in 10s
Build / test (pull_request) Successful in 6m59s
Build / doc (pull_request) Successful in 7m7s
Build / audit (push) Successful in 6s
Build / test (push) Successful in 6m59s
Build / doc (push) Successful in 7m2s
2024-11-19 20:21:41 +01:00
3 changed files with 25 additions and 2 deletions

View File

@ -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

View File

@ -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,

View File

@ -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