git.iko.soy/rowtype-yoga/purescript-yoga-fetch-om
on main help sign in
Add QUERY request method support (#2)

* Add QUERY request method support * Use registry http-methods 6.1.0

commit4e8185bbaa975007e81630d8f34d064ff0b5bdb4 authorMark Eibes <mark.eibes@gmail.com> dateSat 11 Jul 2026, 21:51 (3 months ago) parentb703f9c
4 files changed+31−20
spago.lock+3−3 spago.yaml+1−1 src/Yoga/Fetch/Om/MakeRequest.purs+3 test/MakeRequest.Spec.purs+24−16
spago.lock+3−3
@@ -24,7 +24,7 @@
2424 "exceptions": ">=6.1.0 <7.0.0"
2525 },
2626 {
27− "http-methods": ">=6.0.0 <7.0.0"
27+ "http-methods": ">=6.1.0 <7.0.0"
2828 },
2929 {
3030 "js-fetch": ">=0.2.1 <0.3.0"
@@ -542,8 +542,8 @@
542542 },
543543 "http-methods": {
544544 "type": "registry",
545− "version": "6.0.0",
546− "integrity": "sha256-S0UjrJSgwJxEsFHM/pX77dM8V4HfvvDqdHPckQrtxMs=",
545+ "version": "6.1.0",
546+ "integrity": "sha256-WbjEmCv6rysY/aKwlrcspyzShi5bIQy+AFpDzPMnSP4=",
547547 "dependencies": [
548548 "either",
549549 "prelude",
spago.yaml+1−1
@@ -20,7 +20,7 @@ package:
2020 - effect: ">=4.0.0 <5.0.0"
2121 - either: ">=6.1.0 <7.0.0"
2222 - exceptions: ">=6.1.0 <7.0.0"
23− - http-methods: ">=6.0.0 <7.0.0"
23+ - http-methods: ">=6.1.0 <7.0.0"
2424 - js-fetch: ">=0.2.1 <0.3.0"
2525 - js-promise-aff: ">=1.0.0 <2.0.0"
2626 - maybe: ">=6.0.0 <7.0.0"
src/Yoga/Fetch/Om/MakeRequest.purs+3
@@ -56,6 +56,9 @@ instance MakeRequest Method.DELETE where
5656instance MakeRequest Method.PATCH where
5757 httpMethod _ = PATCH
5858
59+instance MakeRequest Method.QUERY where
60+ httpMethod _ = QUERY
61+
5962makeRequest
6063 :: forall method
6164 . MakeRequest method
test/MakeRequest.Spec.purs+24−16
@@ -2,6 +2,7 @@ module MakeRequest.Spec where
22
33import Prelude
44
5+import Data.HTTP.Method as HTTP
56import Data.Tuple.Nested ((/\))
67import JS.Fetch.Headers as Headers
78import Prim.RowList as RL
@@ -9,23 +10,30 @@ import Test.Spec (Spec, describe, it)
910import Test.Spec.Assertions (shouldEqual, shouldSatisfy)
1011import Type.Proxy (Proxy(..))
1112import Yoga.Fetch.Om (toHeaders)
13+import Yoga.Fetch.Om.MakeRequest (httpMethod)
14+import Yoga.HTTP.API.Route.Method as Route
1215
1316spec :: Spec Unit
14−spec = describe "toHeaders" do
15− it "empty headers produces no entries" do
16− let hdrs = toHeaders (Proxy :: _ RL.Nil) {}
17− Headers.toArray hdrs `shouldEqual` []
17+spec = do
18+ describe "MakeRequest" do
19+ it "maps a QUERY route method to the QUERY runtime method" do
20+ httpMethod (Proxy :: Proxy Route.QUERY) `shouldEqual` HTTP.QUERY
1821
19− it "single header is included" do
20− let hdrs = toHeaders (Proxy :: _ (RL.Cons "authorization" String RL.Nil)) { authorization: "Bearer abc123" }
21− Headers.toArray hdrs `shouldEqual` [ "authorization" /\ "Bearer abc123" ]
22+ describe "toHeaders" do
23+ it "empty headers produces no entries" do
24+ let hdrs = toHeaders (Proxy :: _ RL.Nil) {}
25+ Headers.toArray hdrs `shouldEqual` []
2226
23− it "multiple headers are included" do
24− let
25− hdrs = toHeaders
26− (Proxy :: _ (RL.Cons "authorization" String (RL.Cons "x-custom" String RL.Nil)))
27− { authorization: "Bearer abc123", "x-custom": "value" }
28− arr = Headers.toArray hdrs
29− arr `shouldSatisfy` \a ->
30− a == [ "authorization" /\ "Bearer abc123", "x-custom" /\ "value" ]
31− || a == [ "x-custom" /\ "value", "authorization" /\ "Bearer abc123" ]
27+ it "single header is included" do
28+ let hdrs = toHeaders (Proxy :: _ (RL.Cons "authorization" String RL.Nil)) { authorization: "Bearer abc123" }
29+ Headers.toArray hdrs `shouldEqual` [ "authorization" /\ "Bearer abc123" ]
30+
31+ it "multiple headers are included" do
32+ let
33+ hdrs = toHeaders
34+ (Proxy :: _ (RL.Cons "authorization" String (RL.Cons "x-custom" String RL.Nil)))
35+ { authorization: "Bearer abc123", "x-custom": "value" }
36+ arr = Headers.toArray hdrs
37+ arr `shouldSatisfy` \a ->
38+ a == [ "authorization" /\ "Bearer abc123", "x-custom" /\ "value" ]
39+ || a == [ "x-custom" /\ "value", "authorization" /\ "Bearer abc123" ]