Skip to content

Commit

Permalink
Refactor/ Optimize dependencies update Version to 3.1 (#246)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
nalchevanidze authored Oct 5, 2019
1 parent d232ac4 commit ed666c7
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 24 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand Down
7 changes: 6 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
3 changes: 1 addition & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand Down
9 changes: 4 additions & 5 deletions package.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: morpheus-graphql
version: 0.3.0
version: 0.3.1
github: "nalchevanidze/morpheus-graphql"
license: BSD3
author: "Daviti Nalchevanidze"
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -98,3 +95,5 @@ executables:
- text
- wai
- warp
- wai-websockets >= 1.0 && <= 3.5

22 changes: 10 additions & 12 deletions src/Data/Morpheus/Execution/Server/Resolve.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 (..))
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions stack.yaml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit ed666c7

Please sign in to comment.