Updates to ps15 syntax

This commit is contained in:
Mike Solomon 2023-06-20 09:43:35 +03:00
commit 688358b8af
10 changed files with 29 additions and 1714 deletions

6
.gitignore vendored
View File

@ -1,3 +1,3 @@
.spago
node_modules
output
.spago/
output/
node_modules/

1
.psc-ide-port Normal file
View File

@ -0,0 +1 @@
15162

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.

1593
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,9 +9,9 @@
"author": "",
"license": "ISC",
"devDependencies": {
"purescript": "^0.14.1",
"purescript": "^0.15.9",
"purs-tidy": "^0.10.0",
"spago": "^0.20.3",
"spago": "^0.21.0",
"xhr2": "^0.2.1"
}
}

View File

@ -1,104 +1,5 @@
{-
Welcome to your new Dhall package-set!
Below are instructions for how to edit this file for most use
cases, so that you don't need to know Dhall to use it.
## Use Cases
Most will want to do one or both of these options:
1. Override/Patch a package's dependency
2. Add a package not already in the default package set
This file will continue to work whether you use one or both options.
Instructions for each option are explained below.
### Overriding/Patching a package
Purpose:
- Change a package's dependency to a newer/older release than the
default package set's release
- Use your own modified version of some dependency that may
include new API, changed API, removed API by
using your custom git repo of the library rather than
the package set's repo
Syntax:
where `entityName` is one of the following:
- dependencies
- repo
- version
-------------------------------
let upstream = --
in upstream
with packageName.entityName = "new value"
-------------------------------
Example:
-------------------------------
let upstream = --
in upstream
with halogen.version = "master"
with halogen.repo = "https://example.com/path/to/git/repo.git"
with halogen-vdom.version = "v4.0.0"
with halogen-vdom.dependencies = [ "extra-dependency" ] # halogen-vdom.dependencies
-------------------------------
### Additions
Purpose:
- Add packages that aren't already included in the default package set
Syntax:
where `<version>` is:
- a tag (i.e. "v4.0.0")
- a branch (i.e. "master")
- commit hash (i.e. "701f3e44aafb1a6459281714858fadf2c4c2a977")
-------------------------------
let upstream = --
in upstream
with new-package-name =
{ dependencies =
[ "dependency1"
, "dependency2"
]
, repo =
"https://example.com/path/to/git/repo.git"
, version =
"<version>"
}
-------------------------------
Example:
-------------------------------
let upstream = --
in upstream
with benchotron =
{ dependencies =
[ "arrays"
, "exists"
, "profunctor"
, "strings"
, "quickcheck"
, "lcg"
, "transformers"
, "foldable-traversable"
, "exceptions"
, "node-fs"
, "node-buffer"
, "node-readline"
, "datetime"
, "now"
]
, repo =
"https://github.com/hdgarrood/purescript-benchotron.git"
, version =
"v7.0.0"
}
-------------------------------
-}
let upstream =
https://github.com/purescript/package-sets/releases/download/psc-0.14.1-20210516/packages.dhall sha256:f5e978371d4cdc4b916add9011021509c8d869f4c3f6d0d2694c0e03a85046c8
https://github.com/purescript/package-sets/releases/download/psc-0.15.7-20230227/packages.dhall
sha256:0168e165b4cdb40ab6f7e01448075680097791c8d98f96d684b20d1eef96f3d0
in upstream
in upstream

View File

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

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(..))
@ -97,6 +98,7 @@ type GraphQLClientAff =
graphQL
:: Endpoint
-> Array RequestHeader
-> AffjaxDriver
-> ( forall (operation :: GraphQL) (gql :: Symbol) (i :: Row Type) (o :: Row Type)
. GraphQLReqRes operation gql i o
=> IsSymbol gql
@ -106,14 +108,16 @@ graphQL
-> Record i
-> Aff { | o }
)
graphQL endpoint headers = graphQL'
graphQL endpoint headers driver = graphQL'
endpoint
headers
driver
(error <<< AX.printError <<< _.error)
(error <<< _.body <<< _.response)
graphQL' :: Endpoint -> Array RequestHeader -> GraphQLClient
graphQL' endpoint headers' = go
graphQL' :: Endpoint -> Array RequestHeader -> AffjaxDriver -> GraphQLClient
graphQL' endpoint headers' driver = go
where
requestHeaders = headers' <> [ ContentType $ MediaType "application/json" ]
@ -146,7 +150,7 @@ graphQL' endpoint headers' = go
}
requestBody = JSON.writeJSON input
res <-
liftAff $ AX.request
liftAff $ 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

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