Skip to content

Commit

Permalink
fix: nested args (#2255)
Browse files Browse the repository at this point in the history
  • Loading branch information
ouertani authored Jun 23, 2024
1 parent df0bf4c commit cd21c54
Show file tree
Hide file tree
Showing 5 changed files with 164 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/core/ir/eval_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ fn format_selection_field_arguments(field: SelectionField) -> Cow<'static, str>
.collect::<Vec<_>>()
.join(",");

Cow::Owned(format!("({})", args))
Cow::Owned(format!("({})", args.escape_default()))
}

// TODO: this is the same code as src/json/json_like.rs::get_path
Expand Down
22 changes: 22 additions & 0 deletions tests/core/snapshots/test-input-with-arg-out.md_0.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
source: tests/core/spec.rs
assertion_line: 200
expression: response
---
{
"status": 200,
"headers": {
"content-type": "application/json"
},
"body": {
"data": {
"queryTest": [
{
"id": 1,
"name": "foo",
"num": 1
}
]
}
}
}
59 changes: 59 additions & 0 deletions tests/core/snapshots/test-input-with-arg-out.md_client.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
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

input IntFilter {
i: Int
}

scalar JSON

type MyType {
id: String!
name(sf: StringFilter): String
num(if: IntFilter): Int
}

scalar PhoneNumber

type Query {
queryTest(filter: StringFilter): [MyType]
}

input StringFilter {
s: String
}

scalar UInt128

scalar UInt16

scalar UInt32

scalar UInt64

scalar UInt8

scalar Url

schema {
query: Query
}
31 changes: 31 additions & 0 deletions tests/core/snapshots/test-input-with-arg-out.md_merged.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
source: tests/core/spec.rs
assertion_line: 235
expression: formatter
---
schema @server @upstream {
query: Query
}

input IntFilter {
i: Int
}

input StringFilter {
s: String
}

type MyType {
id: String!
name(sf: StringFilter): String
num(if: IntFilter): Int
}

type Query {
queryTest(filter: StringFilter): [MyType]
@graphQL(
args: [{key: "filter", value: "{{.args.filter}}"}]
baseURL: "http://localhost:8083/mesh"
name: "getMyType"
)
}
51 changes: 51 additions & 0 deletions tests/execution/test-input-with-arg-out.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# test-input-with-arg-type

```graphql @config
schema {
query: Query
}

type Query {
queryTest(filter: StringFilter): [MyType]
@graphQL(
name: "getMyType"
args: [{key: "filter", value: "{{.args.filter}}"}]
baseURL: "http://localhost:8083/mesh"
)
}

type StringFilter {
s: String
}
type IntFilter {
i: Int
}

type MyType {
id: String!
name(sf: StringFilter): String
num(if: IntFilter): Int
}
```

```yml @mock
- request:
method: POST
url: http://localhost:8083/mesh
textBody: '{ "query": "query { getMyType(filter: {s: \\\"1\\\"}) { id name(sf: {s: \\\"f\\\"}) num(if: {i: 3}) } }" }'
response:
status: 200
body:
data:
getMyType:
- id: 1
name: foo
num: 1
```

```yml @test
- method: POST
url: http://localhost:8000/graphql
body:
query: 'query { queryTest(filter: {s: "1"}) { id name(sf: {s: "f"}) num(if: {i :3}) } }'
```

1 comment on commit cd21c54

@github-actions
Copy link

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

Thread Stats Avg Stdev Max +/- Stdev
Latency 6.65ms 2.92ms 64.80ms 71.08%
Req/Sec 3.80k 189.24 4.34k 90.50%

453831 requests in 30.01s, 2.27GB read

Requests/sec: 15121.46

Transfer/sec: 77.61MB

Please sign in to comment.