forked from tailcallhq/tailcall
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: pick query params with empty values (tailcallhq#2470)
Co-authored-by: Tushar Mathur <[email protected]>
- Loading branch information
1 parent
34fde45
commit 8390cd9
Showing
7 changed files
with
222 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
tests/core/snapshots/batching-group-by-optional-key.md_0.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- | ||
source: tests/core/spec.rs | ||
expression: response | ||
--- | ||
{ | ||
"status": 200, | ||
"headers": { | ||
"content-type": "application/json" | ||
}, | ||
"body": { | ||
"data": { | ||
"posts": [ | ||
{ | ||
"user": { | ||
"id": 1 | ||
}, | ||
"userId": 1 | ||
}, | ||
{ | ||
"user": null, | ||
"userId": null | ||
} | ||
] | ||
} | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
tests/core/snapshots/batching-group-by-optional-key.md_client.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
--- | ||
source: tests/core/spec.rs | ||
expression: formatted | ||
--- | ||
scalar Bytes | ||
|
||
scalar Date | ||
|
||
scalar Email | ||
|
||
scalar Empty | ||
|
||
scalar Int128 | ||
|
||
scalar Int16 | ||
|
||
scalar Int32 | ||
|
||
scalar Int64 | ||
|
||
scalar Int8 | ||
|
||
scalar JSON | ||
|
||
scalar PhoneNumber | ||
|
||
type Post { | ||
body: String | ||
id: Int | ||
title: String | ||
user: User | ||
userId: Int | ||
} | ||
|
||
type Query { | ||
posts: [Post] | ||
} | ||
|
||
scalar UInt128 | ||
|
||
scalar UInt16 | ||
|
||
scalar UInt32 | ||
|
||
scalar UInt64 | ||
|
||
scalar UInt8 | ||
|
||
scalar Url | ||
|
||
type User { | ||
id: Int | ||
name: String | ||
} | ||
|
||
schema { | ||
query: Query | ||
} |
35 changes: 35 additions & 0 deletions
35
tests/core/snapshots/batching-group-by-optional-key.md_merged.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--- | ||
source: tests/core/spec.rs | ||
expression: formatter | ||
--- | ||
schema | ||
@server(port: 8000, queryValidation: false) | ||
@upstream( | ||
baseURL: "http://jsonplaceholder.typicode.com" | ||
batch: {delay: 1, headers: [], maxSize: 1000} | ||
httpCache: 42 | ||
) { | ||
query: Query | ||
} | ||
|
||
type Post { | ||
body: String | ||
id: Int | ||
title: String | ||
user: User | ||
@http( | ||
batchKey: ["id"] | ||
path: "/users" | ||
query: [{key: "id", value: "{{.value.userId}}"}, {key: "foo", value: "bar"}] | ||
) | ||
userId: Int | ||
} | ||
|
||
type Query { | ||
posts: [Post] @http(path: "/posts?id=11&id=3&foo=1") | ||
} | ||
|
||
type User { | ||
id: Int | ||
name: String | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# Batching group by | ||
|
||
```graphql @config | ||
schema | ||
@server(port: 8000, queryValidation: false) | ||
@upstream(baseURL: "http://jsonplaceholder.typicode.com", httpCache: 42, batch: {delay: 1, maxSize: 1000}) { | ||
query: Query | ||
} | ||
|
||
type Query { | ||
posts: [Post] @http(path: "/posts?id=11&id=3&foo=1") | ||
} | ||
|
||
type Post { | ||
id: Int | ||
title: String | ||
body: String | ||
userId: Int | ||
user: User | ||
@http( | ||
path: "/users" | ||
query: [{key: "id", value: "{{.value.userId}}"}, {key: "foo", value: "bar"}] | ||
batchKey: ["id"] | ||
) | ||
} | ||
|
||
type User { | ||
id: Int | ||
name: String | ||
} | ||
``` | ||
|
||
```yml @mock | ||
- request: | ||
method: GET | ||
url: http://jsonplaceholder.typicode.com/posts?id=11&id=3&foo=1 | ||
response: | ||
status: 200 | ||
body: | ||
- body: bar | ||
id: 11 | ||
title: foo | ||
userId: 1 | ||
- body: bar # no userId for bar | ||
id: 3 | ||
title: foo | ||
- request: | ||
method: GET | ||
url: http://jsonplaceholder.typicode.com/users?id&foo=bar&id=1 # query should be id&foo=bar&id=1 | ||
response: | ||
status: 200 | ||
body: | ||
- id: 1 | ||
name: Leanne Graham | ||
- id: 2 | ||
name: Ervin Howell | ||
``` | ||
|
||
```yml @test | ||
- method: POST | ||
url: http://localhost:8080/graphql | ||
body: | ||
query: query { posts { user { id } userId } } | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters