Skip to content

Commit

Permalink
test: fix federation usage (#2910)
Browse files Browse the repository at this point in the history
  • Loading branch information
meskill authored Sep 25, 2024
1 parent 04e7a6a commit 9f184fe
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 64 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ type Query {
user(id: Int!): User @http(path: "/users/{{.args.id}}")
}

type User
@http(batchKey: ["id"], path: "/users", query: [{key: "id", value: "{{.value.user.id}}"}])
@key(fields: "user { id }") {
type User @http(batchKey: ["id"], path: "/users", query: [{key: "id", value: "{{.value.id}}"}]) @key(fields: "id") {
id: Int!
name: String!
}
Expand Down
2 changes: 1 addition & 1 deletion tests/core/snapshots/apollo-federation-entities.md_1.snap

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type Query {
user(id: Int!): User @http(path: "/users/{{.args.id}}")
}

type User @call(steps: [{query: "user", args: {id: "{{.value.user.id}}"}}]) @key(fields: "user { id }") {
type User @call(steps: [{query: "user", args: {id: "{{.value.id}}"}}]) @key(fields: "id") {
id: Int!
name: String!
}
Expand Down
6 changes: 3 additions & 3 deletions tests/execution/apollo-federation-entities-batch.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type Query {
user(id: Int!): User @http(path: "/users/{{.args.id}}")
}

type User @http(path: "/users", query: [{key: "id", value: "{{.value.user.id}}"}], batchKey: ["id"]) {
type User @http(path: "/users", query: [{key: "id", value: "{{.value.id}}"}], batchKey: ["id"]) {
id: Int!
name: String!
}
Expand Down Expand Up @@ -90,8 +90,8 @@ type Post
query: >
{
_entities(representations: [
{user: { id: 1 }, __typename: "User"}
{user: { id: 2 }, __typename: "User"}
{id: 1, __typename: "User"}
{id: 2, __typename: "User"}
# TODO: fix selection set of fields for @graphQL directive in jit
# {id: 3, __typename: "Post"}
# {id: 5, __typename: "Post"}
Expand Down
53 changes: 1 addition & 52 deletions tests/execution/apollo-federation-entities-validation.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,59 +20,8 @@ type User @call(steps: [{query: "user", args: {id: "{{.args.id}}"}}]) {
name: String!
}

type Post @http(path: "/users", query: [{key: "id", value: "{{.args.user.id}}"}]) {
type Post @http(path: "/posts", query: [{key: "id", value: "{{.args.id}}"}]) {
id: Int!
title: String!
}
```

```yml @mock
- request:
method: GET
url: http://jsonplaceholder.typicode.com/users/1
response:
status: 200
body:
id: 1
name: Leanne Graham

- request:
method: GET
url: http://jsonplaceholder.typicode.com/users/2
response:
status: 200
body:
id: 2
name: Ervin Howell
```

```yml @test
- method: POST
url: http://localhost:8080/graphql
body:
query: >
{
_entities(representations: [
{user: { id: 1 }, __typename: "User"}
{user: { id: 2 }, __typename: "User"}
{user: { id: 3 }, __typename: "Post"}
{user: { id: 5 }, __typename: "Post"}
]) {
__typename
...on User {
id
name
}
...on Post {
id
title
}
}
}
- method: POST
url: http://localhost:8080/graphql
body:
query: >
{ _service { sdl } }
```
6 changes: 3 additions & 3 deletions tests/execution/apollo-federation-entities.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type Query {
user(id: Int!): User @http(path: "/users/{{.args.id}}")
}

type User @call(steps: [{query: "user", args: {id: "{{.value.user.id}}"}}]) {
type User @call(steps: [{query: "user", args: {id: "{{.value.id}}"}}]) {
id: Int!
name: String!
}
Expand Down Expand Up @@ -52,8 +52,8 @@ type Post @expr(body: {id: "{{.value.id}}", title: "post-title-{{.value.id}}"})
query: >
{
_entities(representations: [
{user: { id: 1 }, __typename: "User"}
{user: { id: 2 }, __typename: "User"}
{id: 1, __typename: "User"}
{id: 2, __typename: "User"}
{id: 3, __typename: "Post"}
{id: 5, __typename: "Post"}
]) {
Expand Down

1 comment on commit 9f184fe

@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 11.75ms 5.20ms 193.01ms 92.44%
Req/Sec 2.17k 266.87 2.89k 83.67%

259011 requests in 30.03s, 1.30GB read

Requests/sec: 8624.76

Transfer/sec: 44.27MB

Please sign in to comment.