Skip to content

Commit 1d2c2eb

Browse files
fix(2958): fix unhandled enum in convert_value (#2964)
1 parent ab89053 commit 1d2c2eb

File tree

5 files changed

+110
-0
lines changed

5 files changed

+110
-0
lines changed

src/core/path.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ fn convert_value(value: Cow<'_, async_graphql::Value>) -> Option<Cow<'_, str>> {
5252
Cow::Borrowed(async_graphql::Value::Boolean(b)) => Some(Cow::Owned(b.to_string())),
5353
Cow::Borrowed(async_graphql::Value::Object(map)) => Some(json!(map).to_string().into()),
5454
Cow::Borrowed(async_graphql::Value::List(list)) => Some(json!(list).to_string().into()),
55+
Cow::Borrowed(async_graphql::Value::Enum(n)) => Some(Cow::Borrowed(n)),
5556
_ => None,
5657
}
5758
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
source: tests/core/spec.rs
3+
expression: response
4+
---
5+
{
6+
"status": 200,
7+
"headers": {
8+
"content-type": "application/json"
9+
},
10+
"body": {
11+
"data": {
12+
"color": "RED"
13+
}
14+
}
15+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
source: tests/core/spec.rs
3+
expression: formatted
4+
---
5+
scalar Bytes
6+
7+
enum COLOR {
8+
BLUE
9+
GREEN
10+
RED
11+
}
12+
13+
scalar Date
14+
15+
scalar DateTime
16+
17+
scalar Email
18+
19+
scalar Empty
20+
21+
scalar Int128
22+
23+
scalar Int16
24+
25+
scalar Int32
26+
27+
scalar Int64
28+
29+
scalar Int8
30+
31+
scalar JSON
32+
33+
scalar PhoneNumber
34+
35+
type Query {
36+
color(item: COLOR): COLOR
37+
}
38+
39+
scalar UInt128
40+
41+
scalar UInt16
42+
43+
scalar UInt32
44+
45+
scalar UInt64
46+
47+
scalar UInt8
48+
49+
scalar Url
50+
51+
schema {
52+
query: Query
53+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
source: tests/core/spec.rs
3+
expression: formatter
4+
---
5+
schema @server @upstream {
6+
query: Query
7+
}
8+
9+
enum COLOR {
10+
BLUE
11+
GREEN
12+
RED
13+
}
14+
15+
type Query {
16+
color(item: COLOR): COLOR @expr(body: "{{.args.item}}")
17+
}

tests/execution/enum-args.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Enum Arguments
2+
3+
```graphql @config
4+
schema {
5+
query: Query
6+
}
7+
8+
enum COLOR {
9+
RED
10+
GREEN
11+
BLUE
12+
}
13+
14+
type Query {
15+
color(item: COLOR): COLOR @expr(body: "{{.args.item}}")
16+
}
17+
```
18+
19+
```yml @test
20+
- method: POST
21+
url: http://localhost:8000/graphql
22+
body:
23+
query: "query { color(item: RED) }"
24+
```

0 commit comments

Comments
 (0)