packages feed

graphql-client 1.2.1 → 1.2.2

raw patch · 15 files changed

+104/−101 lines, 15 filesdep ~mtldep ~transformersnew-uploaderPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependency ranges changed: mtl, transformers

API changes (from Hackage documentation)

- Data.GraphQL.Monad: class Monad m => MonadGraphQLQuery m
+ Data.GraphQL.Monad: class (Monad m) => MonadGraphQLQuery m
- Data.GraphQL.Monad.Class: class Monad m => MonadGraphQLQuery m
+ Data.GraphQL.Monad.Class: class (Monad m) => MonadGraphQLQuery m
- Data.GraphQL.Query: class IsSchema (ResultSchema query) => GraphQLQuery query where {
+ Data.GraphQL.Query: class (IsSchema (ResultSchema query)) => GraphQLQuery query where {

Files

CHANGELOG.md view
@@ -1,3 +1,8 @@+# v1.2.2++* Add support for GHC 9.6+* Fix escaping issues in generated code (e.g. literal strings in graphql queries) ([#80](https://github.com/brandonchinn178/graphql-client/issues/80))+ # v1.2.1  * Add support for GHC 9.4@@ -16,7 +21,7 @@  Bug fixes: -* Generate enums that only appear in query arguments ([#59](https://github.com/LeapYear/graphql-client/pull/59))+* Generate enums that only appear in query arguments ([#59](https://github.com/brandonchinn178/graphql-client/pull/59))  # v1.1.0 
− LICENSE
@@ -1,11 +0,0 @@-Copyright 2020 LeapYear--Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:--1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.--2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.--3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.--THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ LICENSE.md view
@@ -0,0 +1,11 @@+Copyright © 2023-present Brandon Chinn++Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:++1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.++2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.++3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
README.md view
@@ -1,7 +1,7 @@ # graphql-client -[![GitHub Actions](https://img.shields.io/github/workflow/status/LeapYear/graphql-client/CI/main)](https://github.com/LeapYear/graphql-client/actions?query=branch%3Amain)-[![codecov](https://codecov.io/gh/LeapYear/graphql-client/branch/main/graph/badge.svg?token=WIOxotqPTN)](https://codecov.io/gh/LeapYear/graphql-client)+[![GitHub Actions](https://img.shields.io/github/actions/workflow/status/brandonchinn178/graphql-client/ci.yml?branch=main)](https://github.com/brandonchinn178/graphql-client/actions?query=branch%3Amain)+[![codecov](https://codecov.io/gh/brandonchinn178/graphql-client/branch/main/graph/badge.svg?token=WIOxotqPTN)](https://codecov.io/gh/brandonchinn178/graphql-client) [![Hackage](https://img.shields.io/hackage/v/graphql-client)](https://hackage.haskell.org/package/graphql-client)  A client for Haskell applications to query [GraphQL](https://graphql.org) APIs. This package provides two resources:@@ -117,7 +117,7 @@ main :: IO () main = do   let graphQLSettings = defaultGraphQLSettings-        { url = "https://graphbrainz.herokuapp.com/"+        { url = "https://graphbrainz.fly.dev"           -- ^ Most GraphQL APIs are at the path `/graphql`, but not this one         } 
graphql-client.cabal view
@@ -1,20 +1,20 @@ cabal-version: >= 1.10 --- This file has been generated from package.yaml by hpack version 0.35.0.+-- This file has been generated from package.yaml by hpack version 0.35.2. -- -- see: https://github.com/sol/hpack  name:           graphql-client-version:        1.2.1+version:        1.2.2 synopsis:       A client for Haskell programs to query a GraphQL API description:    A client for Haskell programs to query a GraphQL API. category:       Graphql-homepage:       https://github.com/LeapYear/graphql-client#readme-bug-reports:    https://github.com/LeapYear/graphql-client/issues-author:         Brandon Chinn <brandon@leapyear.io>-maintainer:     Brandon Chinn <brandon@leapyear.io>+homepage:       https://github.com/brandonchinn178/graphql-client#readme+bug-reports:    https://github.com/brandonchinn178/graphql-client/issues+author:         Brandon Chinn <brandonchinn178@gmail.com>+maintainer:     Brandon Chinn <brandonchinn178@gmail.com> license:        BSD3-license-file:   LICENSE+license-file:   LICENSE.md build-type:     Simple extra-source-files:     README.md@@ -26,7 +26,7 @@  source-repository head   type: git-  location: https://github.com/LeapYear/graphql-client+  location: https://github.com/brandonchinn178/graphql-client  library   exposed-modules:@@ -50,10 +50,10 @@     , http-client >=0.5.13.1 && <0.8     , http-client-tls >=0.3.5.3 && <0.4     , http-types >=0.12.1 && <0.13-    , mtl >=2.2.2 && <2.3+    , mtl >=2.2.2 && <2.4     , template-haskell >=2.16 && <3     , text >=1.2.3.0 && <2.1-    , transformers >=0.5.2.0 && <0.6+    , transformers >=0.5.2.0 && <0.7     , unliftio-core >=0.1.1.0 && <0.3   default-language: Haskell2010   if impl(ghc >= 8.0)@@ -71,9 +71,9 @@     , bytestring >=0.10.8.2 && <0.12     , file-embed >=0.0.10.1 && <0.1     , graphql-client-    , optparse-applicative >=0.14.2.0 && <0.18+    , optparse-applicative >=0.14.2.0 && <0.19     , path >=0.6.1 && <0.10-    , path-io >=1.3.3 && <1.8+    , path-io >=1.3.3 && <2     , template-haskell >=2.16 && <3     , typed-process >=0.2.3.0 && <0.3   default-language: Haskell2010
js/graphql-codegen-haskell.js view
@@ -53378,6 +53378,8 @@  var template = "{- This file was automatically generated and should not be edited. -}\n\n{-# LANGUAGE DataKinds #-}\n{-# LANGUAGE DuplicateRecordFields #-}\n{-# LANGUAGE OverloadedStrings #-}\n{-# LANGUAGE QuasiQuotes #-}\n{-# LANGUAGE TypeFamilies #-}\n{-# OPTIONS_GHC -w #-}\n\nmodule {{apiModule}} where\n\nimport Data.GraphQL\nimport Data.GraphQL.Bootstrap\n\nimport {{scalarsModule}}\n{{#enumModules}}\nimport {{.}}\n{{/enumModules}}\n\n{{#operations}}\n{-----------------------------------------------------------------------------\n-- {{name}}\n\n-- result :: Object {{schemaType}}; throws a GraphQL exception on errors\nresult <- runQuery {{queryName}}\n  {{#overArgs}}\n  { _{{arg}} = ...\n  {{/overArgs}}\n  }\n\n-- result :: GraphQLResult (Object {{schemaType}})\nresult <- runQuerySafe {{queryName}}\n  {{#overArgs}}\n  { _{{arg}} = ...\n  {{/overArgs}}\n  }\n-----------------------------------------------------------------------------}\n\ndata {{queryName}} = {{queryName}}\n  {{#overArgs}}\n  { _{{arg}} :: {{type}}\n  {{/overArgs}}\n  }\n  deriving (Show)\n\ntype {{schemaType}} = [schema|\n  {{schema}}\n|]\n\ninstance GraphQLQuery {{queryName}} where\n  type ResultSchema {{queryName}} = {{schemaType}}\n\n  getQueryName _ = \"{{name}}\"\n\n  getQueryText _ = [query|\n    {{queryText}}\n  |]\n\n  getArgs query = object\n    {{#overArgs}}\n    [ \"{{arg}}\" .= _{{arg}} (query :: {{queryName}})\n    {{/overArgs}}\n    ]\n\n{{/operations}}\n"; +// globally disable html-escaping
+mustache.escape = function (x) { return x; };
 var renderAPIModule = function (config, enumModules, operations) {
     return mustache.render(template, __assign(__assign({}, config), { enumModules: enumModules, operations: operations.map(function (operation) { return (__assign(__assign({}, operation), { queryText: indent$3(indent$3(operation.queryText)), schema: indent$3(renderAesonSchema(operation.schema)), args: operation.args.map(function (_a) {
                 var name = _a.name, type = _a.type;
js/mocks/__utils.js view
@@ -1,6 +1,6 @@ /* global Proxy */ -const GITHUB_URL = 'https://github.com/LeapYear/graphql-client'+const GITHUB_URL = 'https://github.com/brandonchinn178/graphql-client' const ISSUE_PATH = `${GITHUB_URL}/issues`  module.exports = {
src/Data/GraphQL.hs view
@@ -1,6 +1,6 @@-{- |+{-| Module      :  Data.GraphQL-Maintainer  :  Brandon Chinn <brandon@leapyear.io>+Maintainer  :  Brandon Chinn <brandonchinn178@gmail.com> Stability   :  experimental Portability :  portable 
src/Data/GraphQL/Bootstrap.hs view
@@ -1,6 +1,6 @@-{- |+{-| Module      :  Data.GraphQL.Bootstrap-Maintainer  :  Brandon Chinn <brandon@leapyear.io>+Maintainer  :  Brandon Chinn <brandonchinn178@gmail.com> Stability   :  experimental Portability :  portable 
src/Data/GraphQL/Error.hs view
@@ -2,9 +2,9 @@ {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE OverloadedStrings #-} -{- |+{-| Module      :  Data.GraphQL.Error-Maintainer  :  Brandon Chinn <brandon@leapyear.io>+Maintainer  :  Brandon Chinn <brandonchinn178@gmail.com> Stability   :  experimental Portability :  portable 
src/Data/GraphQL/Monad.hs view
@@ -6,9 +6,9 @@ {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeOperators #-} -{- |+{-| Module      :  Data.GraphQL.Monad-Maintainer  :  Brandon Chinn <brandon@leapyear.io>+Maintainer  :  Brandon Chinn <brandonchinn178@gmail.com> Stability   :  experimental Portability :  portable @@ -70,18 +70,17 @@   , modifyReq :: Request -> Request   } -{- | Default settings for 'GraphQLSettings'. Requires 'url' field to be overridden.-- Example usage:-- >>> defaultGraphQLSettings- ...   { url = "https://api.github.com/graphql"- ...   , modifyReq = \\req -> req- ...       { requestHeaders =- ...           (hAuthorization, "bearer my_github_token") : requestHeaders req- ...       }- ...   }--}+-- | Default settings for 'GraphQLSettings'. Requires 'url' field to be overridden.+--+--  Example usage:+--+--  >>> defaultGraphQLSettings+--  ...   { url = "https://api.github.com/graphql"+--  ...   , modifyReq = \\req -> req+--  ...       { requestHeaders =+--  ...           (hAuthorization, "bearer my_github_token") : requestHeaders req+--  ...       }+--  ...   } defaultGraphQLSettings :: GraphQLSettings defaultGraphQLSettings =   GraphQLSettings@@ -113,9 +112,9 @@ -- | Execute a GraphQL query with the given 'GraphQLManager'. runQuerySafeIO ::   (GraphQLQuery query, schema ~ ResultSchema query) =>-  GraphQLManager ->-  query ->-  IO (GraphQLResult (Object schema))+  GraphQLManager+  -> query+  -> IO (GraphQLResult (Object schema)) runQuerySafeIO GraphQLManager{..} query = httpLbs request manager >>= decodeBody   where     request =@@ -133,17 +132,16 @@  {- GraphQLQueryT monad transformer -} -{- | The monad transformer type that can be used to run GraphQL queries.-- @- newtype MyMonad a = MyMonad { unMyMonad :: GraphQLQueryT IO a }-- runMyMonad :: MyMonad a -> IO a- runMyMonad = runGraphQLQueryT graphQLSettings . unMyMonad-   where-     graphQLSettings = defaultGraphQLSettings{url = "https://api.github.com/graphql"}- @--}+-- | The monad transformer type that can be used to run GraphQL queries.+--+--  @+--  newtype MyMonad a = MyMonad { unMyMonad :: GraphQLQueryT IO a }+--+--  runMyMonad :: MyMonad a -> IO a+--  runMyMonad = runGraphQLQueryT graphQLSettings . unMyMonad+--    where+--      graphQLSettings = defaultGraphQLSettings{url = "https://api.github.com/graphql"}+--  @ newtype GraphQLQueryT m a = GraphQLQueryT {unGraphQLQueryT :: ReaderT GraphQLManager m a}   deriving     ( Functor@@ -153,16 +151,16 @@     , MonadTrans     ) -instance MonadUnliftIO m => MonadUnliftIO (GraphQLQueryT m) where+instance (MonadUnliftIO m) => MonadUnliftIO (GraphQLQueryT m) where   withRunInIO inner = GraphQLQueryT $ withRunInIO $ \run -> inner (run . unGraphQLQueryT) -instance MonadIO m => MonadGraphQLQuery (GraphQLQueryT m) where+instance (MonadIO m) => MonadGraphQLQuery (GraphQLQueryT m) where   runQuerySafe query = do     manager <- GraphQLQueryT ask     liftIO $ runQuerySafeIO manager query  -- | Run the GraphQLQueryT monad transformer.-runGraphQLQueryT :: MonadIO m => GraphQLSettings -> GraphQLQueryT m a -> m a+runGraphQLQueryT :: (MonadIO m) => GraphQLSettings -> GraphQLQueryT m a -> m a runGraphQLQueryT settings m = do   manager <- liftIO $ initGraphQLManager settings   (`runReaderT` manager) . unGraphQLQueryT $ m
src/Data/GraphQL/Monad/Class.hs view
@@ -5,9 +5,9 @@ {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeOperators #-} -{- |+{-| Module      :  Data.GraphQL.Monad.Class-Maintainer  :  Brandon Chinn <brandon@leapyear.io>+Maintainer  :  Brandon Chinn <brandonchinn178@gmail.com> Stability   :  experimental Portability :  portable @@ -39,18 +39,18 @@ import Data.GraphQL.Result (GraphQLResult, getErrors, getResult)  -- | A type class for monads that can run GraphQL queries.-class Monad m => MonadGraphQLQuery m where+class (Monad m) => MonadGraphQLQuery m where   -- | Run the given query and return the 'GraphQLResult'.   runQuerySafe ::     (GraphQLQuery query, schema ~ ResultSchema query) =>-    query ->-    m (GraphQLResult (Object schema))+    query+    -> m (GraphQLResult (Object schema))  -- | Run the given query and returns the result, erroring if the query returned errors. runQuery ::   (MonadIO m, MonadGraphQLQuery m, GraphQLQuery query, schema ~ ResultSchema query) =>-  query ->-  m (Object schema)+  query+  -> m (Object schema) runQuery query = do   result <- runQuerySafe query   case getErrors result of@@ -59,16 +59,16 @@  {- Instances for common monad transformers -} -instance MonadGraphQLQuery m => MonadGraphQLQuery (ReaderT r m) where+instance (MonadGraphQLQuery m) => MonadGraphQLQuery (ReaderT r m) where   runQuerySafe = lift . runQuerySafe -instance MonadGraphQLQuery m => MonadGraphQLQuery (ExceptT e m) where+instance (MonadGraphQLQuery m) => MonadGraphQLQuery (ExceptT e m) where   runQuerySafe = lift . runQuerySafe -instance MonadGraphQLQuery m => MonadGraphQLQuery (IdentityT m) where+instance (MonadGraphQLQuery m) => MonadGraphQLQuery (IdentityT m) where   runQuerySafe = lift . runQuerySafe -instance MonadGraphQLQuery m => MonadGraphQLQuery (MaybeT m) where+instance (MonadGraphQLQuery m) => MonadGraphQLQuery (MaybeT m) where   runQuerySafe = lift . runQuerySafe  instance (Monoid w, MonadGraphQLQuery m) => MonadGraphQLQuery (Lazy.RWST r w s m) where@@ -77,10 +77,10 @@ instance (Monoid w, MonadGraphQLQuery m) => MonadGraphQLQuery (Strict.RWST r w s m) where   runQuerySafe = lift . runQuerySafe -instance MonadGraphQLQuery m => MonadGraphQLQuery (Lazy.StateT s m) where+instance (MonadGraphQLQuery m) => MonadGraphQLQuery (Lazy.StateT s m) where   runQuerySafe = lift . runQuerySafe -instance MonadGraphQLQuery m => MonadGraphQLQuery (Strict.StateT s m) where+instance (MonadGraphQLQuery m) => MonadGraphQLQuery (Strict.StateT s m) where   runQuerySafe = lift . runQuerySafe  instance (Monoid w, MonadGraphQLQuery m) => MonadGraphQLQuery (Lazy.WriterT w m) where
src/Data/GraphQL/Query.hs view
@@ -1,11 +1,11 @@+{-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE TypeFamilies #-}-{-# LANGUAGE TypeInType #-} -{- |+{-| Module      :  Data.GraphQL.Query-Maintainer  :  Brandon Chinn <brandon@leapyear.io>+Maintainer  :  Brandon Chinn <brandonchinn178@gmail.com> Stability   :  experimental Portability :  portable @@ -23,22 +23,20 @@ import Language.Haskell.TH.Quote (QuasiQuoter (..)) import Language.Haskell.TH.Syntax (lift) -{- | A type class for defining GraphQL queries.-- Should be generated via the `graphql-codegen` command. Any manual instances needs- to be certain that `getArgs query` satisfies the arguments defined in- `getQueryText query`, and that the result adheres to `ResultSchema query`.--}-class IsSchema (ResultSchema query) => GraphQLQuery query where+-- | A type class for defining GraphQL queries.+--+--  Should be generated via the `graphql-codegen` command. Any manual instances needs+--  to be certain that `getArgs query` satisfies the arguments defined in+--  `getQueryText query`, and that the result adheres to `ResultSchema query`.+class (IsSchema (ResultSchema query)) => GraphQLQuery query where   type ResultSchema query :: Schema   getQueryName :: query -> Text   getQueryText :: query -> Text   getArgs :: query -> Value -{- | A quasiquoter that interpolates the given string as raw text.-- Trying to avoid a dependency on raw-strings-qq--}+-- | A quasiquoter that interpolates the given string as raw text.+--+--  Trying to avoid a dependency on raw-strings-qq query :: QuasiQuoter query =   QuasiQuoter
src/Data/GraphQL/Result.hs view
@@ -2,9 +2,9 @@ {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE OverloadedStrings #-} -{- |+{-| Module      :  Data.GraphQL.Result-Maintainer  :  Brandon Chinn <brandon@leapyear.io>+Maintainer  :  Brandon Chinn <brandonchinn178@gmail.com> Stability   :  experimental Portability :  portable @@ -27,7 +27,7 @@   }   deriving (Show, Functor, Foldable, Traversable) -instance FromJSON r => FromJSON (GraphQLResult r) where+instance (FromJSON r) => FromJSON (GraphQLResult r) where   parseJSON = withObject "GraphQLResult" $ \o ->     GraphQLResult       <$> o .:? "errors" .!= []
src/Data/GraphQL/TestUtils.hs view
@@ -4,9 +4,9 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE StandaloneDeriving #-} -{- |+{-| Module      :  Data.GraphQL.TestUtils-Maintainer  :  Brandon Chinn <brandon@leapyear.io>+Maintainer  :  Brandon Chinn <brandonchinn178@gmail.com> Stability   :  experimental Portability :  portable @@ -46,7 +46,7 @@  deriving instance Show AnyResultMock -isMatch :: GraphQLQuery query => query -> AnyResultMock -> Bool+isMatch :: (GraphQLQuery query) => query -> AnyResultMock -> Bool isMatch testQuery (AnyResultMock mock) = getArgs (query mock) == getArgs testQuery  getResult :: AnyResultMock -> Value@@ -57,7 +57,7 @@ newtype MockQueryT m a = MockQueryT {unMockQueryT :: StateT [AnyResultMock] m a}   deriving (Functor, Applicative, Monad, MonadIO, MonadState [AnyResultMock], MonadTrans) -instance Monad m => MonadGraphQLQuery (MockQueryT m) where+instance (Monad m) => MonadGraphQLQuery (MockQueryT m) where   runQuerySafe testQuery = toGraphQLResult <$> lookupMock     where       takeWhere :: (a -> Bool) -> [a] -> Maybe (a, [a])@@ -72,7 +72,7 @@           Just (mock, mocks') -> (getResult mock, mocks')           Nothing -> error $ "No more mocked responses for query: " ++ Text.unpack (getQueryName testQuery) -      toGraphQLResult :: FromJSON a => Value -> a+      toGraphQLResult :: (FromJSON a) => Value -> a       toGraphQLResult mockData =         either error id . Aeson.parseEither Aeson.parseJSON $           object@@ -80,5 +80,5 @@             , "data" .= Just mockData             ] -runMockQueryT :: Monad m => MockQueryT m a -> [AnyResultMock] -> m a+runMockQueryT :: (Monad m) => MockQueryT m a -> [AnyResultMock] -> m a runMockQueryT mockQueryT mocks = (`evalStateT` mocks) . unMockQueryT $ mockQueryT