Update for PureScript 0.15.0

This commit is contained in:
Mark Eibes 2022-04-21 13:48:21 +02:00
parent b83fcc13d5
commit c1dbab5f09
10 changed files with 1664 additions and 27 deletions

4
.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
.spago/
output/
node_modules/
.psc-ide-port

1
.psc-ide-port Normal file
View File

@ -0,0 +1 @@
15802

View File

@ -3,7 +3,7 @@
Type-safe graphql queries using functional dependencies.
Use the `GraphQLReqRes` class to define expected input and output.
Then, create a `client` and use it to interact with your API.
Then, create a `client` and use it to interact with your API.
```purescript
endpoint = "https://api.react-finland.fi/graphql" :: String
@ -44,7 +44,7 @@ instance graphqlReactFinlandConference ::
)
client :: GraphQLClient
client = graphQL "https://api.react-finland.fi/graphql" []
client = graphQL "https://api.react-finland.fi/graphql" [] driver
main ∷ Effect Unit
main =
@ -56,4 +56,4 @@ main =
Log.info $ show speakers
```
You can check out the [test](./test/Main.purs) for a full example.
You can check out the [test](./test/Main.purs) for a full example.

1599
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{
"name": "purescript-graphql-fundeps",
"version": "0.0.0",
"version": "0.1.0",
"scripts": {
"postinstall": "spago install && spago build",
"test": "spago -x test.dhall test"
@ -9,8 +9,8 @@
"author": "",
"license": "ISC",
"devDependencies": {
"purescript": "^0.14.1",
"spago": "^0.20.3",
"purescript": "^0.15.0",
"spago": "^0.21.0",
"xhr2": "^0.2.1"
}
}

View File

@ -99,6 +99,56 @@ in upstream
-------------------------------
-}
let upstream =
https://github.com/purescript/package-sets/releases/download/psc-0.14.1-20210516/packages.dhall sha256:f5e978371d4cdc4b916add9011021509c8d869f4c3f6d0d2694c0e03a85046c8
https://raw.githubusercontent.com/purescript/package-sets/prepare-0.15/src/packages.dhall
sha256:b1c6d06132b7cbf1e93b1e5343044fba1604b50bfbe02d8f80a3002e71569c59
in upstream
with variant =
{ dependencies =
[ "enums"
, "lists"
, "maybe"
, "partial"
, "prelude"
, "record"
, "tuples"
, "unsafe-coerce"
]
, repo =
"https://github.com/working-group-purescript-es/purescript-variant.git"
, version = "v0.15.0-update"
}
with simple-json =
{ dependencies =
[ "arrays"
, "exceptions"
, "foreign-object"
, "foreign"
, "nullable"
, "prelude"
, "record"
, "typelevel-prelude"
, "variant"
]
, repo =
"https://github.com/working-group-purescript-es/purescript-simple-json.git"
, version = "v0.15.0-update"
}
with spec =
{ repo = "https://github.com/purescript-spec/purescript-spec.git"
, version = "master"
, dependencies =
[ "aff"
, "ansi"
, "avar"
, "console"
, "exceptions"
, "foldable-traversable"
, "fork"
, "now"
, "pipes"
, "prelude"
, "strings"
, "transformers"
]
}

View File

@ -21,7 +21,6 @@ to generate this file without the comments in this block.
, "maybe"
, "media-types"
, "prelude"
, "psci-support"
, "simple-json"
, "strings"
]

View File

@ -2,6 +2,7 @@ module GraphQL.FunDeps where
import Prelude
import Affjax (AffjaxDriver)
import Affjax as AX
import Affjax.RequestBody as RequestBody
import Affjax.RequestHeader (RequestHeader(..))
@ -31,8 +32,8 @@ type GraphQLClient' (operation :: GraphQL) (gql :: Symbol) (i :: Row Type) (o ::
type GraphQLClient = forall (operation :: GraphQL) (gql :: Symbol) (i :: Row Type) (o :: Row Type). GraphQLClient' operation gql i o
graphQL :: Endpoint -> Array RequestHeader -> GraphQLClient
graphQL endpoint headers = go
graphQL :: Endpoint -> Array RequestHeader -> AffjaxDriver -> GraphQLClient
graphQL endpoint headers driver = go
where
go :: forall (operation :: GraphQL) (gql :: Symbol) (i :: Row Type) (o :: Row Type). GraphQLReqRes operation gql i o => IsSymbol gql => JSON.WriteForeign { | i } => JSON.ReadForeign { | o } => Gql operation -> Record i -> Aff { | o }
go _ variables = do
@ -42,7 +43,7 @@ graphQL endpoint headers = go
, query: String.replaceAll (String.Pattern "\n") (String.Replacement " ") (String.replaceAll (String.Pattern "\r\n") (String.Replacement " ") (reflectSymbol (Proxy :: Proxy gql)))
}
res <-
AX.request
AX.request driver
( AX.defaultRequest
{ url = endpoint
, method = Left POST

View File

@ -1,6 +1,8 @@
let conf = ./spago.dhall
in conf // {
sources = conf.sources # [ "test/**/*.purs" ],
dependencies = conf.dependencies # [ "spec", "foldable-traversable" ]
}
in conf
// { sources = conf.sources # [ "test/**/*.purs" ]
, dependencies =
conf.dependencies
# [ "spec", "foldable-traversable", "affjax-node" ]
}

View File

@ -1,6 +1,9 @@
module Test.Main where
import Prelude
import Affjax (AffjaxDriver)
import Affjax.Node as AffjaxNode
import Data.Foldable (for_)
import Data.Maybe (Maybe(..))
import Effect (Effect)
@ -49,7 +52,7 @@ instance graphqlReactFinlandConference ::
)
client :: GraphQLClient
client = graphQL "https://api.react-finland.fi/graphql" []
client = graphQL "https://api.react-finland.fi/graphql" [] AffjaxNode.driver
main ∷ Effect Unit
main =