Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
webbdays committed May 17, 2024
1 parent a0d62a0 commit fb195f5
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/core/snapshots/test-js-multi-onRequest-handlers.md_0.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
source: tests/core/spec.rs
expression: response
---
{
"status": 200,
"headers": {
"content-type": "application/json"
},
"body": {
"data": {
"foo": "its intercepted foo",
"bar": "its intercepted bar"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
source: tests/core/spec.rs
expression: client
---
scalar Date

scalar Email

scalar Empty

scalar JSON

scalar PhoneNumber

type Query {
bar: String
foo: String
}

scalar Url

schema {
query: Query
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
source: tests/core/spec.rs
expression: merged
---
schema @server @upstream(onRequest: "foo", baseURL: "http://localhost:3000") @link(src: "test1.js", type: Script) {
query: Query
}

type Query {
bar: String @http(onRequest: "bar", baseURL: "http://localhost:3000", path: "/bar")
foo: String @http(baseURL: "http://localhost:3000", path: "/foo")
}
47 changes: 47 additions & 0 deletions tests/execution/test-js-multi-onRequest-handlers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Js Request - Multiple onRequest Handlers

```js @file:test1.js
function onRequest({request}) {
return {request}
}
function foo({request}) {
return {
response: {
status: 200,
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify("its intercepted foo"),
},
}
}
function bar({request}) {
return {
response: {
status: 200,
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify("its intercepted bar"),
},
}
}
```

```graphql @config
schema @server @upstream(baseURL: "http://localhost:3000", onRequest: "foo") @link(type: Script, src: "test1.js") {
query: Query
}

type Query {
foo: String @http(baseURL: "http://localhost:3000", path: "/foo")
bar: String @http(baseURL: "http://localhost:3000", path: "/bar", onRequest: "bar")
}
```

```yml @test
- method: POST
url: http://localhost:8080/graphql
body:
query: query { foo bar }
```

1 comment on commit fb195f5

@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.91ms 3.17ms 90.77ms 73.14%
Req/Sec 3.67k 192.84 4.21k 91.42%

437819 requests in 30.01s, 2.19GB read

Requests/sec: 14588.18

Transfer/sec: 74.88MB

Please sign in to comment.