morpheus-graphql-client 0.28.1 → 0.28.2
raw patch · 12 files changed
+54/−53 lines, 12 filesdep ~bytestringdep ~containersdep ~tastyPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: bytestring, containers, tasty, transformers, unliftio-core, unordered-containers
API changes (from Hackage documentation)
+ Data.Morpheus.Client.CodeGen.Internal: ($dmparseJSON) :: (FromJSON a, Generic a, GFromJSON Zero (Rep a)) => Value -> Parser a
+ Data.Morpheus.Client.CodeGen.Internal: ($dmtoJSON) :: (ToJSON a, Generic a, GToJSON' Value Zero (Rep a)) => a -> Value
- Data.Morpheus.Client: class () => DecodeScalar a
+ Data.Morpheus.Client: class DecodeScalar a
- Data.Morpheus.Client: class () => EncodeScalar a
+ Data.Morpheus.Client: class EncodeScalar a
- Data.Morpheus.Client: class (RequestType a, ToJSON (Args a), FromJSON a) => Fetch a where {
+ Data.Morpheus.Client: class (RequestType a, ToJSON Args a, FromJSON a) => Fetch a where {
- Data.Morpheus.Client: data () => ScalarValue
+ Data.Morpheus.Client: data ScalarValue
- Data.Morpheus.Client: newtype () => ID
+ Data.Morpheus.Client: newtype ID
- Data.Morpheus.Client: type Args a :: Type;
+ Data.Morpheus.Client: type Args a;
- Data.Morpheus.Client: type GQLClientResult (a :: Type) = (Either (FetchError a) a)
+ Data.Morpheus.Client: type GQLClientResult a = Either FetchError a a
- Data.Morpheus.Client: type RequestArgs a :: Type;
+ Data.Morpheus.Client: type RequestArgs a;
- Data.Morpheus.Client.CodeGen.Internal: class () => FromJSON a
+ Data.Morpheus.Client.CodeGen.Internal: class FromJSON a
- Data.Morpheus.Client.CodeGen.Internal: class () => Generic a
+ Data.Morpheus.Client.CodeGen.Internal: class Generic a
- Data.Morpheus.Client.CodeGen.Internal: class () => ToJSON a
+ Data.Morpheus.Client.CodeGen.Internal: class ToJSON a
- Data.Morpheus.Client.CodeGen.Internal: data () => OperationType
+ Data.Morpheus.Client.CodeGen.Internal: data OperationType
- Data.Morpheus.Client.CodeGen.Internal: type RequestArgs a :: Type;
+ Data.Morpheus.Client.CodeGen.Internal: type RequestArgs a;
Files
- morpheus-graphql-client.cabal +13/−13
- src/Data/Morpheus/Client/CodeGen/AST.hs +3/−3
- src/Data/Morpheus/Client/CodeGen/Interpreting/Local.hs +3/−3
- src/Data/Morpheus/Client/CodeGen/Interpreting/PreDeclarations.hs +10/−10
- src/Data/Morpheus/Client/CodeGen/QuasiQuoter.hs +3/−3
- src/Data/Morpheus/Client/Fetch.hs +2/−2
- src/Data/Morpheus/Client/Fetch/RequestType.hs +2/−2
- src/Data/Morpheus/Client/Fetch/ResponseStream.hs +4/−3
- src/Data/Morpheus/Client/Fetch/WebSockets.hs +7/−7
- src/Data/Morpheus/Client/Schema/JSON/Types.hs +1/−1
- test/Case/Github/Test.hs +4/−4
- test/Spec.hs +2/−2
morpheus-graphql-client.cabal view
@@ -1,11 +1,11 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.36.0.+-- This file has been generated from package.yaml by hpack version 0.38.1. -- -- see: https://github.com/sol/hpack name: morpheus-graphql-client-version: 0.28.1+version: 0.28.2 synopsis: Morpheus GraphQL Client description: Build GraphQL APIs with your favorite functional language! category: web, graphql, client@@ -89,8 +89,8 @@ build-depends: aeson >=1.4.4 && <3.0.0 , base >=4.7.0 && <5.0.0- , bytestring >=0.10.4 && <0.15.0- , containers >=0.4.2.1 && <=0.7+ , bytestring >=0.10.4 && <1.0.0+ , containers >=0.4.2.1 && <1.0.0 , file-embed >=0.0.10 && <1.0.0 , modern-uri >=0.1.0.0 && <1.0.0 , morpheus-graphql-code-gen-utils >=0.28.0 && <0.29.0@@ -102,9 +102,9 @@ , req >=3.0.0 && <4.0.0 , template-haskell >=2.0.0 && <3.0.0 , text >=1.2.3 && <3.0.0- , transformers >=0.3.0 && <0.7.0- , unliftio-core >=0.0.1 && <0.4.0- , unordered-containers >=0.2.8 && <0.3.0+ , transformers >=0.3.0 && <1.0.0+ , unliftio-core >=0.0.1 && <1.0.0+ , unordered-containers >=0.2.8 && <1.0.0 , websockets >=0.12.6.0 && <1.0.0 , wuss >=1.0.0 && <3.0.0 default-language: Haskell2010@@ -130,8 +130,8 @@ build-depends: aeson >=1.4.4 && <3.0.0 , base >=4.7.0 && <5.0.0- , bytestring >=0.10.4 && <0.15.0- , containers >=0.4.2.1 && <=0.7+ , bytestring >=0.10.4 && <1.0.0+ , containers >=0.4.2.1 && <1.0.0 , directory >=1.0.0 && <2.0.0 , file-embed >=0.0.10 && <1.0.0 , modern-uri >=0.1.0.0 && <1.0.0@@ -143,13 +143,13 @@ , prettyprinter >=1.7.0 && <2.0.0 , relude >=0.3.0 && <2.0.0 , req >=3.0.0 && <4.0.0- , tasty >=0.1.0 && <=1.5+ , tasty >=0.1.0 && <2.0.0 , tasty-hunit >=0.1.0 && <1.0.0 , template-haskell >=2.0.0 && <3.0.0 , text >=1.2.3 && <3.0.0- , transformers >=0.3.0 && <0.7.0- , unliftio-core >=0.0.1 && <0.4.0- , unordered-containers >=0.2.8 && <0.3.0+ , transformers >=0.3.0 && <1.0.0+ , unliftio-core >=0.0.1 && <1.0.0+ , unordered-containers >=0.2.8 && <1.0.0 , websockets >=0.12.6.0 && <1.0.0 , wuss >=1.0.0 && <3.0.0 default-language: Haskell2010
src/Data/Morpheus/Client/CodeGen/AST.hs view
@@ -115,10 +115,10 @@ mapP (UString v) = prettyLit v mapP (UVar v) = pretty v -list :: Foldable t => t (Doc ann) -> Doc ann+list :: (Foldable t) => t (Doc ann) -> Doc ann list xs = "[" <> indent 1 (foldr1 (\a b -> a <> "," <> line <> b) xs) <> line <> "]" -tuple :: Foldable t => t (Doc ann) -> Doc ann+tuple :: (Foldable t) => t (Doc ann) -> Doc ann tuple ls = "(" <> foldr1 (\a b -> a <> "," <+> b) ls <> ")" instance PrintExp ClientMethod where@@ -162,7 +162,7 @@ printFieldDoc :: AesonField -> Doc n printFieldDoc (v, o, l) = printTHName v <+> printTHName o <+> prettyLit l -prettyLit :: Show a => a -> Doc ann+prettyLit :: (Show a) => a -> Doc ann prettyLit a = pretty (show a) prettyName :: TypeName -> Doc ann
src/Data/Morpheus/Client/CodeGen/Interpreting/Local.hs view
@@ -166,11 +166,11 @@ checkTypename pos path iFace UnionTag {..} | any (member "__typename") (unionTagSelection : toList iFace) = pure () | otherwise =- warning $- withPath+ warning+ $ withPath ("missing \"__typename\" for selection " <> msg unionTagName <> ". this can lead to undesired behavior at runtime!") (map (PropName . unpackName) path)- `at` pos+ `at` pos type Variant = (CodeGenTypeName, Maybe TypeName)
src/Data/Morpheus/Client/CodeGen/Interpreting/PreDeclarations.hs view
@@ -56,7 +56,7 @@ import Language.Haskell.TH.Syntax (Name) import Relude hiding (ToString, Type, toString) -mapPreDeclarations :: MonadFail m => ClientPreDeclaration -> m ClientDeclaration+mapPreDeclarations :: (MonadFail m) => ClientPreDeclaration -> m ClientDeclaration mapPreDeclarations (FromJSONClass mode dec) = InstanceDeclaration mode <$> deriveFromJSON mode dec mapPreDeclarations (FromJSONObjectClass cType CodeGenConstructor {..}) = pure $ InstanceDeclaration TYPE_MODE $ mkFromJSON cType $ FromJSONObjectMethod (getFullName constructorName) (map defField constructorFields)@@ -84,13 +84,13 @@ ] -- FromJSON-deriveFromJSONMethod :: MonadFail m => DERIVING_MODE -> CodeGenType -> m ClientMethod+deriveFromJSONMethod :: (MonadFail m) => DERIVING_MODE -> CodeGenType -> m ClientMethod deriveFromJSONMethod SCALAR_MODE _ = pure $ FunctionNameMethod 'scalarFromJSON deriveFromJSONMethod ENUM_MODE CodeGenType {..} =- pure $- MatchMethod $- map (fromJSONEnum . constructorName) cgConstructors- <> [MFunction "v" 'invalidConstructorError]+ pure+ $ MatchMethod+ $ map (fromJSONEnum . constructorName) cgConstructors+ <> [MFunction "v" 'invalidConstructorError] deriveFromJSONMethod _ CodeGenType {..} = emptyTypeError cgTypeName defField :: CodeGenField -> AesonField@@ -101,7 +101,7 @@ | nullable = '(.:?) | otherwise = '(.:) -deriveToJSONMethod :: MonadFail m => DERIVING_MODE -> CodeGenType -> m (MethodArgument, ClientMethod)+deriveToJSONMethod :: (MonadFail m) => DERIVING_MODE -> CodeGenType -> m (MethodArgument, ClientMethod) deriveToJSONMethod SCALAR_MODE _ = pure (NoArgument, FunctionNameMethod 'scalarToJSON) deriveToJSONMethod _ CodeGenType {cgConstructors = [], ..} = emptyTypeError cgTypeName deriveToJSONMethod ENUM_MODE CodeGenType {cgConstructors} =@@ -129,7 +129,7 @@ fromJSONEnum :: CodeGenTypeName -> MValue fromJSONEnum name = MFrom (typename name) (getFullName name) -deriveToJSON :: MonadFail m => DERIVING_MODE -> CodeGenType -> m (TypeClassInstance ClientMethod)+deriveToJSON :: (MonadFail m) => DERIVING_MODE -> CodeGenType -> m (TypeClassInstance ClientMethod) deriveToJSON mode cType = do (args, expr) <- deriveToJSONMethod mode cType pure@@ -151,8 +151,8 @@ typeClassMethods = [('parseJSON, NoArgument, expr)] } -deriveFromJSON :: MonadFail m => DERIVING_MODE -> CodeGenType -> m (TypeClassInstance ClientMethod)+deriveFromJSON :: (MonadFail m) => DERIVING_MODE -> CodeGenType -> m (TypeClassInstance ClientMethod) deriveFromJSON mode cType = mkFromJSON (cgTypeName cType) <$> deriveFromJSONMethod mode cType -emptyTypeError :: MonadFail m => CodeGenTypeName -> m a+emptyTypeError :: (MonadFail m) => CodeGenTypeName -> m a emptyTypeError name = fail $ show $ internal ("Type " <> msg (getFullName name) <> " Should Have at least one Constructor")
src/Data/Morpheus/Client/CodeGen/QuasiQuoter.hs view
@@ -17,9 +17,9 @@ notSupported :: Text -> a notSupported things =- error $- things- <> " are not supported by the GraphQL QuasiQuoter"+ error+ $ things+ <> " are not supported by the GraphQL QuasiQuoter" -- | QuasiQuoter to insert multiple lines of text in Haskell raw :: QuasiQuoter
src/Data/Morpheus/Client/Fetch.hs view
@@ -28,12 +28,12 @@ ) import Relude hiding (ByteString) -decodeResponse :: FromJSON a => ByteString -> Either (FetchError a) a+decodeResponse :: (FromJSON a) => ByteString -> Either (FetchError a) a decodeResponse = (first FetchErrorParseFailure . eitherDecode) >=> processResponse class (RequestType a, ToJSON (Args a), FromJSON a) => Fetch a where type Args a :: Type- fetch :: Monad m => (ByteString -> m ByteString) -> Args a -> m (Either (FetchError a) a)+ fetch :: (Monad m) => (ByteString -> m ByteString) -> Args a -> m (Either (FetchError a) a) instance (RequestType a, ToJSON (Args a), FromJSON a) => Fetch a where type Args a = RequestArgs a
src/Data/Morpheus/Client/Fetch/RequestType.hs view
@@ -61,7 +61,7 @@ } ) -decodeResponse :: FromJSON a => ByteString -> Either (FetchError a) a+decodeResponse :: (FromJSON a) => ByteString -> Either (FetchError a) a decodeResponse = (first FetchErrorParseFailure . eitherDecode) >=> processResponse processResponse :: JSONResponse a -> Either (FetchError a) a@@ -79,5 +79,5 @@ newtype Request (a :: Type) = Request {requestArgs :: RequestArgs a} -isSubscription :: RequestType a => Request a -> Bool+isSubscription :: (RequestType a) => Request a -> Bool isSubscription x = __type x == OPERATION_SUBSCRIPTION
src/Data/Morpheus/Client/Fetch/ResponseStream.hs view
@@ -39,7 +39,7 @@ import Relude hiding (ByteString) import Text.URI (URI, mkURI) -parseURI :: MonadFail m => String -> m URI+parseURI :: (MonadFail m) => String -> m URI parseURI url = maybe (fail ("Invalid Endpoint: " <> show url <> "!")) pure (mkURI (T.pack url)) requestSingle :: ResponseStream a -> IO (Either (FetchError a) a)@@ -68,7 +68,8 @@ endSession conn sid -- PUBLIC API-data ResponseStream a = ClientTypeConstraint a =>+data ResponseStream a+ = (ClientTypeConstraint a) => ResponseStream { _req :: Request a, _uri :: URI,@@ -83,7 +84,7 @@ pure ResponseStream {_req, _uri, _headers = clientHeaders} -- | returns first response from the server-single :: MonadIO m => ResponseStream a -> m (GQLClientResult a)+single :: (MonadIO m) => ResponseStream a -> m (GQLClientResult a) single = liftIO . requestSingle -- | returns loop listening subscription events forever. if you want to run it in background use `forkIO`
src/Data/Morpheus/Client/Fetch/WebSockets.hs view
@@ -60,12 +60,12 @@ } deriving (Show) -parseProtocol :: MonadFail m => Text -> m Bool+parseProtocol :: (MonadFail m) => Text -> m Bool parseProtocol "ws" = pure False parseProtocol "wss" = pure True parseProtocol p = fail $ "unsupported protocol" <> show p -getWebsocketURI :: MonadFail m => URI -> Headers -> m WebSocketSettings+getWebsocketURI :: (MonadFail m) => URI -> Headers -> m WebSocketSettings getWebsocketURI URI {uriScheme = Just scheme, uriAuthority = Right Authority {authHost, authPort}, uriPath} headers = do isSecure <- parseProtocol $ unRText scheme pure@@ -78,7 +78,7 @@ } getWebsocketURI uri _ = fail ("Invalid Endpoint: " <> show uri <> "!") -toHeader :: IsString a => (Text, Text) -> (a, BS.ByteString)+toHeader :: (IsString a) => (Text, Text) -> (a, BS.ByteString) toHeader (x, y) = (fromString $ T.unpack x, BS.pack $ T.unpack y) _useWS :: WebSocketSettings -> (Connection -> IO a) -> IO a@@ -98,7 +98,7 @@ processMessage ApolloSubscription {apolloPayload = Just payload} = processResponse payload processMessage ApolloSubscription {} = Left (FetchErrorParseFailure "empty message") -decodeMessage :: A.FromJSON a => ByteString -> GQLClientResult a+decodeMessage :: (A.FromJSON a) => ByteString -> GQLClientResult a decodeMessage = (first FetchErrorParseFailure . A.eitherDecode) >=> processMessage initialMessage :: ApolloSubscription ()@@ -116,10 +116,10 @@ endMessage :: Text -> ApolloSubscription () endMessage uid = ApolloSubscription {apolloType = GqlComplete, apolloPayload = Nothing, apolloId = Just uid} -endSession :: MonadIO m => Connection -> Text -> m ()+endSession :: (MonadIO m) => Connection -> Text -> m () endSession conn uid = liftIO $ sendTextData conn $ A.encode $ endMessage uid -receiveResponse :: MonadIO m => A.FromJSON a => Connection -> m (GQLClientResult a)+receiveResponse :: (MonadIO m) => (A.FromJSON a) => Connection -> m (GQLClientResult a) receiveResponse conn = liftIO $ do message <- receiveData conn pure $ decodeMessage message@@ -133,5 +133,5 @@ sendRequest :: (RequestType a, A.ToJSON (RequestArgs a), MonadIO m) => Connection -> Text -> Request a -> m () sendRequest conn uid r = liftIO $ sendTextData conn (encodeRequestMessage uid r) -sendInitialRequest :: MonadIO m => Connection -> m ()+sendInitialRequest :: (MonadIO m) => Connection -> m () sendInitialRequest conn = liftIO $ sendTextData conn (A.encode initialMessage)
src/Data/Morpheus/Client/Schema/JSON/Types.hs view
@@ -91,7 +91,7 @@ where objectParser o = EnumValue <$> o .: "name" -instance FromJSON a => FromJSON (JSONResponse a) where+instance (FromJSON a) => FromJSON (JSONResponse a) where parseJSON = withObject "JSONResponse" objectParser where objectParser o =
test/Case/Github/Test.hs view
@@ -73,16 +73,16 @@ }, edges = Just- [ Just $- GetTagsRepositoryRefsEdges+ [ Just+ $ GetTagsRepositoryRefsEdges { cursor = "test cursor", node = Just GetTagsRepositoryRefsEdgesNode { name = "test name", target =- Just $- GetTagsRepositoryRefsEdgesNodeTargetVariantGitObject+ Just+ $ GetTagsRepositoryRefsEdgesNodeTargetVariantGitObject GetTagsRepositoryRefsEdgesNodeTargetGitObject { __typename = "GitObject" }
test/Spec.hs view
@@ -25,8 +25,8 @@ main :: IO () main =- defaultMain $- testGroup+ defaultMain+ $ testGroup "Client tests" [ Interface.test, LowercaseTypeName.test,