Fix GHC 9.2 warnings and deprecations

- Fix GHC 9.2 warnings
- Convert comments to proper deprecations
This commit is contained in:
Eugen Wissner 2022-12-24 18:09:52 +01:00
parent bf2e4925b4
commit 2f9881bb21
Signed by: belka
GPG Key ID: A27FDC1E8EE902C0
7 changed files with 26 additions and 30 deletions

View File

@ -6,7 +6,7 @@ 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/).
## [Unreleased] ## [1.1.0.0] - 2022-12-24
### Changed ### Changed
- Removed deprecated `Language.GraphQL.Error` functions: `addErr`, `addErrMsg`, - Removed deprecated `Language.GraphQL.Error` functions: `addErr`, `addErrMsg`,
`singleError`. `singleError`.
@ -490,9 +490,9 @@ and this project adheres to
### Added ### Added
- Data types for the GraphQL language. - Data types for the GraphQL language.
[Unreleased]: https://www.caraus.tech/projects/pub-graphql/repository/23/diff?rev=master&rev_to=v1.0.3.0 [1.1.0.0]: https://www.caraus.tech/projects/pub-graphql/repository/23/diff?rev=v1.1.0.0&rev_to=v1.0.3.0
[1.0.3.0]: https://www.caraus.tech/projects/pub-graphql/repository/23/diff?rev=1.0.3.0&rev_to=v1.0.2.0 [1.0.3.0]: https://www.caraus.tech/projects/pub-graphql/repository/23/diff?rev=v1.0.3.0&rev_to=v1.0.2.0
[1.0.2.0]: https://www.caraus.tech/projects/pub-graphql/repository/23/diff?rev=1.0.2.0&rev_to=v1.0.1.0 [1.0.2.0]: https://www.caraus.tech/projects/pub-graphql/repository/23/diff?rev=v1.0.2.0&rev_to=v1.0.1.0
[1.0.1.0]: https://www.caraus.tech/projects/pub-graphql/repository/23/diff?rev=v1.0.1.0&rev_to=v1.0.0.0 [1.0.1.0]: https://www.caraus.tech/projects/pub-graphql/repository/23/diff?rev=v1.0.1.0&rev_to=v1.0.0.0
[1.0.0.0]: https://www.caraus.tech/projects/pub-graphql/repository/23/diff?rev=v1.0.0.0&rev_to=v0.11.1.0 [1.0.0.0]: https://www.caraus.tech/projects/pub-graphql/repository/23/diff?rev=v1.0.0.0&rev_to=v0.11.1.0
[0.11.1.0]: https://www.caraus.tech/projects/pub-graphql/repository/23/diff?rev=v0.11.1.0&rev_to=v0.11.0.0 [0.11.1.0]: https://www.caraus.tech/projects/pub-graphql/repository/23/diff?rev=v0.11.1.0&rev_to=v0.11.0.0

View File

@ -1,7 +1,7 @@
cabal-version: 2.4 cabal-version: 2.4
name: graphql name: graphql
version: 1.0.3.0 version: 1.1.0.0
synopsis: Haskell GraphQL implementation synopsis: Haskell GraphQL implementation
description: Haskell <https://spec.graphql.org/June2018/ GraphQL> implementation. description: Haskell <https://spec.graphql.org/June2018/ GraphQL> implementation.
category: Language category: Language
@ -22,7 +22,7 @@ extra-source-files:
README.md README.md
tested-with: tested-with:
GHC == 8.10.7, GHC == 8.10.7,
GHC == 9.2.3 GHC == 9.2.4
source-repository head source-repository head
type: git type: git
@ -30,7 +30,7 @@ source-repository head
flag Json flag Json
description: Whether to build against @aeson 1.x@ description: Whether to build against @aeson 1.x@
default: True default: False
manual: True manual: True
library library

View File

