From ed666c7a8fde1c01855964cfa2edcf31b0f5936a Mon Sep 17 00:00:00 2001 From: nalchevanidze Date: Sat, 5 Oct 2019 12:56:47 +0200 Subject: [PATCH] Refactor/ Optimize dependencies update Version to 3.1 (#246) * cleanup aeson remove attoparsec * remove uft8-string * move wei to api file * resolver 13.30 * resolver 13.30 * update changelog * resolver 13.30 * version: 0.3.1 * update docs --- README.md | 3 +-- changelog.md | 7 +++++- docs/index.md | 3 +-- package.yaml | 9 ++++---- src/Data/Morpheus/Execution/Server/Resolve.hs | 22 +++++++++---------- stack.yaml | 3 +-- 6 files changed, 23 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index c059edc716..c050aa213f 100644 --- a/README.md +++ b/README.md @@ -26,10 +26,9 @@ Additionally, you should tell stack which version to pick: _stack.yml_ ```yaml -resolver: lts-13.24 +resolver: lts-13.30 extra-deps: - - megaparsec-7.0.5 - aeson-1.4.4.0 - time-compat-1.9.2.2 ``` diff --git a/changelog.md b/changelog.md index 36ac67963c..e9b248f0d1 100644 --- a/changelog.md +++ b/changelog.md @@ -1,4 +1,9 @@ -## [0.3.1] - \*.2019 +## [0.3.1] - 05.10.2019 + +### Changed + +- removed dependencies: attoparsec , utf8-string +- updated aeson lower bound up to: 1.4.4.0 ## [0.3.0] - 04.10.2019 diff --git a/docs/index.md b/docs/index.md index 6b00c63c2e..d42ff9ab42 100644 --- a/docs/index.md +++ b/docs/index.md @@ -29,10 +29,9 @@ Additionally, you should tell stack which version to pick: _stack.yml_ ```yaml -resolver: lts-13.24 +resolver: lts-13.30 extra-deps: - - megaparsec-7.0.5 - aeson-1.4.4.0 - time-compat-1.9.2.2 ``` diff --git a/package.yaml b/package.yaml index 727c0e4925..833589aacc 100644 --- a/package.yaml +++ b/package.yaml @@ -1,5 +1,5 @@ name: morpheus-graphql -version: 0.3.0 +version: 0.3.1 github: "nalchevanidze/morpheus-graphql" license: BSD3 author: "Daviti Nalchevanidze" @@ -25,8 +25,7 @@ data-files: dependencies: - base >= 4.7 && < 5 - megaparsec >= 7.0.0 && < 8.0 - - aeson >= 1.4.4.0 && <= 1.5 - - attoparsec >= 0.13.2 && < 0.14 + - aeson >= 1.4.4.0 && <= 1.6 - bytestring >= 0.10.4 && < 0.11 - text >= 1.2.3.0 && < 1.3 - containers >= 0.4.2.1 && < 0.7 @@ -36,8 +35,6 @@ dependencies: - vector >= 0.12.0.1 && < 0.13 - mtl >= 2.0 && <= 2.2.2 - websockets >= 0.11.0 && <= 0.12.5.3 - - wai-websockets >= 1.0 && <= 3.5 - - utf8-string >= 1.0.1 && < 1.1 - uuid >= 1.0 && <= 1.4 - template-haskell - lens @@ -98,3 +95,5 @@ executables: - text - wai - warp + - wai-websockets >= 1.0 && <= 3.5 + diff --git a/src/Data/Morpheus/Execution/Server/Resolve.hs b/src/Data/Morpheus/Execution/Server/Resolve.hs index 11ac42139d..fb3bbb3234 100644 --- a/src/Data/Morpheus/Execution/Server/Resolve.hs +++ b/src/Data/Morpheus/Execution/Server/Resolve.hs @@ -15,13 +15,11 @@ module Data.Morpheus.Execution.Server.Resolve , fullSchema ) where -import qualified Codec.Binary.UTF8.String as UTF8 import Control.Monad.Except (liftEither) import Control.Monad.Trans.Except (ExceptT (..), runExceptT) -import Data.Aeson (Result (..), encode, fromJSON) -import Data.Aeson.Parser (jsonNoDup) -import Data.Attoparsec.ByteString (parseOnly) -import qualified Data.ByteString as S +import Data.Aeson (encode) +import Data.Aeson.Internal (formatError, ifromJSON) +import Data.Aeson.Parser (eitherDecodeWith, jsonNoDup) import qualified Data.ByteString.Lazy.Char8 as L import Data.Functor.Identity (Identity (..)) import Data.Proxy (Proxy (..)) @@ -64,17 +62,17 @@ type RootResCon m event cont query mutation subscription , EncodeMutCon m event cont mutation , EncodeSubCon m event cont subscription) -decodeNoDup :: L.ByteString -> Result GQLRequest -decodeNoDup bs = - case parseOnly jsonNoDup (S.pack . UTF8.encode $ L.unpack bs) of - Left e -> Error e - Right v -> fromJSON v +decodeNoDup :: L.ByteString -> Either String GQLRequest +decodeNoDup str = + case eitherDecodeWith jsonNoDup ifromJSON str of + Left (path, x) -> Left $ formatError path x + Right value -> Right value byteStringIO :: Monad m => (GQLRequest -> m GQLResponse) -> L.ByteString -> m L.ByteString byteStringIO resolver request = case decodeNoDup request of - Error aesonError' -> return $ badRequestError aesonError' - Success req -> encode <$> resolver req + Left aesonError' -> return $ badRequestError aesonError' + Right req -> encode <$> resolver req statelessResolver :: (Monad m, RootResCon m s cont query mut sub) diff --git a/stack.yaml b/stack.yaml index 26ebf77efb..d2d3c00afb 100644 --- a/stack.yaml +++ b/stack.yaml @@ -1,7 +1,6 @@ # ghc 8.6.5 -resolver: lts-13.24 +resolver: lts-13.30 extra-deps: - - megaparsec-7.0.5 - aeson-1.4.4.0 - time-compat-1.9.2.2