-
Notifications
You must be signed in to change notification settings - Fork 259
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add support for enum args in query encoder (#2994)
- Loading branch information
1 parent
052e037
commit 1679aea
Showing
5 changed files
with
99 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
source: tests/core/spec.rs | ||
expression: response | ||
--- | ||
{ | ||
"status": 200, | ||
"headers": { | ||
"content-type": "application/json" | ||
}, | ||
"body": { | ||
"data": { | ||
"user": { | ||
"name": "Json Schema" | ||
} | ||
} | ||
} | ||
} |
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,21 @@ | ||
--- | ||
source: tests/core/spec.rs | ||
expression: formatted | ||
--- | ||
type Query { | ||
user(id: Int!, test: Test): User | ||
} | ||
|
||
enum Test { | ||
A | ||
B | ||
} | ||
|
||
type User { | ||
id: Int! | ||
name: String! | ||
} | ||
|
||
schema { | ||
query: Query | ||
} |
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,21 @@ | ||
--- | ||
source: tests/core/spec.rs | ||
expression: formatter | ||
--- | ||
schema @server @upstream(baseURL: "http://jsonplaceholder.typicode.com") { | ||
query: Query | ||
} | ||
|
||
enum Test { | ||
A | ||
B | ||
} | ||
|
||
type Query { | ||
user(id: Int!, test: Test): User @http(path: "/users/{{.args.id}}", query: [{key: "enum", value: "{{.args.test}}"}]) | ||
} | ||
|
||
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,39 @@ | ||
# test enum as argument | ||
|
||
```graphql @config | ||
schema @server @upstream(baseURL: "http://jsonplaceholder.typicode.com") { | ||
query: Query | ||
} | ||
|
||
type Query { | ||
user(id: Int!, test: Test): User @http(path: "/users/{{.args.id}}", query: [{key: "enum", value: "{{.args.test}}"}]) | ||
} | ||
|
||
enum Test { | ||
A | ||
B | ||
} | ||
|
||
type User { | ||
id: Int! | ||
name: String! | ||
} | ||
``` | ||
|
||
```yml @mock | ||
- request: | ||
method: GET | ||
url: http://jsonplaceholder.typicode.com/users/1?enum=A | ||
response: | ||
status: 200 | ||
body: | ||
id: 1 | ||
name: Json Schema | ||
``` | ||
|
||
```yml @test | ||
- method: POST | ||
url: http://localhost:8080/graphql | ||
body: | ||
query: "query { user(id: 1, test: A) { name } }" | ||
``` |
1679aea
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Running 30s test @ http://localhost:8000/graphql
4 threads and 100 connections
402625 requests in 30.02s, 772.69MB read
Requests/sec: 13411.66
Transfer/sec: 25.74MB