@ -45,6 +45,7 @@ import qualified Language.GraphQL.Validate as Validate
import Language.GraphQL.Type.Schema (Schema) import Language.GraphQL.Type.Schema (Schema)
import Text.Megaparsec (parse) import Text.Megaparsec (parse)
{-# DEPRECATED graphql "Use graphql-spice package instead" #-}
-- | If the text parses correctly as a @GraphQL@ query the query is -- | If the text parses correctly as a @GraphQL@ query the query is
-- executed using the given 'Schema'. -- executed using the given 'Schema'.
graphql :: MonadCatch m graphql :: MonadCatch m
@ -53,6 +54,7 @@ graphql :: MonadCatch m
-> m (Either (ResponseEventStream m Aeson.Value) Aeson.Object) -- ^ Response. -> m (Either (ResponseEventStream m Aeson.Value) Aeson.Object) -- ^ Response.
graphql schema = graphqlSubs schema mempty mempty graphql schema = graphqlSubs schema mempty mempty
{-# DEPRECATED graphqlSubs "Use graphql-spice package instead" #-}
-- | If the text parses correctly as a @GraphQL@ query the substitution is -- | If the text parses correctly as a @GraphQL@ query the substitution is
-- applied to the query and the query is then executed using to the given -- applied to the query and the query is then executed using to the given
-- 'Schema'. -- 'Schema'.

View File

@ -100,11 +100,9 @@ instance Exception ResolverException
-- * Deprecated -- * Deprecated
{-# DEPRECATED runCollectErrs "runCollectErrs was part of the old executor and isn't used anymore" #-}
-- | Runs the given query computation, but collects the errors into an error -- | Runs the given query computation, but collects the errors into an error
-- list, which is then sent back with the data. -- list, which is then sent back with the data.
--
-- {-# DEPRECATED runCollectErrs was part of the old executor and isn't used
-- anymore #-}
runCollectErrs :: (Monad m, Serialize a) runCollectErrs :: (Monad m, Serialize a)
=> HashMap Name (Schema.Type m) => HashMap Name (Schema.Type m)
-> CollectErrsT m a -> CollectErrsT m a
@ -114,17 +112,13 @@ runCollectErrs types' res = do
$ Resolution{ errors = Seq.empty, types = types' } $ Resolution{ errors = Seq.empty, types = types' }
pure $ Response dat errors pure $ Response dat errors
{-# DEPRECATED Resolution "Resolution was part of the old executor and isn't used anymore" #-}
-- | Executor context. -- | Executor context.
--
-- {-# DEPRECATED Resolution was part of the old executor and isn't used
-- anymore #-}
data Resolution m = Resolution data Resolution m = Resolution
{ errors :: Seq Error { errors :: Seq Error
, types :: HashMap Name (Schema.Type m) , types :: HashMap Name (Schema.Type m)
} }
{-# DEPRECATED CollectErrsT "CollectErrsT was part of the old executor and isn't used anymore" #-}
-- | A wrapper to pass error messages around. -- | A wrapper to pass error messages around.
--
-- {-# DEPRECATED CollectErrsT was part of the old executor and isn't used
-- anymore #-}
type CollectErrsT m = StateT (Resolution m) m type CollectErrsT m = StateT (Resolution m) m

View File

@ -9,7 +9,7 @@
{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE OverloadedStrings #-}
-- | Test helpers. -- | Test helpers.
module Test.Hspec.GraphQL module Test.Hspec.GraphQL {-# DEPRECATED "Use graphql-spice package instead" #-}
( shouldResolve ( shouldResolve
, shouldResolveTo , shouldResolveTo
) where ) where
@ -43,7 +43,7 @@ shouldResolve executor query = do
_ -> expectationFailure _ -> expectationFailure
"the query is expected to resolve to a value, but it resolved to an event stream" "the query is expected to resolve to a value, but it resolved to an event stream"
#else #else
module Test.Hspec.GraphQL module Test.Hspec.GraphQL {-# DEPRECATED "Use graphql-spice package instead" #-}
( (
) where ) where
#endif #endif

View File

@ -13,7 +13,7 @@ module Language.GraphQL.ExecuteSpec
( spec ( spec
) where ) where
import Control.Exception (Exception(..), SomeException) import Control.Exception (Exception(..))
import Control.Monad.Catch (throwM) import Control.Monad.Catch (throwM)
import Data.Conduit import Data.Conduit
import Data.HashMap.Strict (HashMap) import Data.HashMap.Strict (HashMap)
@ -202,7 +202,7 @@ schoolType = EnumType "School" Nothing $ HashMap.fromList
] ]
type EitherStreamOrValue = Either type EitherStreamOrValue = Either
(ResponseEventStream (Either SomeException) Type.Value) (ResponseEventStream IO Type.Value)
(Response Type.Value) (Response Type.Value)
-- Asserts that a query resolves to a value. -- Asserts that a query resolves to a value.
@ -414,16 +414,16 @@ spec =
in sourceQuery `shouldResolveTo` expected in sourceQuery `shouldResolveTo` expected
context "Error path" $ do context "Error path" $ do
let executeHero :: Document -> Either SomeException EitherStreamOrValue let executeHero :: Document -> IO EitherStreamOrValue
executeHero = execute heroSchema Nothing (HashMap.empty :: HashMap Name Type.Value) executeHero = execute heroSchema Nothing (HashMap.empty :: HashMap Name Type.Value)
it "at the beggining of the list" $ it "at the beggining of the list" $ do
let Right (Right actual) = either (pure . parseError) executeHero Right actual <- either (pure . parseError) executeHero
$ parse document "" "{ hero(id: \"1\") { friends { name } } }" $ parse document "" "{ hero(id: \"1\") { friends { name } } }"
Response _ errors' = actual let Response _ errors' = actual
Error _ _ path' = fromJust $ Seq.lookup 0 errors' Error _ _ path' = fromJust $ Seq.lookup 0 errors'
expected = [Segment "hero", Segment "friends", Index 0, Segment "name"] expected = [Segment "hero", Segment "friends", Index 0, Segment "name"]
in path' `shouldBe` expected in path' `shouldBe` expected
context "Subscription" $ context "Subscription" $
it "subscribes" $ do it "subscribes" $ do

View File

@ -6,7 +6,7 @@
module Schemas.HeroSchema (heroSchema) where module Schemas.HeroSchema (heroSchema) where
import Control.Exception (Exception(..), SomeException) import Control.Exception (Exception(..))
import Control.Monad.Catch (throwM) import Control.Monad.Catch (throwM)
import Language.GraphQL.Error (ResolverException (..)) import Language.GraphQL.Error (ResolverException (..))
import qualified Language.GraphQL.Type.In as In import qualified Language.GraphQL.Type.In as In
@ -25,11 +25,11 @@ instance Exception HeroException where
ResolverException resolverException <- fromException e ResolverException resolverException <- fromException e
cast resolverException cast resolverException
heroSchema :: Type.Schema (Either SomeException) heroSchema :: Type.Schema IO
heroSchema = heroSchema =
schemaWithTypes Nothing queryType Nothing Nothing [] mempty schemaWithTypes Nothing queryType Nothing Nothing [] mempty
type ObjectType = Out.ObjectType (Either SomeException) type ObjectType = Out.ObjectType IO
queryType :: ObjectType queryType :: ObjectType
queryType = Out.ObjectType "Query" Nothing [] queryType = Out.ObjectType "Query" Nothing []
@ -42,7 +42,7 @@ queryType = Out.ObjectType "Query" Nothing []
$ In.Argument Nothing (In.NamedScalarType Type.id) Nothing $ In.Argument Nothing (In.NamedScalarType Type.id) Nothing
heroResolver = pure $ Type.Object mempty heroResolver = pure $ Type.Object mempty
stringField :: Out.Field (Either SomeException) stringField :: Out.Field IO
stringField = Out.Field Nothing (Out.NonNullScalarType Type.string) HashMap.empty stringField = Out.Field Nothing (Out.NonNullScalarType Type.string) HashMap.empty
heroType :: ObjectType heroType :: ObjectType