Skip to content

Commit ac04c9a

Browse files
committed
Include query params in POST requests.
1 parent 8dcf2b4 commit ac04c9a

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

src/Graphql/Http/QueryHelper.elm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ build forceMethod url queryParams maybeOperationName queryDocument =
6060
( Document.serializeQuery queryDocument, [] )
6161
in
6262
{ method = Post
63-
, url = QueryParams.urlWithQueryParams [] url
63+
, url = QueryParams.urlWithQueryParams queryParams url
6464
, body =
6565
Http.jsonBody <|
6666
Json.Encode.object <|

tests/Http/QueryHelperTests.elm

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,28 @@ all =
8686
, url = "https://elm-graphql.herokuapp.com/api"
8787
, body = Http.jsonBody (Json.Encode.object [ ( "query", Json.Encode.string (Document.serializeQuery queryDocument) ) ])
8888
}
89+
, test "passes through query params for POST requests" <|
90+
\() ->
91+
let
92+
queryDocument =
93+
document
94+
[ Composite "hero"
95+
[]
96+
[ leaf longName1 []
97+
, leaf longName2 []
98+
]
99+
]
100+
in
101+
queryDocument
102+
|> QueryHelper.build Nothing
103+
"https://elm-graphql.herokuapp.com/api"
104+
[ ( "send", "it" ) ]
105+
Nothing
106+
|> Expect.equal
107+
{ method = QueryHelper.Post
108+
, url = "https://elm-graphql.herokuapp.com/api?send=it"
109+
, body = Http.jsonBody (Json.Encode.object [ ( "query", Json.Encode.string (Document.serializeQuery queryDocument) ) ])
110+
}
89111
, test "uses POST when it too long, with operation name" <|
90112
\() ->
91113
let

0 commit comments

Comments
 (0)