diff --git a/CHANGELOG.md b/CHANGELOG.md index ec5d2db..0ce7624 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ The format is based on and this project adheres to [Haskell Package Versioning Policy](https://pvp.haskell.org/). -## [Unreleased] +## [1.1.0.0] - 2022-12-24 ### Changed - Removed deprecated `Language.GraphQL.Error` functions: `addErr`, `addErrMsg`, `singleError`. @@ -490,9 +490,9 @@ and this project adheres to ### Added - 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.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.2.0]: https://www.caraus.tech/projects/pub-graphql/repository/23/diff?rev=1.0.2.0&rev_to=v1.0.1.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=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=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.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 diff --git a/graphql.cabal b/graphql.cabal index 3cc6160..c448f0e 100644 --- a/graphql.cabal +++ b/graphql.cabal @@ -1,7 +1,7 @@ cabal-version: 2.4 name: graphql -version: 1.0.3.0 +version: 1.1.0.0 synopsis: Haskell GraphQL implementation description: Haskell implementation. category: Language @@ -22,7 +22,7 @@ extra-source-files: README.md tested-with: GHC == 8.10.7, - GHC == 9.2.3 + GHC == 9.2.4 source-repository head type: git @@ -30,7 +30,7 @@ source-repository head flag Json description: Whether to build against @aeson 1.x@ - default: True + default: False manual: True library diff --git a/src/Language/GraphQL.hs b/src/Language/GraphQL.hs index d54ae60..4f3e8d9 100644 --- a/src/Language/GraphQL.hs +++ b/src/Language/GraphQL.hs @@ -45,6 +45,7 @@ import qualified Language.GraphQL.Validate as Validate import Language.GraphQL.Type.Schema (Schema) import Text.Megaparsec (parse) +{-# DEPRECATED graphql "Use graphql-spice package instead" #-} -- | If the text parses correctly as a @GraphQL@ query the query is -- executed using the given 'Schema'. graphql :: MonadCatch m @@ -53,6 +54,7 @@ graphql :: MonadCatch m -> m (Either (ResponseEventStream m Aeson.Value) Aeson.Object) -- ^ Response. 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 -- applied to the query and the query is then executed using to the given -- 'Schema'. diff --git a/src/Language/GraphQL/Error.hs b/src/Language/GraphQL/Error.hs index 403aaf6..87ee702 100644 --- a/src/Language/GraphQL/Error.hs +++ b/src/Language/GraphQL/Error.hs @@ -100,11 +100,9 @@ instance Exception ResolverException -- * 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 -- 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) => HashMap Name (Schema.Type m) -> CollectErrsT m a @@ -114,17 +112,13 @@ runCollectErrs types' res = do $ Resolution{ errors = Seq.empty, types = types' } pure $ Response dat errors +{-# DEPRECATED Resolution "Resolution was part of the old executor and isn't used anymore" #-} -- | Executor context. --- --- {-# DEPRECATED Resolution was part of the old executor and isn't used --- anymore #-} data Resolution m = Resolution { errors :: Seq Error , 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. --- --- {-# DEPRECATED CollectErrsT was part of the old executor and isn't used --- anymore #-} type CollectErrsT m = StateT (Resolution m) m diff --git a/src/Test/Hspec/GraphQL.hs b/src/Test/Hspec/GraphQL.hs index 5d812bf..a848c15 100644 --- a/src/Test/Hspec/GraphQL.hs +++ b/src/Test/Hspec/GraphQL.hs @@ -9,7 +9,7 @@ {-# LANGUAGE OverloadedStrings #-} -- | Test helpers. -module Test.Hspec.GraphQL +module Test.Hspec.GraphQL {-# DEPRECATED "Use graphql-spice package instead" #-} ( shouldResolve , shouldResolveTo ) where @@ -43,7 +43,7 @@ shouldResolve executor query = do _ -> expectationFailure "the query is expected to resolve to a value, but it resolved to an event stream" #else -module Test.Hspec.GraphQL +module Test.Hspec.GraphQL {-# DEPRECATED "Use graphql-spice package instead" #-} ( ) where #endif diff --git a/tests/Language/GraphQL/ExecuteSpec.hs b/tests/Language/GraphQL/ExecuteSpec.hs index 58aeb70..c313df0 100644 --- a/tests/Language/GraphQL/ExecuteSpec.hs +++ b/tests/Language/GraphQL/ExecuteSpec.hs @@ -13,7 +13,7 @@ module Language.GraphQL.ExecuteSpec ( spec ) where -import Control.Exception (Exception(..), SomeException) +import Control.Exception (Exception(..)) import Control.Monad.Catch (throwM) import Data.Conduit import Data.HashMap.Strict (HashMap) @@ -202,7 +202,7 @@ schoolType = EnumType "School" Nothing $ HashMap.fromList ] type EitherStreamOrValue = Either - (ResponseEventStream (Either SomeException) Type.Value) + (ResponseEventStream IO Type.Value) (Response Type.Value) -- Asserts that a query resolves to a value. @@ -414,16 +414,16 @@ spec = in sourceQuery `shouldResolveTo` expected 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) - it "at the beggining of the list" $ - let Right (Right actual) = either (pure . parseError) executeHero - $ parse document "" "{ hero(id: \"1\") { friends { name } } }" - Response _ errors' = actual + it "at the beggining of the list" $ do + Right actual <- either (pure . parseError) executeHero + $ parse document "" "{ hero(id: \"1\") { friends { name } } }" + let Response _ errors' = actual Error _ _ path' = fromJust $ Seq.lookup 0 errors' expected = [Segment "hero", Segment "friends", Index 0, Segment "name"] - in path' `shouldBe` expected + in path' `shouldBe` expected context "Subscription" $ it "subscribes" $ do diff --git a/tests/Schemas/HeroSchema.hs b/tests/Schemas/HeroSchema.hs index 71b7a10..63c461c 100644 --- a/tests/Schemas/HeroSchema.hs +++ b/tests/Schemas/HeroSchema.hs @@ -6,7 +6,7 @@ module Schemas.HeroSchema (heroSchema) where -import Control.Exception (Exception(..), SomeException) +import Control.Exception (Exception(..)) import Control.Monad.Catch (throwM) import Language.GraphQL.Error (ResolverException (..)) import qualified Language.GraphQL.Type.In as In @@ -25,11 +25,11 @@ instance Exception HeroException where ResolverException resolverException <- fromException e cast resolverException -heroSchema :: Type.Schema (Either SomeException) +heroSchema :: Type.Schema IO heroSchema = schemaWithTypes Nothing queryType Nothing Nothing [] mempty -type ObjectType = Out.ObjectType (Either SomeException) +type ObjectType = Out.ObjectType IO queryType :: ObjectType queryType = Out.ObjectType "Query" Nothing [] @@ -42,7 +42,7 @@ queryType = Out.ObjectType "Query" Nothing [] $ In.Argument Nothing (In.NamedScalarType Type.id) Nothing heroResolver = pure $ Type.Object mempty -stringField :: Out.Field (Either SomeException) +stringField :: Out.Field IO stringField = Out.Field Nothing (Out.NonNullScalarType Type.string) HashMap.empty heroType :: ObjectType