Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 0 additions & 43 deletions src/GraphQL/Client/Query.purs
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,16 @@ module GraphQL.Client.Query
, mutationOpts
, mutationOptsWithDecoder
, mutationWithDecoder
, mutation_
, query
, queryFullRes
, queryJson
, queryOpts
, queryOptsWithDecoder
, queryWithDecoder
, query_
) where

import Prelude

import Affjax (URL)
import Control.Monad.Error.Class (class MonadThrow)
import Control.Monad.Except (class MonadError, catchError)
import Data.Argonaut.Core (Json, stringify)
Expand All @@ -32,9 +29,7 @@ import Data.Either (Either(..), hush)
import Data.Maybe (Maybe(..))
import Data.Traversable (traverse)
import Effect.Aff (Aff, Error, error, message, throwError)
import Effect.Class (liftEffect)
import Foreign.Object (Object)
import GraphQL.Client.BaseClients.Urql (UrqlClient, createGlobalClientUnsafe)
import GraphQL.Client.GqlError (GqlError)
import GraphQL.Client.Operation (OpMutation, OpQuery)
import GraphQL.Client.SafeQueryName (safeQueryName)
Expand Down Expand Up @@ -97,26 +92,6 @@ query
-> Aff returns
query = queryWithDecoder decodeJson

-- | A create client and query shortcut that creates a global client and caches it for future calls.
-- | `query` is a safer option for production environments and should generally be used
query_
:: forall directives schema query returns
. GqlQuery directives OpQuery schema query returns
=> DecodeJson returns
=> URL
-> Proxy schema
-> String
-> query
-> Aff returns
query_ url _ name q = do
client <-
liftEffect
$ createGlobalClientUnsafe
{ url
, headers: []
}
query (client :: Client UrqlClient { directives :: Proxy directives, query :: schema | _ }) name q

mutationWithDecoder
:: forall client directives schema mutation returns queryOpts mutationOpts sr
. QueryClient client queryOpts mutationOpts
Expand Down Expand Up @@ -167,24 +142,6 @@ mutationOpts
-> Aff returns
mutationOpts = mutationOptsWithDecoder decodeJson

mutation_
:: forall directives schema mutation returns
. GqlQuery directives OpMutation schema mutation returns
=> DecodeJson returns
=> URL
-> Proxy schema
-> String
-> mutation
-> Aff returns
mutation_ url _ name q = do
client <-
liftEffect
$ createGlobalClientUnsafe
{ url
, headers: []
}
mutation (client :: Client UrqlClient { directives :: Proxy directives, mutation :: schema | _ }) name q

runQuery
:: forall client directives schema query returns qOpts mOpts
. QueryClient client qOpts mOpts
Expand Down
Loading