Skip to content

Commit

Permalink
chore: testconv showcase
Browse files Browse the repository at this point in the history
  • Loading branch information
mogery committed Feb 3, 2024
1 parent 61bfbc1 commit 146b006
Show file tree
Hide file tree
Showing 8 changed files with 195 additions and 0 deletions.
74 changes: 74 additions & 0 deletions tests/execution/showcase.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Showcase GraphQL Request

#### server:

```graphql
schema @server(showcase: true) {
query: Query
}

type User {
not_id: Int
not_name: String
}

type Query {
not_user: User @http(path: "/users/1", baseURL: "http://jsonplaceholder.typicode.com")
}
```

#### mock:

```yml
- request:
method: GET
url: http://jsonplaceholder.typicode.com/users/1
headers:
test: test
body: null
response:
status: 200
body:
id: 1
name: foo
- request:
method: GET
url: http://example.com/simple.graphql
body: null
response:
status: 200
body: null
- request:
method: GET
url: http://example.com/invalid.graphql
body: null
response:
status: 200
body: dsjfsjdfjdsfjkdskjfjkds
```

#### assert:

```yml
- method: POST
url: http://localhost:8080/showcase/graphql?config=http%3A%2F%2Fexample.com%2Fsimple.graphql
body:
query: query { user { name } }
- method: POST
url: http://localhost:8080/showcase/graphql
body:
query: query { user { name } }
- method: POST
url: http://localhost:8080/showcase/graphql?config=.%2Ftests%2Fhttp%2Fconfig%2Fsimple.graphql
body:
query: query { user { name } }
- method: POST
url: http://localhost:8080/showcase/graphql?config=http%3A%2F%2Fexample.com%2Finvalid.graphql
body:
query: query { user { name } }
- method: POST
url: http://localhost:8080/showcase/graphql?config=http%3A%2F%2Fexample.com%2Fsimple.graphql
body:
query:
foo: bar
```
17 changes: 17 additions & 0 deletions tests/snapshots/execution_spec__showcase.md_assert_0.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
source: tests/execution_spec.rs
expression: response
---
{
"status": 200,
"headers": {
"content-type": "application/json"
},
"body": {
"data": {
"user": {
"name": "foo"
}
}
}
}
18 changes: 18 additions & 0 deletions tests/snapshots/execution_spec__showcase.md_assert_1.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
source: tests/execution_spec.rs
expression: response
---
{
"status": 200,
"headers": {
"content-type": "application/json"
},
"body": {
"data": null,
"errors": [
{
"message": "No Config URL specified"
}
]
}
}
18 changes: 18 additions & 0 deletions tests/snapshots/execution_spec__showcase.md_assert_2.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
source: tests/execution_spec.rs
expression: response
---
{
"status": 200,
"headers": {
"content-type": "application/json"
},
"body": {
"data": null,
"errors": [
{
"message": "Invalid Config URL specified"
}
]
}
}
18 changes: 18 additions & 0 deletions tests/snapshots/execution_spec__showcase.md_assert_3.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
source: tests/execution_spec.rs
expression: response
---
{
"status": 200,
"headers": {
"content-type": "application/json"
},
"body": {
"data": null,
"errors": [
{
"message": "Failed to read config: Validation Error\n• --> 1:1\n |\n1 | \"dsjfsjdfjdsfjkdskjfjkds\"\n | ^---\n |\n = expected type_system_definition\n"
}
]
}
}
18 changes: 18 additions & 0 deletions tests/snapshots/execution_spec__showcase.md_assert_4.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
source: tests/execution_spec.rs
expression: response
---
{
"status": 200,
"headers": {
"content-type": "application/json"
},
"body": {
"data": null,
"errors": [
{
"message": "Unexpected GraphQL Request: invalid type: map, expected a string at line 1 column 9"
}
]
}
}
16 changes: 16 additions & 0 deletions tests/snapshots/execution_spec__showcase.md_client.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
source: tests/execution_spec.rs
expression: client
---
type Query {
not_user: User
}

type User {
not_id: Int
not_name: String
}

schema {
query: Query
}
16 changes: 16 additions & 0 deletions tests/snapshots/execution_spec__showcase.md_merged.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
source: tests/execution_spec.rs
expression: merged
---
schema @server(showcase: true) @upstream {
query: Query
}

type Query {
not_user: User @http(baseURL: "http://jsonplaceholder.typicode.com", path: "/users/1")
}

type User {
not_id: Int
not_name: String
}

0 comments on commit 146b006

Please sign in to comment.